1111
1212from util import sliding_runlength_sum , frequency_mapping , SYNAPSE_DIR_ROOT
1313
14- INPUT_ROOT = "/home/pape/Work/my_projects/flamingo-tools/scripts/M_LR_000227_R/scale3/frequency_mapping"
14+ INPUT_ROOT = "/home/pape/Work/my_projects/flamingo-tools/scripts/M_LR_000227_R/scale3"
15+
16+ TYPE_TO_CHANNEL = {
17+ "Type-Ia" : "CR" ,
18+ "Type-Ib" : "Calb1" ,
19+ "Type-Ic" : "Lypd1" ,
20+ "Type-II" : "Prph" ,
21+ }
1522
1623png_dpi = 300
1724
@@ -42,35 +49,27 @@ def _plot_colormap(vol, title, plot, save_path):
4249 plt .tight_layout ()
4350 if plot :
4451 plt .show ()
52+
4553 plt .savefig (save_path )
4654 plt .close ()
4755
4856
4957def fig_03a (save_path , plot , plot_napari ):
50- path = os .path .join (INPUT_ROOT , "frequencies_IHC_v4c.tif" )
51- vol = imageio .imread (path )
52- _plot_colormap (vol , title = "Tonotopic Mapping: IHCs" , plot = plot , save_path = save_path )
58+ path_ihc = os .path .join (INPUT_ROOT , "frequencies_IHC_v4c.tif" )
59+ path_sgn = os .path .join (INPUT_ROOT , "frequencies_SGN_v2.tif" )
60+ sgn = imageio .imread (path_sgn )
61+ ihc = imageio .imread (path_ihc )
62+ _plot_colormap (sgn , title = "Tonotopic Mapping" , plot = plot , save_path = save_path )
5363
5464 # Show the image in napari for rendering.
5565 if plot_napari :
5666 import napari
5767 v = napari .Viewer ()
58- v .add_image (vol , colormap = "viridis" )
68+ v .add_image (ihc , colormap = "viridis" )
69+ v .add_image (sgn , colormap = "viridis" )
5970 napari .run ()
6071
6172
62- def fig_03b (save_path , plot , plot_napari ):
63- path = os .path .join (INPUT_ROOT , "frequencies_SGN_v2.tif" )
64- vol = imageio .imread (path )
65- _plot_colormap (vol , title = "Tonotopic Mapping: SGNs" , plot = plot , save_path = save_path )
66-
67- # Show the image in napari for rendering.
68- if plot_napari :
69- import napari
70- v = napari .Viewer ()
71- v .add_image (vol , colormap = "viridis" )
72-
73-
7473def fig_03c_rl (save_path , plot = False ):
7574 tables = glob ("./ihc_counts/ihc_count_M_LR*.tsv" )
7675 fig , ax = plt .subplots (figsize = (8 , 4 ))
@@ -102,9 +101,9 @@ def fig_03c_rl(save_path, plot=False):
102101
103102
104103def fig_03c_octave (save_path , plot = False ):
105- # TODO update this table
106104 ihc_version = "ihc_counts_v4c"
107105 tables = glob (os .path .join (SYNAPSE_DIR_ROOT , ihc_version , "ihc_count_M_LR*.tsv" ))
106+ assert len (tables ) == 4
108107
109108 result = {"cochlea" : [], "octave_band" : [], "value" : []}
110109 for tab_path in tables :
@@ -114,7 +113,6 @@ def fig_03c_octave(save_path, plot=False):
114113 freq = tab ["frequency" ].values
115114 syn_count = tab ["synapse_count" ].values
116115
117- # Compute the running sum of 10 micron.
118116 octave_binned = frequency_mapping (freq , syn_count , animal = "mouse" )
119117
120118 result ["cochlea" ].extend ([alias ] * len (octave_binned ))
@@ -164,7 +162,11 @@ def fig_03d(save_path, plot, print_stats=True):
164162 vals = table [col ].values
165163 subtype = col [3 :]
166164 n_subtype = vals .sum ()
167- print (subtype , ":" , n_subtype , "/" , n_sgns , f"({ np .round (float (n_subtype ) / n_sgns * 100 , 2 )} %)" )
165+ channel = TYPE_TO_CHANNEL [subtype ]
166+ print (
167+ f"{ subtype } ({ channel } ):" , n_subtype , "/" , n_sgns ,
168+ f"({ np .round (float (n_subtype ) / n_sgns * 100 , 2 )} %)"
169+ )
168170
169171 coexpr = np .logical_and (subtype_table .iloc [:, 0 ].values , subtype_table .iloc [:, 1 ].values )
170172 print ("Co-expression:" , coexpr .sum ())
@@ -178,16 +180,13 @@ def main():
178180
179181 os .makedirs (args .figure_dir , exist_ok = True )
180182
181- # Panel A: Tonotopic mapping of IHCs (rendering in napari)
182- # fig_03a(save_path=os.path.join(args.figure_dir, "fig_03a.png"), plot=args.plot, plot_napari=False)
183-
184- # Panel B: Tonotopic mapping of SGNs (rendering in napari)
185- # fig_03b(save_path=os.path.join(args.figure_dir, "fig_03b.png"), plot=args.plot, plot_napari=False)
183+ # Panel A: Tonotopic mapping of SGNs and IHCs (rendering in napari + heatmap)
184+ # fig_03a(save_path=os.path.join(args.figure_dir, "fig_03a_cmap.png"), plot=args.plot, plot_napari=True)
186185
187186 # Panel C: Spatial distribution of synapses across the cochlea.
188187 # We have two options: running sum over the runlength or per octave band
189188 # fig_03c_rl(save_path=os.path.join(args.figure_dir, "fig_03c_runlength.png"), plot=args.plot)
190- # fig_03c_octave(save_path=os.path.join(args.figure_dir, "fig_03c_octave.png"), plot=args.plot)
189+ fig_03c_octave (save_path = os .path .join (args .figure_dir , "fig_03c_octave.png" ), plot = args .plot )
191190
192191 # Panel D: Spatial distribution of SGN sub-types.
193192 fig_03d (save_path = os .path .join (args .figure_dir , "fig_03d.png" ), plot = args .plot )
0 commit comments