Skip to content
Snippets Groups Projects
Commit b905961b authored by pswain's avatar pswain
Browse files

change: updated plot_kymograph for new sorting

parent 977ffc4c
No related branches found
No related tags found
No related merge requests found
import matplotlib.cm import matplotlib.cm
import numpy as np
from wela.figs2pdf import figs2pdf from wela.figs2pdf import figs2pdf
from wela.dataloader import dataloader, sort_df from wela.dataloader import dataloader
from wela.sorting import sort_by_maximum
from wela.plotting import kymograph, plot_lineage from wela.plotting import kymograph, plot_lineage
datasets = ["Pdr5_3_11_22", "Pdr5_flc_10ugml_1676"] datasets = ["Pdr5_3_11_22"]
for dataname in datasets: for dataname in datasets:
# load data
dl = dataloader(".", "/Users/pswain/wip/tsv_data/pdr_with_gr/") dl = dataloader(".", "/Users/pswain/wip/tsv_data/pdr_with_gr/")
dl.load(dataname, use_tsv=True) dl.load(dataname, use_tsv=True, hours=False)
sdf = sort_df(dl.df, "median_GFP") dl.df.time = dl.df.time / 60
title = dataname.split(".")[0] title = dataname.split(".")[0]
kymograph(sdf, hue="buddings", title=title) # although only one group for this data
kymograph(sdf, hue="median_GFP", title=title) groups = dl.df.group.unique()
# standard kymographs
kymograph(dl.df, hue="buddings", title=title)
kymograph(dl.df, hue="median_GFP", title=title, buddings=True)
kymograph( kymograph(
sdf, dl.df,
hue="bud_growth_rate", hue="bud_growth_rate",
title=title, title=title,
vmin=-50, vmin=-50,
vmax=50, vmax=50,
cmap=matplotlib.cm.Spectral, cmap=matplotlib.cm.Spectral,
) )
# sorted kymograph
t, data = dl.get_time_series("median_GFP", group=groups[0])
sort_order = sort_by_maximum(data[:, t < 5], np.nanmean)
kymograph(
dl.df,
"median_GFP",
group=groups[0],
buddings=True,
sort_order=sort_order,
title=title,
)
if False: if False:
......
...@@ -4,14 +4,16 @@ import numpy as np ...@@ -4,14 +4,16 @@ import numpy as np
def sort_by_budding(buddings, bud_number=0): def sort_by_budding(buddings, bud_number=0):
"""Return indices for each cell when a particular budding occurs.""" """Return indices for each cell when a particular budding occurs."""
bud_indices = np.transpose(np.nonzero(buddings)) bud_indices = np.transpose(np.nonzero(buddings))
sort_order = [] particular_bud_indices = []
for cell_i in range(buddings.shape[0]): for cell_i in range(buddings.shape[0]):
# find particular bud for this cell
cell_buds = bud_indices[bud_indices[:, 0] == cell_i, :] cell_buds = bud_indices[bud_indices[:, 0] == cell_i, :]
if bud_number < cell_buds.shape[0]: if bud_number < cell_buds.shape[0]:
sort_order.append(cell_buds[bud_number][1]) particular_bud_indices.append(cell_buds[bud_number][1])
else: else:
sort_order.append(np.nan) particular_bud_indices.append(np.nan)
sort_order = np.argsort(sort_order) # arrange by earliest bud
sort_order = np.argsort(particular_bud_indices)
return sort_order return sort_order
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment