diff --git a/dataloader.py b/dataloader.py index 8cc1603df8cfb317e50a90e75f3b3294b2280a90..6fde979e28573dfdd0a6539465392e1e026b5c02 100644 --- a/dataloader.py +++ b/dataloader.py @@ -563,7 +563,7 @@ class dataloader: ------- >>> dl.wide_df("median_GFP") """ - return self.df.pivot(y, x, signal) + return self.df.pivot(columns=x, index=y, values=signal) def sub_df( self, @@ -641,7 +641,9 @@ class dataloader: if group is None: wdf = self.wide_df(signal, x="time", y="id") elif group in self.df.group.values: - wdf = self.df[self.df.group == group].pivot("id", "time", signal) + wdf = self.df[self.df.group == group].pivot( + columns="time", index="id", values=signal + ) else: print(group, "not recognised") return None, None diff --git a/plotting.py b/plotting.py index 9513a8006ffb33ac602c163abd29e1aa9ce1d97d..456a38b56ec57bec7825aaa49be456e2dac0f164 100644 --- a/plotting.py +++ b/plotting.py @@ -527,7 +527,9 @@ def plot_cuml_divisions_per_cell(t, buddings, nboots=30, col="b", label=None): plt.fill_between(t, cuml - err_cuml, cuml + err_cuml, color=col, alpha=0.2) -def bud_to_bud_plot(tpt, signal, dl, nbins=None, return_signal=False): +def bud_to_bud_plot( + tpt, signal, dl, group=None, nbins=None, return_signal=False +): """ Plot the median and percentiles of a signal between consecutive buddings. @@ -544,10 +546,12 @@ def bud_to_bud_plot(tpt, signal, dl, nbins=None, return_signal=False): The signal to plot. dl: dataloader object A dataloader object with the data to be plotted. - nbins: integer (optional) + group: str, optional + The name of the group to plot. + nbins: integer, optional The number of time bins to partition the interval between the first and the second budding event. - return_signal: boolean (optional) + return_signal: boolean, optional If True, return the signal for each cell interpolated to the time bins. @@ -556,8 +560,8 @@ def bud_to_bud_plot(tpt, signal, dl, nbins=None, return_signal=False): >>> from wela.plotting import bud_to_bud_plot >>> bud_to_bud_plot(8.4, "bud_growth_rate", dl) """ - t, signal_data = dl.get_time_series(signal) - t, buddings = dl.get_time_series("buddings") + t, signal_data = dl.get_time_series(signal, group=group) + t, buddings = dl.get_time_series("buddings", group=group) if np.max(t) > 48: # convert to hours t = t / 60 @@ -606,7 +610,7 @@ def bud_to_bud_plot(tpt, signal, dl, nbins=None, return_signal=False): ) plt.xlabel("position between budding events") plt.ylabel(signal.replace("_", " ")) - plt.title(f"t={tpt}") + plt.title(f"{dl.dataname}: t={tpt}") plt.show(block=False) if return_signal: return new_signal