Skip to content
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
55d0135
add cell height to toy model
cfrick13 Oct 8, 2024
e588633
enable plotting of old vs new density vs time
cfrick13 Oct 8, 2024
0d4d247
fix volume plot in chosen_volume plot of trakcks
cfrick13 Oct 8, 2024
71ebce8
it worked
cfrick13 Oct 9, 2024
65e65e6
update density plots
cfrick13 Oct 9, 2024
1003b27
add code to make watershed figure for supp fig s3
cfrick13 Oct 10, 2024
1c4c76d
add old density to figure plot temporarily
cfrick13 Oct 10, 2024
998d8e9
finish adjustments to make panels C and D for suppfigS4
cfrick13 Nov 19, 2024
fc448b9
remove unused changes
cfrick13 Nov 19, 2024
a6497d2
finalize updates to toymodel figure code
cfrick13 Nov 20, 2024
f19d059
clean up and rename files
cfrick13 Nov 20, 2024
858a336
Merge branch 'dev' of github.com:AllenCell/nuc-morph-analysis into de…
cfrick13 Nov 21, 2024
0eb1597
fix global_dataset_feature error
cfrick13 Nov 22, 2024
ea6e1ad
restore old global dataset
cfrick13 Nov 22, 2024
114fbc3
add frame formation and adjust colors to SuppFigS4 panelD
cfrick13 Nov 27, 2024
d22d67b
remove colony depth as criteria for uncaught density outliers
cfrick13 Nov 27, 2024
3d0463a
address PR comments and clean up code
cfrick13 Nov 27, 2024
f51268f
remove unused old density schematic
jcass11 Dec 2, 2024
673448e
add track ids for now example tracks
jcass11 Dec 2, 2024
23ccd70
remove references to old unfiltered method
jcass11 Dec 2, 2024
07d4ab4
update imports, use example tracks dict, remove commented code and un…
jcass11 Dec 2, 2024
7e4b59e
move new fig 3 and sfig s4 workflows into one workflow
jcass11 Dec 2, 2024
e57fb84
use example tracks dict
jcass11 Dec 2, 2024
5e84ec4
remove commented out code
jcass11 Dec 2, 2024
6824e4e
remove references to old density and commented out code
jcass11 Dec 2, 2024
f3b1a13
remove test related to old denisty
jcass11 Dec 2, 2024
1aa9b1e
remove references to old denisty and old filtering methods and remove…
jcass11 Dec 2, 2024
2d4b6d4
update imports, add new worklows related to these figures to be part …
jcass11 Dec 2, 2024
f679be2
Put test voronoi back
jcass11 Dec 4, 2024
3745e99
Merge pull request #48 from AllenCell/density_julie
jcass11 Dec 4, 2024
e66de89
Delete nuc_morph_analysis/analyses/evaluate_filters_and_outliers/coun…
cfrick13 Dec 5, 2024
3babe11
Merge branch 'dev' of github.com:AllenCell/nuc-morph-analysis into de…
cfrick13 Dec 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def get_save_dir_and_fig_panel_str(figure, panel):
return savedir, fig_panel_str


def return_glasbey_on_dark(N=255, cell_id=None, cell_color=None):
def return_glasbey_on_dark(N=255, cell_id=None, cell_color=None, from_list=False):
"""
Publication
The Glasbey LUT is based on the publication:
Expand All @@ -110,7 +110,7 @@ def return_glasbey_on_dark(N=255, cell_id=None, cell_color=None):
cell_id: int, the cell id to change the color of
cell_color: array, the RGB color to change the cell to
"""
from matplotlib.colors import LinearSegmentedColormap
from matplotlib.colors import LinearSegmentedColormap, ListedColormap
from nuc_morph_analysis.analyses.dataset_images_for_figures.glasbey_on_dark import (
glasbey_on_dark_func,
)
Expand All @@ -136,7 +136,8 @@ def return_glasbey_on_dark(N=255, cell_id=None, cell_color=None):
cmap_name = "glasbey_on_dark"
rgb_array0_1 = [tuple(np.asarray(x) / 255) for x in glasbey_on_dark]
cmap = LinearSegmentedColormap.from_list(cmap_name, rgb_array0_1, N=N + 1)

if from_list:
cmap = ListedColormap(rgb_array0_1, cmap_name, N=N)
return np.asarray(rgb_array0_255), cmap, rgb_array0_255


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from nuc_morph_analysis.lib.preprocessing import filter_data
from pathlib import Path
from sklearn.linear_model import LinearRegression
from matplotlib.ticker import MaxNLocator

#%%
# set figure directory
Expand All @@ -21,52 +22,19 @@
dfm = filter_data.all_timepoints_minimal_filtering(df)

#%% # plot density over time for each colony along colony time
x_col = "colony_time"
column_val = 'label_img'
feature_list = ['2d_area_nuc_cell_ratio','density','2d_area_nucleus','2d_area_pseudo_cell',
'2d_area_cyto','inv_cyto_density','2d_intensity_min_edge','2d_intensity_max_edge','2d_intensity_mean_edge'
]
for y_col in feature_list:
fig,ax = plt.subplots(figsize=(4,3))

for colony in ['small','medium','large']:

dfsub = dfm[dfm['colony']==colony].copy()
dfsub.dropna(subset=[y_col],inplace=True)

# create a pivot of the dataframe to get a 2d array of track_id x timepoint with each value being the density
pivot = dfsub.pivot(index=x_col, columns=column_val, values=y_col)
pivot.head()

mean = pivot.median(axis=1)
lower = pivot.quantile(0.05,axis=1)
upper = pivot.quantile(0.95,axis=1)

xscale_factor, xlabel, xunit, xlimit = get_plot_labels_for_metric(x_col)
x = mean.index * xscale_factor
yscale_factor, ylabel, yunit, ylimit = get_plot_labels_for_metric(y_col)
y = mean.values * yscale_factor
yl = lower.values * yscale_factor
yu = upper.values * yscale_factor

ax.plot(x, y, label=COLONY_LABELS[colony], color=COLONY_COLORS[colony])
ax.fill_between(x, yl, yu, alpha=0.2, color=COLONY_COLORS[colony],
edgecolor='none')
ax.set_xlabel(f"{xlabel} {xunit}")
ax.set_ylabel(f"{ylabel} {yunit}\n(90% interpercentile range)")
import matplotlib
matplotlib.rcParams.update({'font.size': 8})
matplotlib.rcParams.update({'axes.titlesize': 8})
matplotlib.rcParams.update({'axes.labelsize': 8})
matplotlib.rcParams.update({'xtick.labelsize': 8})
matplotlib.rcParams.update({'ytick.labelsize': 8})
matplotlib.rcParams.update({'legend.fontsize': 7})
matplotlib.rcParams.update({'legend.title_fontsize': 8})
matplotlib.rcParams.update({'figure.titlesize': 8})
# make axis linewidth thinner
matplotlib.rcParams.update({'axes.linewidth': 0.5})


ax.legend(loc="upper right", handletextpad=0.7, frameon=False)
plt.tight_layout()
for ext in ['.png','.pdf']:
save_and_show_plot(
f"{figdir}/{y_col}_vs_{x_col}_by_colony",
file_extension=ext,
dpi=300,
transparent=False,
)
plt.show()

#%%
# plot density as a function of nucleus size (and compare to old density metric)
colony='medium'
Expand All @@ -88,6 +56,7 @@
ax.set_xlabel(f"{xlabel} {xunit}")
ax.set_ylabel(f"{ylabel} {yunit}")


# add best fit line
reg = LinearRegression().fit(x.reshape(-1,1), y)
y_pred = reg.predict(x.reshape(-1,1))
Expand Down

This file was deleted.

Loading
Loading