Skip to content

Commit 99cd1ec

Browse files
committed
Update figures, cochleae: N98R, N152R
1 parent 3c5e046 commit 99cd1ec

File tree

11 files changed

+554
-94
lines changed

11 files changed

+554
-94
lines changed

flamingo_tools/segmentation/sgn_subtype_utils.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,12 @@
2222
"M_LR_000184_R": "M_10R",
2323
"M_LR_000260_L": "M_11L",
2424
"M_LR_000098_L": "M_12L",
25+
"M_LR_N98_R": "M_12R",
2526
"M_LR_N110_L": "M_13L",
2627
"M_LR_N110_R": "M_13R",
2728
"M_LR_N127_L": "M_14L",
2829
"M_LR_N152_L": "M_15L",
30+
"M_LR_N152_R": "M_15R",
2931
"M_LR_000099_L": "M_00L",
3032
"M_AMD_N180_L": "M_16L",
3133
"M_AMD_N180_R": "M_16R",
@@ -40,6 +42,7 @@
4042
"0929-0749-0290": {"manual": 2.78, "annotations": 2.78},
4143
"0956-0629-0576": {"manual": 3.36, "annotations": 3.36},
4244
}},
45+
"M_LR_N98_R": {"Ntng1": 2.2},
4346
"M_LR_000099_L": {"Lypd1": 0.65},
4447
"M_LR_000184_L": {"Prph": 1},
4548
"M_LR_000184_R": {"Prph": {

scripts/assign_subtypes.py

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -82,35 +82,39 @@ def filter_subtypes(cochlea, seg_name, subtype, stains=None):
8282

8383
def assign_subtypes(cochlea, output_folder, subtype_column="subtype_label"):
8484
if "label_stains" in COCHLEAE[cochlea].keys():
85-
for subtype_column, subtype_stains in COCHLEAE[cochlea]["label_stains"].items():
85+
subtype_assign_dic = COCHLEAE[cochlea]["label_stains"]
86+
else:
87+
subtype_assign_dic = {subtype_column: COCHLEAE[cochlea]["subtype_stains"]}
88+
89+
for subtype_column, subtype_stains in subtype_assign_dic.items():
8690

87-
subtype_stains.sort()
88-
if "output_seg" in list(COCHLEAE[cochlea].keys()):
89-
seg_name = COCHLEAE[cochlea]["output_seg"]
90-
else:
91-
seg_name = COCHLEAE[cochlea]["seg_data"]
91+
subtype_stains.sort()
92+
if "output_seg" in list(COCHLEAE[cochlea].keys()):
93+
seg_name = COCHLEAE[cochlea]["output_seg"]
94+
else:
95+
seg_name = COCHLEAE[cochlea]["seg_data"]
9296

93-
out_path = os.path.join(output_folder, f"{cochlea}_subtypes.tsv")
97+
out_path = os.path.join(output_folder, f"{cochlea}_subtypes.tsv")
9498

95-
table_seg_path = f"{cochlea}/tables/{seg_name}/default.tsv"
96-
table_path_s3, fs = get_s3_path(table_seg_path)
97-
with fs.open(table_path_s3, "r") as f:
98-
table = pd.read_csv(f, sep="\t")
99+
table_seg_path = f"{cochlea}/tables/{seg_name}/default.tsv"
100+
table_path_s3, fs = get_s3_path(table_seg_path)
101+
with fs.open(table_path_s3, "r") as f:
102+
table = pd.read_csv(f, sep="\t")
99103

100-
print(f"Subtype stains: {subtype_stains}.")
101-
subtypes = types_for_stain(subtype_stains)
102-
subtypes.sort()
104+
print(f"Subtype stains: {subtype_stains}.")
105+
subtypes = types_for_stain(subtype_stains)
106+
subtypes.sort()
103107

104-
# Subtype labels
105-
subtype_labels = ["None" for _ in range(len(table))]
106-
table[subtype_column] = subtype_labels
107-
for subtype in subtypes:
108+
# Subtype labels
109+
subtype_labels = ["None" for _ in range(len(table))]
110+
table[subtype_column] = subtype_labels
111+
for subtype in subtypes:
108112

109-
label_ids_subtype = filter_subtypes(cochlea, seg_name=seg_name, subtype=subtype, stains=subtype_stains)
110-
print(f"Subtype '{subtype}' with {len(label_ids_subtype)} instances.")
111-
table.loc[table["label_id"].isin(label_ids_subtype), subtype_column] = subtype
113+
label_ids_subtype = filter_subtypes(cochlea, seg_name=seg_name, subtype=subtype, stains=subtype_stains)
114+
print(f"Subtype '{subtype}' with {len(label_ids_subtype)} instances.")
115+
table.loc[table["label_id"].isin(label_ids_subtype), subtype_column] = subtype
112116

113-
table.to_csv(out_path, sep="\t", index=False)
117+
table.to_csv(out_path, sep="\t", index=False)
114118

115119

116120
def main():
Lines changed: 201 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
1+
apicalDistToApex apicalRibbons_Cell YuRibPct YuRib1 YuRib2 X__from_Apex Ribbons_Cell
2+
322 10.5 96.129 9.8 7 1 7.17
3+
843 15.09 92.2581 10 1.25878 9
4+
2108 16 88.3871 10.8 9.3 1.7752 8
5+
196 10.5 84.5161 10.4 1.83975 6.54
6+
1707 15.58 80.6452 10.6 12 2.03341 7.08
7+
589 11.09 76.7742 13.6 2.1141 9.5
8+
300 11.23 72.9032 14.4 3 8.67
9+
627 11.1 69.0323 18 2.43686 7.88
10+
657 11.7 65.1613 17.6 2.453
11+
1379 15.6 61.2903 17.25 2 9.43
12+
581 11.31 57.4194 17.14 2.82417 9.67
13+
1594 53.5484 21.2 16 2.95328 10.3
14+
282 49.6774 19 15.6 2 10.5
15+
709 45.8065 20.03 18.4 3.16308 10.5
16+
1170 41.9355 19.3 17.25 3.22763
17+
267 9.31 38.0645 19.6 16.5 3.51812 7.83
18+
1194 16.23 34.1935 15 3 11.33
19+
2430 14.4 30.3226 13.4 18 3.6795 6.75
20+
817 26.4516 13.8 17.6 4.03454 10.46
21+
500 9.75 22.5806 14.4 12.4 4.30888 9.31
22+
929 12.36 18.7097 11.8 4.55096
23+
1238 11.79 14.8387 10 12 4.84144 11.23
24+
1821 15.33 10.9677 8 12.6 5.19648 10.5
25+
152 7.09677 9.6 5.2449 7.36364
26+
78 9 3.22581 9 7.4 5 9.86
27+
454 9.1 6.03567 10.17
28+
2415 11.73 6 9.67
29+
131 9.5 6.66505 12.67
30+
876 10.56 8 11.86
31+
1386 12.73 7.32672 9.1
32+
1767 12.83 8.06907 9.75
33+
2763 12.58 8.74687 9
34+
175 9.67 8.8437 11.18
35+
1464 13.23 8.90825
36+
126 7.08 9.08577 10.8
37+
542 9 9 13.8
38+
1024 9.37626 11.31
39+
1524 12.27 9.42468 11.9
40+
228 6.75 9.50537 11.09
41+
548 11.18 10.1186 11.1
42+
552 10.6028 11.7
43+
1053 10 11.25
44+
814 11.3774 11.6667
45+
218 7.83 11.4419
46+
413 12.67 12.152 13.92
47+
920 13.08 11 12.5
48+
1509 15.88 12.2004 12.2
49+
374 10.17 12 12.83
50+
753 13.92 13.1364
51+
1464 15.6 13.1849
52+
250 10.46 13.6045 15.09
53+
855 13.33 13.7981 13.33
54+
2030 17.85 14.137 10.56
55+
17 12.71
56+
114 6.54 14.8471 13.08
57+
756 12.2 14.9923 12.36
58+
1340 13.27 16.477 15.2
59+
151 7.88 16.5255
60+
584 11.9 16.7191 11.625
61+
1235 12.5 16.9935
62+
1586 15.23 17.2355 13.8
63+
2305 15.92 17 16.57
64+
2766 15.91 18.8332 12.08
65+
200 18.8816
66+
1021 15.2 19.2689 16.23
67+
1998 18 13.11
68+
2648 15.73 19.9306 12.5
69+
183 10.3 19.979 11.79
70+
563 10.8 20.8989 15.625
71+
1167 12.08 21.6251 13.27
72+
1068 13.8 22.2545 15.6
73+
1892 16.45 28 15.13
74+
110 8 22.3675 12.73
75+
325 7.36364 22 14.88
76+
705 11.6667 22 15.14
77+
1036 11.625 23.6262 13.23
78+
1295 15.625 23.6262 15.6
79+
1732 16.5714 23 16.67
80+
24.3525 15.88
81+
24.5945 12.27
82+
25.5951 15.23
83+
25.7242
84+
27.5478 15.58
85+
27.9513 16.5714
86+
35 19.6
87+
28.5161 12.83
88+
27 15.25
89+
29.3876 15.33
90+
30.5334 16.45
91+
30 17.43
92+
30 16.33
93+
30 17.83
94+
39 16.33
95+
32.244
96+
32.7604 17.85
97+
34.0192 16
98+
33 17
99+
44 16.43
100+
37.1984 15.92
101+
37 16.5
102+
47 14.33
103+
38 18.83
104+
38.9736 11.73
105+
39.2157 14.4
106+
37 13.71
107+
39 18
108+
53 15.83
109+
42.7338 15.73
110+
44.5897 12.58
111+
44.6381 15.91
112+
44 18
113+
45 15.33
114+
48 16.4
115+
48
116+
47 16.63
117+
51 11.86
118+
66 13
119+
52 14.71
120+
79 13
121+
82 13
122+
85 11.67
123+
67 15
124+
90 10
125+
71 14.14
126+
92 8.6
127+
95 6
128+
75 14.86
129+
82 9.25
130+
82 12.14
131+
86 10.63
132+
94 7.2
133+
134+
135+
136+
137+
138+
139+
140+
141+
142+
143+
144+
145+
146+
147+
148+
149+
150+
151+
152+
153+
154+
155+
156+
157+
158+
159+
160+
161+
162+
163+
164+
165+
166+
167+
168+
169+
170+
171+
172+
173+
174+
175+
176+
177+
178+
179+
180+
181+
182+
183+
184+
185+
186+
187+
188+
189+
190+
191+
192+
193+
194+
195+
196+
197+
198+
199+
200+
201+

scripts/figures/plot_fig2.py

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def supp_fig_02(save_path, plot=False, segm="SGN", mode="precision"):
4747
"precision": 0.706,
4848
"recall": 0.630,
4949
"f1-score": 0.628,
50-
"marker": "o",
50+
"marker": "*",
5151
"runtime": 536.5,
5252
"runtime_std": 148.4
5353
},
@@ -83,7 +83,7 @@ def supp_fig_02(save_path, plot=False, segm="SGN", mode="precision"):
8383
"precision": 0.373,
8484
"recall": 0.340,
8585
"f1-score": 0.326,
86-
"marker": "*",
86+
"marker": "o",
8787
"runtime": None,
8888
"runtime_std": None,
8989
},
@@ -141,14 +141,16 @@ def supp_fig_02(save_path, plot=False, segm="SGN", mode="precision"):
141141
offset = 0.08 # horizontal shift for scatter separation
142142

143143
# Plot
144-
fig, ax = plt.subplots(figsize=(8, 5))
144+
tick_rotation = 0
145145

146146
main_label_size = 20
147147
main_tick_size = 16
148+
marker_size = 200
148149

149150
labels = [value_dict[segm][key]["label"] for key in value_dict[segm].keys()]
150151

151152
if mode == "precision":
153+
fig, ax = plt.subplots(figsize=(10, 5))
152154
# Convert setting labels to numerical x positions
153155
offset = 0.08 # horizontal shift for scatter separation
154156
for num, key in enumerate(list(value_dict[segm].keys())):
@@ -158,20 +160,24 @@ def supp_fig_02(save_path, plot=False, segm="SGN", mode="precision"):
158160
marker = value_dict[segm][key]["marker"]
159161
x_pos = num + 1
160162

161-
plt.scatter([x_pos - offset], precision, label="Precision manual", color=COLOR_P, marker=marker, s=80)
162-
plt.scatter([x_pos], recall, label="Recall manual", color=COLOR_R, marker=marker, s=80)
163-
plt.scatter([x_pos + offset], f1score, label="F1-score manual", color=COLOR_F, marker=marker, s=80)
163+
plt.scatter([x_pos - offset], precision, label="Precision manual",
164+
color=COLOR_P, marker=marker, s=marker_size)
165+
plt.scatter([x_pos], recall, label="Recall manual",
166+
color=COLOR_R, marker=marker, s=marker_size)
167+
plt.scatter([x_pos + offset], f1score, label="F1-score manual",
168+
color=COLOR_F, marker=marker, s=marker_size)
164169

