-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbar_plots_per_method.py
377 lines (317 loc) · 11.7 KB
/
bar_plots_per_method.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Mar 24 13:38:42 2021
@author: genevieve.hayes
Bar plots per method
"""
import numpy as np
import matplotlib.pyplot as plt
import matplotlib
SAVEIMG = 1
# In[]: WATERSHED
width = 0.7
matplotlib.rcParams['font.family'] = 'serif'
matplotlib.rcParams['font.serif'] = ['Times New Roman'] + plt.rcParams['font.serif']
matplotlib.rc('text', usetex='false')
matplotlib.rcParams.update({'font.size': 29})
fig = matplotlib.pyplot.gcf()
fig.set_size_inches(5.5, 9.5)
# #Sample 6B
# B_kngp_w = 2516.0
# B_kpgp_w = 3509.0
# B_kpgn_w = 80.0
# B_kngn_w = 1048
#File:Sample6B.tiff
B_kngp_w = 2552.0
B_kpgp_w = 2619.0
B_kpgn_w = 40.0
B_kngn_w = 1141.0
xB_w = np.array(["6B"])
yB_w = np.array([B_kngp_w,B_kngn_w,B_kpgp_w,B_kpgn_w])
p1B_w = plt.bar(xB_w, yB_w[0], width, color='g')
p2B_w = plt.bar(xB_w, yB_w[1], width, bottom=yB_w[0], color='c')
p3B_w = plt.bar(xB_w, yB_w[2], width, bottom=yB_w[0]+yB_w[1], color='r')
p4B_w = plt.bar(xB_w, yB_w[3], width, bottom=yB_w[0]+yB_w[1]+yB_w[2], color='b')
# #Sample 6D
# D_kngp_w = 2765.0
# D_kpgp_w = 1137.0
# D_kpgn_w = 9.0
# D_kngn_w = 2485.0
#File:Sample6D.tiff
D_kngp_w = 2655.0
D_kpgp_w = 218.0
D_kpgn_w = 2.0
D_kngn_w = 798.0
xD_w = np.array(["6D"])
yD_w = np.array([D_kngp_w,D_kngn_w,D_kpgp_w,D_kpgn_w])
p1D_w = plt.bar(xD_w, yD_w[0], width, color='g')
p2D_w = plt.bar(xD_w, yD_w[1], width, bottom=yD_w[0], color='c')
p3D_w = plt.bar(xD_w, yD_w[2], width, bottom=yD_w[0]+yD_w[1], color='r')
p4D_w = plt.bar(xD_w, yD_w[3], width, bottom=yD_w[0]+yD_w[1]+yD_w[2], color='b')
# #Sample 6G
# G_kngp_w = 503.0
# G_kpgp_w = 5507.0
# G_kpgn_w = 1.0
# G_kngn_w = 441.0
#File:Sample6G.tiff
G_kngp_w = 973.0
G_kpgp_w = 4916.0
G_kpgn_w = 1.0
G_kngn_w = 606.0
xG_w = np.array(["6G"])
yG_w = np.array([G_kngp_w,G_kngn_w,G_kpgp_w,G_kpgn_w])
p1G_w = plt.bar(xG_w, yG_w[0], width, color='g')
p2G_w = plt.bar(xG_w, yG_w[1], width, bottom=yG_w[0], color='c')
p3G_w = plt.bar(xG_w, yG_w[2], width, bottom=yG_w[0]+yG_w[1], color='r')
p4G_w = plt.bar(xG_w, yG_w[3], width, bottom=yG_w[0]+yG_w[1]+yG_w[2], color='b')
plt.ylabel("Number of Cells Identified", fontsize=30)
#plt.legend((p1B_w[0], p2B_w[0], p3B_w[0], p4B_w[0]), ('KRT5-/GATA3+', 'KRT5-/GATA3-', 'KRT5+/GATA3+', 'KRT5+/GATA3-'), fontsize=10, ncol=1, framealpha=0, fancybox=True,bbox_to_anchor=(1.04,1.04))
plt.title("Watershed Method",fontsize=25)
plt.ylim([0,9000])
plt.tight_layout()
if SAVEIMG == 1:
filename_output = "bar_plots_per_method/bar_plot_watershed.tiff"
plt.savefig(filename_output)
plt.show()
print('\n---- WATERSHED METHOD ----')
print('-----------------------------')
print('\n---- Sample 6B ----')
print('\nKRT5-/GATA3+:', B_kngp_w)
print('KRT5+/GATA3+:', B_kpgp_w)
print('KRT5+/GATA3-:', B_kpgn_w)
print('KRT5-/GATA3-:', B_kngn_w)
print('\n---- Sample 6D ----')
print('\nKRT5-/GATA3+:', D_kngp_w)
print('KRT5+/GATA3+:', D_kpgp_w)
print('KRT5+/GATA3-:', D_kpgn_w)
print('KRT5-/GATA3-:', D_kngn_w)
print('\n---- Sample 6G ----')
print('\nKRT5-/GATA3+:', G_kngp_w)
print('KRT5+/GATA3+:', G_kpgp_w)
print('KRT5+/GATA3-:', G_kpgn_w)
print('KRT5-/GATA3-:', G_kngn_w)
# In[]: TEMPLATE MATCHING
width = 0.7
matplotlib.rcParams['font.family'] = 'serif'
matplotlib.rcParams['font.serif'] = ['Times New Roman'] + plt.rcParams['font.serif']
matplotlib.rc('text', usetex='false')
matplotlib.rcParams.update({'font.size': 29})
fig = matplotlib.pyplot.gcf()
fig.set_size_inches(5.5, 9.5)
#Sample 6B
B_kngp_tm = 1276.0
B_kpgp_tm = 1529.0
B_kpgn_tm = 0.0
B_kngn_tm = 246.0
xB_tm = np.array(["6B"])
yB_tm = np.array([B_kngp_tm,B_kngn_tm,B_kpgp_tm,B_kpgn_tm])
p1B_tm = plt.bar(xB_tm, yB_tm[0], width, color='g')
p2B_tm = plt.bar(xB_tm, yB_tm[1], width, bottom=yB_tm[0], color='c')
p3B_tm = plt.bar(xB_tm, yB_tm[2], width, bottom=yB_tm[0]+yB_tm[1], color='r')
p4B_tm = plt.bar(xB_tm, yB_tm[3], width, bottom=yB_tm[0]+yB_tm[1]+yB_tm[2], color='b')
#Sample 6D
D_kngp_tm = 1382.0
D_kpgp_tm = 445.0
D_kpgn_tm = 1.0
D_kngn_tm = 897.0
xD_tm = np.array(["6D"])
yD_tm = np.array([D_kngp_tm,D_kngn_tm,D_kpgp_tm,D_kpgn_tm])
p1D_tm = plt.bar(xD_tm, yD_tm[0], width, color='g')
p2D_tm = plt.bar(xD_tm, yD_tm[1], width, bottom=yD_tm[0], color='c')
p3D_tm = plt.bar(xD_tm, yD_tm[2], width, bottom=yD_tm[0]+yD_tm[1], color='r')
p4D_tm = plt.bar(xD_tm, yD_tm[3], width, bottom=yD_tm[0]+yD_tm[1]+yD_tm[2], color='b')
#Sample 6G
G_kngp_tm = 756.0
G_kpgp_tm = 2816.0
G_kpgn_tm = 0.0
G_kngn_tm = 138.0
xG_tm = np.array(["6G"])
yG_tm = np.array([G_kngp_tm,G_kngn_tm,G_kpgp_tm,G_kpgn_tm])
p1G_tm = plt.bar(xG_tm, yG_tm[0], width, color='g')
p2G_tm = plt.bar(xG_tm, yG_tm[1], width, bottom=yG_tm[0], color='c')
p3G_tm = plt.bar(xG_tm, yG_tm[2], width, bottom=yG_tm[0]+yG_tm[1], color='r')
p4G_tm = plt.bar(xG_tm, yG_tm[3], width, bottom=yG_tm[0]+yG_tm[1]+yG_tm[2], color='b')
#plt.ylabel("Number of Cells Identified")
#plt.legend((p1B_tm[0], p2B_tm[0], p3B_tm[0], p4B_tm[0]), ('KRT5-/GATA3+', 'KRT5-/GATA3-', 'KRT5+/GATA3+', 'KRT5+/GATA3-'), fontsize=10, ncol=1, framealpha=0, fancybox=True,bbox_to_anchor=(1.04,1))
plt.title("Template Matching Method",fontsize=25)
plt.ylim([0,9000])
plt.tight_layout()
if SAVEIMG == 1:
filename_output = "bar_plots_per_method/bar_plot_templatematching.tiff"
plt.savefig(filename_output)
plt.show()
print('\n---- TEMPLATE MATCHING METHOD ----')
print('-------------------------------------')
print('\n---- Sample 6B ----')
print('\nKRT5-/GATA3+:', B_kngp_tm)
print('KRT5+/GATA3+:', B_kpgp_tm)
print('KRT5+/GATA3-:', B_kpgn_tm)
print('KRT5-/GATA3-:', B_kngn_tm)
print('\n---- Sample 6D ----')
print('\nKRT5-/GATA3+:', D_kngp_tm)
print('KRT5+/GATA3+:', D_kpgp_tm)
print('KRT5+/GATA3-:', D_kpgn_tm)
print('KRT5-/GATA3-:', D_kngn_tm)
print('\n---- Sample 6G ----')
print('\nKRT5-/GATA3+:', G_kngp_tm)
print('KRT5+/GATA3+:', G_kpgp_tm)
print('KRT5+/GATA3-:', G_kpgn_tm)
print('KRT5-/GATA3-:', G_kngn_tm)
# In[]: COMBINED
width = 0.7
matplotlib.rcParams['font.family'] = 'serif'
matplotlib.rcParams['font.serif'] = ['Times New Roman'] + plt.rcParams['font.serif']
matplotlib.rc('text', usetex='false')
matplotlib.rcParams.update({'font.size': 29})
fig = matplotlib.pyplot.gcf()
fig.set_size_inches(5.5, 9.5)
# #Sample 6B
# B_kngp_c = 1276.0
# B_kpgp_c = 3627.0
# B_kpgn_c = 80.0
# B_kngn_c = 246.0
#File:Sample6B.tiff
B_kngp_c = 1343.0
B_kpgp_c = 2683.0
B_kpgn_c = 40.0
B_kngn_c = 273.0
xB_c = np.array(["6B"])
yB_c = np.array([B_kngp_c,B_kngn_c,B_kpgp_c,B_kpgn_c])
p1B_c = plt.bar(xB_c, yB_c[0], width, color='g')
p2B_c = plt.bar(xB_c, yB_c[1], width, bottom=yB_c[0], color='c')
p3B_c = plt.bar(xB_c, yB_c[2], width, bottom=yB_c[0]+yB_c[1], color='r')
p4B_c = plt.bar(xB_c, yB_c[3], width, bottom=yB_c[0]+yB_c[1]+yB_c[2], color='b')
# #Sample 6D
# D_kngp_c = 1382.0
# D_kpgp_c = 1153.0
# D_kpgn_c = 9.0
# D_kngn_c = 897.0
#File:Sample6D.tiff
D_kngp_c = 1415.0
D_kpgp_c = 220.0
D_kpgn_c = 2.0
D_kngn_c = 917.0
xD_c = np.array(["6D"])
yD_c = np.array([D_kngp_c,D_kngn_c,D_kpgp_c,D_kpgn_c])
p1D_c = plt.bar(xD_c, yD_c[0], width, color='g')
p2D_c = plt.bar(xD_c, yD_c[1], width, bottom=yD_c[0], color='c')
p3D_c = plt.bar(xD_c, yD_c[2], width, bottom=yD_c[0]+yD_c[1], color='r')
p4D_c = plt.bar(xD_c, yD_c[3], width, bottom=yD_c[0]+yD_c[1]+yD_c[2], color='b')
# #Sample 6G
# G_kngp_c = 756.0
# G_kpgp_c = 5508.0
# G_kpgn_c = 1.0
# G_kngn_c = 138.0
#File:Sample6G.tiff
G_kngp_c = 910.0
G_kpgp_c = 4917.0
G_kpgn_c = 1.0
G_kngn_c = 145.0
xG_c = np.array(["6G"])
yG_c = np.array([G_kngp_c,G_kngn_c,G_kpgp_c,G_kpgn_c])
p1G_c = plt.bar(xG_c, yG_c[0], width, color='g')
p2G_c = plt.bar(xG_c, yG_c[1], width, bottom=yG_c[0], color='c')
p3G_c = plt.bar(xG_c, yG_c[2], width, bottom=yG_c[0]+yG_c[1], color='r')
p4G_c = plt.bar(xG_c, yG_c[3], width, bottom=yG_c[0]+yG_c[1]+yG_c[2], color='b')
#plt.ylabel("Number of Cells Identified")
#plt.legend((p1G_c[0], p2G_c[0], p3G_c[0], p4G_c[0]), ('KRT5-/GATA3+', 'KRT5-/GATA3-', 'KRT5+/GATA3+', 'KRT5+/GATA3-'), fontsize=10, ncol=1, framealpha=0, fancybox=True,bbox_to_anchor=(1.04,1))
plt.ylim([0,9000])
plt.title("Combined Method",fontsize=25)
plt.tight_layout()
if SAVEIMG == 1:
filename_output = "bar_plots_per_method/bar_plot_combined.tiff"
plt.savefig(filename_output)
plt.show()
print('\n---- COMBINED METHOD ----')
print('---------------------------')
print('\n---- Sample 6B ----')
print('\nKRT5-/GATA3+:', B_kngp_c)
print('KRT5+/GATA3+:', B_kpgp_c)
print('KRT5+/GATA3-:', B_kpgn_c)
print('KRT5-/GATA3-:', B_kngn_c)
print('\n---- Sample 6D ----')
print('\nKRT5-/GATA3+:', D_kngp_c)
print('KRT5+/GATA3+:', D_kpgp_c)
print('KRT5+/GATA3-:', D_kpgn_c)
print('KRT5-/GATA3-:', D_kngn_c)
print('\n---- Sample 6G ----')
print('\nKRT5-/GATA3+:', G_kngp_c)
print('KRT5+/GATA3+:', G_kpgp_c)
print('KRT5+/GATA3-:', G_kpgn_c)
print('KRT5-/GATA3-:', G_kngn_c)
# In[]: HALO
# Stain 1 is green
# Stain 2 is red
width = 0.7
matplotlib.rcParams['font.family'] = 'serif'
matplotlib.rcParams['font.serif'] = ['Times New Roman'] + plt.rcParams['font.serif']
matplotlib.rc('text', usetex='false')
matplotlib.rcParams.update({'font.size': 29})
fig = matplotlib.pyplot.gcf()
fig.set_size_inches(5.5, 9.5)
#Sample 6B
Btot_stain1_h = 7087
Btot_stain2_h = 3918
B_kpgp_h = 3439 #Dual positive cells
B_kngn_h = 747 #Dual negative cells
B_kngp_h = Btot_stain1_h - B_kpgp_h
B_kpgn_h = Btot_stain2_h - B_kpgp_h
xB_h = np.array(["6B"])
yB_h = np.array([B_kngp_h,B_kngn_h,B_kpgp_h,B_kpgn_h])
p1B_h = plt.bar(xB_h, yB_h[0], width, color='g')
p2B_h = plt.bar(xB_h, yB_h[1], width, bottom=yB_h[0], color='c')
p3B_h = plt.bar(xB_h, yB_h[2], width, bottom=yB_h[0]+yB_h[1], color='r')
p4B_h = plt.bar(xB_h, yB_h[3], width, bottom=yB_h[0]+yB_h[1]+yB_h[2], color='b')
#Sample 6D
Dtot_stain1_h = 4570
Dtot_stain2_h = 387
D_kpgp_h = 284
D_kngn_h = 1894
D_kngp_h = Dtot_stain1_h - D_kpgp_h
D_kpgn_h = Dtot_stain2_h - D_kpgp_h
xD_h = np.array(["6D"])
yD_h = np.array([D_kngp_h,D_kngn_h,D_kpgp_h,D_kpgn_h])
p1D_h = plt.bar(xD_h, yD_h[0], width, color='g')
p2D_h = plt.bar(xD_h, yD_h[1], width, bottom=yD_h[0], color='c')
p3D_h = plt.bar(xD_h, yD_h[2], width, bottom=yD_h[0]+yD_h[1], color='r')
p4D_h = plt.bar(xD_h, yD_h[3], width, bottom=yD_h[0]+yD_h[1]+yD_h[2], color='b')
#Sample 6G
Gtot_stain1_h = 6819
Gtot_stain2_h = 5800
G_kpgp_h = 5400
G_kngn_h = 340
G_kngp_h = Gtot_stain1_h - G_kpgp_h
G_kpgn_h = Gtot_stain2_h - G_kpgp_h
xG_h = np.array(["6G"])
yG_h = np.array([G_kngp_h,G_kngn_h,G_kpgp_h,G_kpgn_h])
p1G_h = plt.bar(xG_h, yG_h[0], width, color='g')
p2G_h = plt.bar(xG_h, yG_h[1], width, bottom=yG_h[0], color='c')
p3G_h = plt.bar(xG_h, yG_h[2], width, bottom=yG_h[0]+yG_h[1], color='r')
p4G_h = plt.bar(xG_h, yG_h[3], width, bottom=yG_h[0]+yG_h[1]+yG_h[2], color='b')
#plt.ylabel("Number of Cells Identified")
#plt.legend((p1G_h[0], p2G_h[0], p3G_h[0], p4G_h[0]), ('KRT5-/GATA3+', 'KRT5-/GATA3-', 'KRT5+/GATA3+', 'KRT5+/GATA3-'), fontsize=15, ncol=1, framealpha=0, fancybox=True,bbox_to_anchor=(1.04,1))
plt.ylim([0,9000])
plt.title("HALO Analysis",fontsize=25)
plt.tight_layout()
if SAVEIMG == 1:
filename_output = "bar_plots_per_method/bar_plot_HALO.tiff"
plt.savefig(filename_output)
plt.show()
print('\n---- HALO METHOD ----')
print('-----------------------')
print('\n---- Sample 6B ----')
print('\nKRT5-/GATA3+:', B_kngp_h)
print('KRT5+/GATA3+:', B_kpgp_h)
print('KRT5+/GATA3-:', B_kpgn_h)
print('KRT5-/GATA3-:', B_kngn_h)
print('\n---- Sample 6D ----')
print('\nKRT5-/GATA3+:', D_kngp_h)
print('KRT5+/GATA3+:', D_kpgp_h)
print('KRT5+/GATA3-:', D_kpgn_h)
print('KRT5-/GATA3-:', D_kngn_h)
print('\n---- Sample 6G ----')
print('\nKRT5-/GATA3+:', G_kngp_h)
print('KRT5+/GATA3+:', G_kpgp_h)
print('KRT5+/GATA3-:', G_kpgn_h)
print('KRT5-/GATA3-:', G_kngn_h)