165170
# Labels and formatting
166171
x_pos = np.arange(1, len(labels)+1)
167-
plt.xticks(x_pos, labels, fontsize=main_tick_size)
172+
plt.xticks(x_pos, labels, fontsize=main_tick_size, rotation=tick_rotation)
168173
plt.yticks(fontsize=main_tick_size)
169174
plt.ylabel("Value", fontsize=main_label_size)
170175
plt.ylim(-0.1, 1)
171176
# plt.legend(loc="lower right", fontsize=legendsize)
172177
plt.grid(axis="y", linestyle="solid", alpha=0.5)
173178

174179
elif mode == "runtime":
180+
fig, ax = plt.subplots(figsize=(8.5, 5))
175181
if "Spiner" in labels:
176182
labels.remove("Spiner")
177183

@@ -183,19 +189,22 @@ def supp_fig_02(save_path, plot=False, segm="SGN", mode="precision"):
183189
if runtime[0] is None:
184190
continue
185191
marker = value_dict[segm][key]["marker"]
186-
plt.scatter([x_pos], runtime, label="Runtime", color=COLOR_T, marker=marker, s=80)
192+
plt.scatter([x_pos], runtime, label="Runtime", color=COLOR_T, marker=marker, s=marker_size)
187193
x_pos = x_pos + 1
188194

189195
# Labels and formatting
190196
x_pos = np.arange(1, len(labels)+1)
191-
plt.xticks(x_pos, labels, fontsize=16)
197+
plt.xticks(x_pos, labels, fontsize=16, rotation=tick_rotation)
192198
plt.yticks(fontsize=main_tick_size)
193199
plt.ylabel("Processing time [s]", fontsize=main_label_size)
194-
plt.ylim(10, 2400)
200+
plt.ylim(10, 2600)
195201
plt.yscale('log')
196202
# plt.legend(loc="lower right", fontsize=legendsize)
197203
plt.grid(axis="y", linestyle="solid", alpha=0.5)
198204

205+
else:
206+
raise ValueError("Unsupported mode for plotting.")
207+
199208
plt.tight_layout()
200209
prism_cleanup_axes(ax)
201210

0 commit comments

Comments
 (0)