-
Notifications
You must be signed in to change notification settings - Fork 3
/
cpa.py
639 lines (626 loc) · 32.3 KB
/
cpa.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
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Helper functions for analysis of the Cell Painting Assay data.
"""
from typing import Iterable
# import sys
# import pandas as pd
from pandas import DataFrame
import numpy as np
import scipy.spatial.distance as dist
ACT_PROF_PARAMETERS = [
"Median_Cells_AreaShape_Area",
"Median_Cells_AreaShape_MaximumRadius",
"Median_Cells_AreaShape_MeanRadius",
"Median_Cells_AreaShape_MinFeretDiameter",
"Median_Cells_AreaShape_MinorAxisLength",
"Median_Cells_AreaShape_Perimeter",
"Median_Cells_Correlation_Correlation_ER_Ph_golgi",
"Median_Cells_Correlation_Correlation_ER_Syto",
"Median_Cells_Correlation_Correlation_Hoechst_ER",
"Median_Cells_Correlation_Correlation_Hoechst_Mito",
"Median_Cells_Correlation_Correlation_Hoechst_Ph_golgi",
"Median_Cells_Correlation_Correlation_Hoechst_Syto",
"Median_Cells_Correlation_Correlation_Mito_ER",
"Median_Cells_Correlation_Correlation_Mito_Ph_golgi",
"Median_Cells_Correlation_Correlation_Mito_Syto",
"Median_Cells_Correlation_Correlation_Syto_Ph_golgi",
"Median_Cells_Correlation_K_ER_Syto",
"Median_Cells_Correlation_K_Hoechst_Syto",
"Median_Cells_Correlation_K_Mito_Hoechst",
"Median_Cells_Correlation_K_Ph_golgi_Syto",
"Median_Cells_Correlation_K_Syto_ER",
"Median_Cells_Correlation_K_Syto_Hoechst",
"Median_Cells_Correlation_K_Syto_Ph_golgi",
"Median_Cells_Correlation_Manders_ER_Hoechst",
"Median_Cells_Correlation_Manders_ER_Syto",
"Median_Cells_Correlation_Manders_Mito_Hoechst",
"Median_Cells_Correlation_Manders_Ph_golgi_Hoechst",
"Median_Cells_Correlation_Manders_Syto_Hoechst",
"Median_Cells_Correlation_Overlap_Hoechst_ER",
"Median_Cells_Correlation_Overlap_Hoechst_Mito",
"Median_Cells_Correlation_Overlap_Hoechst_Ph_golgi",
"Median_Cells_Correlation_Overlap_Hoechst_Syto",
"Median_Cells_Correlation_Overlap_Mito_ER",
"Median_Cells_Correlation_Overlap_Mito_Ph_golgi",
"Median_Cells_Correlation_Overlap_Mito_Syto",
"Median_Cells_Correlation_Overlap_Syto_Ph_golgi",
"Median_Cells_Correlation_RWC_ER_Mito",
"Median_Cells_Correlation_RWC_Hoechst_ER",
"Median_Cells_Correlation_RWC_Hoechst_Mito",
"Median_Cells_Correlation_RWC_Hoechst_Ph_golgi",
"Median_Cells_Correlation_RWC_Hoechst_Syto",
"Median_Cells_Correlation_RWC_Mito_Hoechst",
"Median_Cells_Correlation_RWC_Mito_Syto",
"Median_Cells_Correlation_RWC_Ph_golgi_Hoechst",
"Median_Cells_Correlation_RWC_Ph_golgi_Mito",
"Median_Cells_Correlation_RWC_Ph_golgi_Syto",
"Median_Cells_Correlation_RWC_Syto_Hoechst",
"Median_Cells_Correlation_RWC_Syto_Mito",
"Median_Cells_Granularity_1_Mito",
"Median_Cells_Granularity_1_Ph_golgi",
"Median_Cells_Granularity_1_Syto",
"Median_Cells_Granularity_2_Mito",
"Median_Cells_Granularity_2_Ph_golgi",
"Median_Cells_Granularity_2_Syto",
"Median_Cells_Granularity_3_ER",
"Median_Cells_Granularity_3_Mito",
"Median_Cells_Granularity_3_Ph_golgi",
"Median_Cells_Granularity_3_Syto",
"Median_Cells_Granularity_4_Mito",
"Median_Cells_Granularity_5_Mito",
"Median_Cells_Intensity_IntegratedIntensityEdge_Hoechst",
"Median_Cells_Intensity_IntegratedIntensity_Syto",
"Median_Cells_Intensity_LowerQuartileIntensity_Mito",
"Median_Cells_Intensity_MADIntensity_ER",
"Median_Cells_Intensity_MADIntensity_Hoechst",
"Median_Cells_Intensity_MADIntensity_Mito",
"Median_Cells_Intensity_MADIntensity_Ph_golgi",
"Median_Cells_Intensity_MADIntensity_Syto",
"Median_Cells_Intensity_MaxIntensityEdge_Mito",
"Median_Cells_Intensity_MaxIntensityEdge_Syto",
"Median_Cells_Intensity_MaxIntensity_Hoechst",
"Median_Cells_Intensity_MaxIntensity_Mito",
"Median_Cells_Intensity_MaxIntensity_Ph_golgi",
"Median_Cells_Intensity_MeanIntensityEdge_Hoechst",
"Median_Cells_Intensity_MeanIntensity_Hoechst",
"Median_Cells_Intensity_MeanIntensity_Mito",
"Median_Cells_Intensity_MeanIntensity_Syto",
"Median_Cells_Intensity_MedianIntensity_ER",
"Median_Cells_Intensity_MedianIntensity_Mito",
"Median_Cells_Intensity_MedianIntensity_Syto",
"Median_Cells_Intensity_MinIntensityEdge_Mito",
"Median_Cells_Intensity_MinIntensityEdge_Syto",
"Median_Cells_Intensity_MinIntensity_Mito",
"Median_Cells_Intensity_MinIntensity_Syto",
"Median_Cells_Intensity_StdIntensityEdge_ER",
"Median_Cells_Intensity_StdIntensityEdge_Mito",
"Median_Cells_Intensity_StdIntensityEdge_Syto",
"Median_Cells_Intensity_StdIntensity_Hoechst",
"Median_Cells_Intensity_StdIntensity_Mito",
"Median_Cells_Intensity_StdIntensity_Ph_golgi",
"Median_Cells_Intensity_StdIntensity_Syto",
"Median_Cells_Intensity_UpperQuartileIntensity_Hoechst",
"Median_Cells_Intensity_UpperQuartileIntensity_Mito",
"Median_Cells_Intensity_UpperQuartileIntensity_Syto",
"Median_Cells_RadialDistribution_FracAtD_Mito_3of4",
"Median_Cells_RadialDistribution_FracAtD_Mito_4of4",
"Median_Cells_RadialDistribution_FracAtD_Ph_golgi_1of4",
"Median_Cells_RadialDistribution_FracAtD_Ph_golgi_2of4",
"Median_Cells_RadialDistribution_FracAtD_Ph_golgi_4of4",
"Median_Cells_RadialDistribution_MeanFrac_Mito_1of4",
"Median_Cells_RadialDistribution_MeanFrac_Mito_2of4",
"Median_Cells_RadialDistribution_MeanFrac_Mito_3of4",
"Median_Cells_RadialDistribution_MeanFrac_Mito_4of4",
"Median_Cells_RadialDistribution_MeanFrac_Ph_golgi_1of4",
"Median_Cells_RadialDistribution_MeanFrac_Ph_golgi_2of4",
"Median_Cells_RadialDistribution_MeanFrac_Ph_golgi_4of4",
"Median_Cells_RadialDistribution_RadialCV_Mito_3of4",
"Median_Cells_RadialDistribution_RadialCV_Mito_4of4",
"Median_Cells_RadialDistribution_RadialCV_Ph_golgi_1of4",
"Median_Cells_RadialDistribution_RadialCV_Ph_golgi_2of4",
"Median_Cells_RadialDistribution_RadialCV_Ph_golgi_3of4",
"Median_Cells_Texture_AngularSecondMoment_Mito_10_00",
"Median_Cells_Texture_AngularSecondMoment_Mito_3_00",
"Median_Cells_Texture_AngularSecondMoment_Mito_5_00",
"Median_Cells_Texture_AngularSecondMoment_Ph_golgi_10_00",
"Median_Cells_Texture_AngularSecondMoment_Ph_golgi_3_00",
"Median_Cells_Texture_AngularSecondMoment_Ph_golgi_5_00",
"Median_Cells_Texture_AngularSecondMoment_Syto_10_00",
"Median_Cells_Texture_AngularSecondMoment_Syto_3_00",
"Median_Cells_Texture_AngularSecondMoment_Syto_5_00",
"Median_Cells_Texture_Contrast_ER_3_00",
"Median_Cells_Texture_Contrast_ER_5_00",
"Median_Cells_Texture_Contrast_Hoechst_10_00",
"Median_Cells_Texture_Contrast_Hoechst_3_00",
"Median_Cells_Texture_Contrast_Hoechst_5_00",
"Median_Cells_Texture_Contrast_Mito_10_00",
"Median_Cells_Texture_Contrast_Mito_3_00",
"Median_Cells_Texture_Contrast_Mito_5_00",
"Median_Cells_Texture_Contrast_Ph_golgi_10_00",
"Median_Cells_Texture_Contrast_Ph_golgi_3_00",
"Median_Cells_Texture_Contrast_Ph_golgi_5_00",
"Median_Cells_Texture_Contrast_Syto_10_00",
"Median_Cells_Texture_Contrast_Syto_3_00",
"Median_Cells_Texture_Contrast_Syto_5_00",
"Median_Cells_Texture_Correlation_ER_10_00",
"Median_Cells_Texture_Correlation_ER_3_00",
"Median_Cells_Texture_Correlation_ER_5_00",
"Median_Cells_Texture_Correlation_Mito_10_00",
"Median_Cells_Texture_Correlation_Mito_3_00",
"Median_Cells_Texture_Correlation_Mito_5_00",
"Median_Cells_Texture_Correlation_Ph_golgi_10_00",
"Median_Cells_Texture_Correlation_Ph_golgi_3_00",
"Median_Cells_Texture_Correlation_Ph_golgi_5_00",
"Median_Cells_Texture_Correlation_Syto_10_00",
"Median_Cells_Texture_Correlation_Syto_5_00",
"Median_Cells_Texture_DifferenceEntropy_Hoechst_10_00",
"Median_Cells_Texture_DifferenceEntropy_Mito_10_00",
"Median_Cells_Texture_DifferenceEntropy_Mito_3_00",
"Median_Cells_Texture_DifferenceEntropy_Mito_5_00",
"Median_Cells_Texture_DifferenceEntropy_Ph_golgi_10_00",
"Median_Cells_Texture_DifferenceEntropy_Ph_golgi_3_00",
"Median_Cells_Texture_DifferenceEntropy_Ph_golgi_5_00",
"Median_Cells_Texture_DifferenceEntropy_Syto_10_00",
"Median_Cells_Texture_DifferenceEntropy_Syto_3_00",
"Median_Cells_Texture_DifferenceEntropy_Syto_5_00",
"Median_Cells_Texture_DifferenceVariance_Mito_10_00",
"Median_Cells_Texture_DifferenceVariance_Mito_3_00",
"Median_Cells_Texture_DifferenceVariance_Mito_5_00",
"Median_Cells_Texture_DifferenceVariance_Ph_golgi_10_00",
"Median_Cells_Texture_DifferenceVariance_Ph_golgi_3_00",
"Median_Cells_Texture_DifferenceVariance_Ph_golgi_5_00",
"Median_Cells_Texture_DifferenceVariance_Syto_10_00",
"Median_Cells_Texture_DifferenceVariance_Syto_3_00",
"Median_Cells_Texture_DifferenceVariance_Syto_5_00",
"Median_Cells_Texture_Entropy_Mito_10_00",
"Median_Cells_Texture_Entropy_Mito_3_00",
"Median_Cells_Texture_Entropy_Mito_5_00",
"Median_Cells_Texture_Entropy_Ph_golgi_10_00",
"Median_Cells_Texture_Entropy_Ph_golgi_3_00",
"Median_Cells_Texture_Entropy_Ph_golgi_5_00",
"Median_Cells_Texture_Entropy_Syto_10_00",
"Median_Cells_Texture_Entropy_Syto_3_00",
"Median_Cells_Texture_Entropy_Syto_5_00",
"Median_Cells_Texture_InfoMeas2_Ph_golgi_10_00",
"Median_Cells_Texture_InfoMeas2_Ph_golgi_3_00",
"Median_Cells_Texture_InfoMeas2_Ph_golgi_5_00",
"Median_Cells_Texture_InverseDifferenceMoment_ER_10_00",
"Median_Cells_Texture_InverseDifferenceMoment_ER_3_00",
"Median_Cells_Texture_InverseDifferenceMoment_ER_5_00",
"Median_Cells_Texture_InverseDifferenceMoment_Mito_10_00",
"Median_Cells_Texture_InverseDifferenceMoment_Mito_3_00",
"Median_Cells_Texture_InverseDifferenceMoment_Mito_5_00",
"Median_Cells_Texture_InverseDifferenceMoment_Ph_golgi_10_00",
"Median_Cells_Texture_InverseDifferenceMoment_Ph_golgi_3_00",
"Median_Cells_Texture_InverseDifferenceMoment_Ph_golgi_5_00",
"Median_Cells_Texture_InverseDifferenceMoment_Syto_10_00",
"Median_Cells_Texture_InverseDifferenceMoment_Syto_3_00",
"Median_Cells_Texture_InverseDifferenceMoment_Syto_5_00",
"Median_Cells_Texture_SumAverage_Hoechst_10_00",
"Median_Cells_Texture_SumAverage_Hoechst_3_00",
"Median_Cells_Texture_SumAverage_Hoechst_5_00",
"Median_Cells_Texture_SumAverage_Mito_10_00",
"Median_Cells_Texture_SumAverage_Mito_3_00",
"Median_Cells_Texture_SumAverage_Mito_5_00",
"Median_Cells_Texture_SumAverage_Syto_10_00",
"Median_Cells_Texture_SumAverage_Syto_3_00",
"Median_Cells_Texture_SumAverage_Syto_5_00",
"Median_Cells_Texture_SumEntropy_Mito_10_00",
"Median_Cells_Texture_SumEntropy_Mito_3_00",
"Median_Cells_Texture_SumEntropy_Mito_5_00",
"Median_Cells_Texture_SumEntropy_Ph_golgi_10_00",
"Median_Cells_Texture_SumEntropy_Ph_golgi_3_00",
"Median_Cells_Texture_SumEntropy_Ph_golgi_5_00",
"Median_Cells_Texture_SumEntropy_Syto_10_00",
"Median_Cells_Texture_SumEntropy_Syto_3_00",
"Median_Cells_Texture_SumEntropy_Syto_5_00",
"Median_Cells_Texture_SumVariance_Hoechst_10_00",
"Median_Cells_Texture_SumVariance_Hoechst_3_00",
"Median_Cells_Texture_SumVariance_Hoechst_5_00",
"Median_Cells_Texture_SumVariance_Mito_10_00",
"Median_Cells_Texture_SumVariance_Mito_3_00",
"Median_Cells_Texture_SumVariance_Mito_5_00",
"Median_Cells_Texture_SumVariance_Ph_golgi_10_00",
"Median_Cells_Texture_SumVariance_Ph_golgi_3_00",
"Median_Cells_Texture_SumVariance_Ph_golgi_5_00",
"Median_Cells_Texture_SumVariance_Syto_3_00",
"Median_Cells_Texture_SumVariance_Syto_5_00",
"Median_Cells_Texture_Variance_Hoechst_10_00",
"Median_Cells_Texture_Variance_Hoechst_3_00",
"Median_Cells_Texture_Variance_Hoechst_5_00",
"Median_Cells_Texture_Variance_Mito_10_00",
"Median_Cells_Texture_Variance_Mito_3_00",
"Median_Cells_Texture_Variance_Mito_5_00",
"Median_Cells_Texture_Variance_Ph_golgi_10_00",
"Median_Cells_Texture_Variance_Ph_golgi_3_00",
"Median_Cells_Texture_Variance_Ph_golgi_5_00",
"Median_Cells_Texture_Variance_Syto_10_00",
"Median_Cells_Texture_Variance_Syto_3_00",
"Median_Cells_Texture_Variance_Syto_5_00",
"Median_Cytoplasm_AreaShape_Area",
"Median_Cytoplasm_AreaShape_MinFeretDiameter",
"Median_Cytoplasm_AreaShape_MinorAxisLength",
"Median_Cytoplasm_AreaShape_Perimeter",
"Median_Cytoplasm_Correlation_Correlation_ER_Ph_golgi",
"Median_Cytoplasm_Correlation_Correlation_ER_Syto",
"Median_Cytoplasm_Correlation_Correlation_Hoechst_ER",
"Median_Cytoplasm_Correlation_Correlation_Hoechst_Mito",
"Median_Cytoplasm_Correlation_Correlation_Hoechst_Ph_golgi",
"Median_Cytoplasm_Correlation_Correlation_Hoechst_Syto",
"Median_Cytoplasm_Correlation_Correlation_Mito_ER",
"Median_Cytoplasm_Correlation_Correlation_Mito_Ph_golgi",
"Median_Cytoplasm_Correlation_Correlation_Mito_Syto",
"Median_Cytoplasm_Correlation_Correlation_Syto_Ph_golgi",
"Median_Cytoplasm_Correlation_K_ER_Syto",
"Median_Cytoplasm_Correlation_K_Hoechst_ER",
"Median_Cytoplasm_Correlation_K_Hoechst_Mito",
"Median_Cytoplasm_Correlation_K_Hoechst_Ph_golgi",
"Median_Cytoplasm_Correlation_K_Hoechst_Syto",
"Median_Cytoplasm_Correlation_K_Mito_Hoechst",
"Median_Cytoplasm_Correlation_K_Mito_Syto",
"Median_Cytoplasm_Correlation_K_Ph_golgi_Syto",
"Median_Cytoplasm_Correlation_K_Syto_ER",
"Median_Cytoplasm_Correlation_K_Syto_Hoechst",
"Median_Cytoplasm_Correlation_K_Syto_Mito",
"Median_Cytoplasm_Correlation_K_Syto_Ph_golgi",
"Median_Cytoplasm_Correlation_Manders_ER_Hoechst",
"Median_Cytoplasm_Correlation_Manders_ER_Syto",
"Median_Cytoplasm_Correlation_Manders_Hoechst_Syto",
"Median_Cytoplasm_Correlation_Manders_Mito_Hoechst",
"Median_Cytoplasm_Correlation_Manders_Mito_Syto",
"Median_Cytoplasm_Correlation_Manders_Ph_golgi_Hoechst",
"Median_Cytoplasm_Correlation_Manders_Ph_golgi_Syto",
"Median_Cytoplasm_Correlation_Manders_Syto_Hoechst",
"Median_Cytoplasm_Correlation_Overlap_ER_Syto",
"Median_Cytoplasm_Correlation_Overlap_Hoechst_ER",
"Median_Cytoplasm_Correlation_Overlap_Hoechst_Mito",
"Median_Cytoplasm_Correlation_Overlap_Hoechst_Ph_golgi",
"Median_Cytoplasm_Correlation_Overlap_Mito_Ph_golgi",
"Median_Cytoplasm_Correlation_Overlap_Mito_Syto",
"Median_Cytoplasm_Correlation_Overlap_Syto_Ph_golgi",
"Median_Cytoplasm_Correlation_RWC_ER_Hoechst",
"Median_Cytoplasm_Correlation_RWC_ER_Mito",
"Median_Cytoplasm_Correlation_RWC_Hoechst_Mito",
"Median_Cytoplasm_Correlation_RWC_Hoechst_Ph_golgi",
"Median_Cytoplasm_Correlation_RWC_Hoechst_Syto",
"Median_Cytoplasm_Correlation_RWC_Mito_Hoechst",
"Median_Cytoplasm_Correlation_RWC_Mito_Syto",
"Median_Cytoplasm_Correlation_RWC_Ph_golgi_Hoechst",
"Median_Cytoplasm_Correlation_RWC_Ph_golgi_Mito",
"Median_Cytoplasm_Correlation_RWC_Ph_golgi_Syto",
"Median_Cytoplasm_Correlation_RWC_Syto_Hoechst",
"Median_Cytoplasm_Correlation_RWC_Syto_Mito",
"Median_Cytoplasm_Granularity_1_Mito",
"Median_Cytoplasm_Granularity_1_Ph_golgi",
"Median_Cytoplasm_Granularity_1_Syto",
"Median_Cytoplasm_Granularity_2_ER",
"Median_Cytoplasm_Granularity_2_Mito",
"Median_Cytoplasm_Granularity_2_Ph_golgi",
"Median_Cytoplasm_Granularity_3_ER",
"Median_Cytoplasm_Granularity_3_Mito",
"Median_Cytoplasm_Granularity_3_Ph_golgi",
"Median_Cytoplasm_Granularity_3_Syto",
"Median_Cytoplasm_Granularity_4_Mito",
"Median_Cytoplasm_Granularity_4_Ph_golgi",
"Median_Cytoplasm_Granularity_5_Mito",
"Median_Cytoplasm_Granularity_5_Ph_golgi",
"Median_Cytoplasm_Intensity_IntegratedIntensity_Syto",
"Median_Cytoplasm_Intensity_LowerQuartileIntensity_Mito",
"Median_Cytoplasm_Intensity_MADIntensity_ER",
"Median_Cytoplasm_Intensity_MADIntensity_Hoechst",
"Median_Cytoplasm_Intensity_MADIntensity_Mito",
"Median_Cytoplasm_Intensity_MADIntensity_Ph_golgi",
"Median_Cytoplasm_Intensity_MADIntensity_Syto",
"Median_Cytoplasm_Intensity_MaxIntensityEdge_Hoechst",
"Median_Cytoplasm_Intensity_MaxIntensityEdge_Mito",
"Median_Cytoplasm_Intensity_MaxIntensityEdge_Ph_golgi",
"Median_Cytoplasm_Intensity_MaxIntensityEdge_Syto",
"Median_Cytoplasm_Intensity_MaxIntensity_Hoechst",
"Median_Cytoplasm_Intensity_MaxIntensity_Mito",
"Median_Cytoplasm_Intensity_MaxIntensity_Ph_golgi",
"Median_Cytoplasm_Intensity_MaxIntensity_Syto",
"Median_Cytoplasm_Intensity_MeanIntensityEdge_Hoechst",
"Median_Cytoplasm_Intensity_MeanIntensity_Mito",
"Median_Cytoplasm_Intensity_MeanIntensity_Syto",
"Median_Cytoplasm_Intensity_MedianIntensity_ER",
"Median_Cytoplasm_Intensity_MedianIntensity_Mito",
"Median_Cytoplasm_Intensity_MedianIntensity_Syto",
"Median_Cytoplasm_Intensity_MinIntensityEdge_Mito",
"Median_Cytoplasm_Intensity_MinIntensityEdge_Syto",
"Median_Cytoplasm_Intensity_MinIntensity_Mito",
"Median_Cytoplasm_Intensity_MinIntensity_Syto",
"Median_Cytoplasm_Intensity_StdIntensityEdge_Hoechst",
"Median_Cytoplasm_Intensity_StdIntensityEdge_Mito",
"Median_Cytoplasm_Intensity_StdIntensityEdge_Ph_golgi",
"Median_Cytoplasm_Intensity_StdIntensityEdge_Syto",
"Median_Cytoplasm_Intensity_StdIntensity_Hoechst",
"Median_Cytoplasm_Intensity_StdIntensity_Mito",
"Median_Cytoplasm_Intensity_StdIntensity_Ph_golgi",
"Median_Cytoplasm_Intensity_StdIntensity_Syto",
"Median_Cytoplasm_Intensity_UpperQuartileIntensity_ER",
"Median_Cytoplasm_Intensity_UpperQuartileIntensity_Mito",
"Median_Cytoplasm_Intensity_UpperQuartileIntensity_Syto",
"Median_Cytoplasm_RadialDistribution_MeanFrac_ER_1of4",
"Median_Cytoplasm_RadialDistribution_MeanFrac_ER_2of4",
"Median_Cytoplasm_RadialDistribution_MeanFrac_Mito_1of4",
"Median_Cytoplasm_RadialDistribution_MeanFrac_Mito_2of4",
"Median_Cytoplasm_RadialDistribution_MeanFrac_Mito_3of4",
"Median_Cytoplasm_RadialDistribution_MeanFrac_Mito_4of4",
"Median_Cytoplasm_RadialDistribution_MeanFrac_Ph_golgi_1of4",
"Median_Cytoplasm_RadialDistribution_MeanFrac_Ph_golgi_2of4",
"Median_Cytoplasm_RadialDistribution_MeanFrac_Ph_golgi_3of4",
"Median_Cytoplasm_RadialDistribution_MeanFrac_Ph_golgi_4of4",
"Median_Cytoplasm_RadialDistribution_RadialCV_Mito_1of4",
"Median_Cytoplasm_RadialDistribution_RadialCV_Mito_2of4",
"Median_Cytoplasm_RadialDistribution_RadialCV_Mito_3of4",
"Median_Cytoplasm_RadialDistribution_RadialCV_Mito_4of4",
"Median_Cytoplasm_RadialDistribution_RadialCV_Ph_golgi_1of4",
"Median_Cytoplasm_RadialDistribution_RadialCV_Ph_golgi_2of4",
"Median_Cytoplasm_RadialDistribution_RadialCV_Ph_golgi_3of4",
"Median_Cytoplasm_Texture_AngularSecondMoment_ER_3_00",
"Median_Cytoplasm_Texture_AngularSecondMoment_ER_5_00",
"Median_Cytoplasm_Texture_AngularSecondMoment_Mito_10_00",
"Median_Cytoplasm_Texture_AngularSecondMoment_Mito_3_00",
"Median_Cytoplasm_Texture_AngularSecondMoment_Mito_5_00",
"Median_Cytoplasm_Texture_AngularSecondMoment_Ph_golgi_10_00",
"Median_Cytoplasm_Texture_AngularSecondMoment_Ph_golgi_3_00",
"Median_Cytoplasm_Texture_AngularSecondMoment_Ph_golgi_5_00",
"Median_Cytoplasm_Texture_AngularSecondMoment_Syto_10_00",
"Median_Cytoplasm_Texture_AngularSecondMoment_Syto_3_00",
"Median_Cytoplasm_Texture_AngularSecondMoment_Syto_5_00",
"Median_Cytoplasm_Texture_Contrast_ER_10_00",
"Median_Cytoplasm_Texture_Contrast_ER_3_00",
"Median_Cytoplasm_Texture_Contrast_ER_5_00",
"Median_Cytoplasm_Texture_Contrast_Hoechst_10_00",
"Median_Cytoplasm_Texture_Contrast_Hoechst_3_00",
"Median_Cytoplasm_Texture_Contrast_Hoechst_5_00",
"Median_Cytoplasm_Texture_Contrast_Mito_10_00",
"Median_Cytoplasm_Texture_Contrast_Mito_3_00",
"Median_Cytoplasm_Texture_Contrast_Mito_5_00",
"Median_Cytoplasm_Texture_Contrast_Ph_golgi_10_00",
"Median_Cytoplasm_Texture_Contrast_Ph_golgi_3_00",
"Median_Cytoplasm_Texture_Contrast_Ph_golgi_5_00",
"Median_Cytoplasm_Texture_Contrast_Syto_10_00",
"Median_Cytoplasm_Texture_Contrast_Syto_5_00",
"Median_Cytoplasm_Texture_Correlation_Ph_golgi_10_00",
"Median_Cytoplasm_Texture_Correlation_Ph_golgi_3_00",
"Median_Cytoplasm_Texture_Correlation_Ph_golgi_5_00",
"Median_Cytoplasm_Texture_DifferenceEntropy_ER_3_00",
"Median_Cytoplasm_Texture_DifferenceEntropy_ER_5_00",
"Median_Cytoplasm_Texture_DifferenceEntropy_Mito_10_00",
"Median_Cytoplasm_Texture_DifferenceEntropy_Mito_3_00",
"Median_Cytoplasm_Texture_DifferenceEntropy_Mito_5_00",
"Median_Cytoplasm_Texture_DifferenceEntropy_Ph_golgi_10_00",
"Median_Cytoplasm_Texture_DifferenceEntropy_Ph_golgi_3_00",
"Median_Cytoplasm_Texture_DifferenceEntropy_Ph_golgi_5_00",
"Median_Cytoplasm_Texture_DifferenceEntropy_Syto_10_00",
"Median_Cytoplasm_Texture_DifferenceEntropy_Syto_3_00",
"Median_Cytoplasm_Texture_DifferenceEntropy_Syto_5_00",
"Median_Cytoplasm_Texture_DifferenceVariance_Mito_10_00",
"Median_Cytoplasm_Texture_DifferenceVariance_Mito_3_00",
"Median_Cytoplasm_Texture_DifferenceVariance_Mito_5_00",
"Median_Cytoplasm_Texture_DifferenceVariance_Ph_golgi_10_00",
"Median_Cytoplasm_Texture_DifferenceVariance_Ph_golgi_3_00",
"Median_Cytoplasm_Texture_DifferenceVariance_Ph_golgi_5_00",
"Median_Cytoplasm_Texture_DifferenceVariance_Syto_10_00",
"Median_Cytoplasm_Texture_DifferenceVariance_Syto_3_00",
"Median_Cytoplasm_Texture_DifferenceVariance_Syto_5_00",
"Median_Cytoplasm_Texture_Entropy_ER_3_00",
"Median_Cytoplasm_Texture_Entropy_ER_5_00",
"Median_Cytoplasm_Texture_Entropy_Mito_10_00",
"Median_Cytoplasm_Texture_Entropy_Mito_3_00",
"Median_Cytoplasm_Texture_Entropy_Mito_5_00",
"Median_Cytoplasm_Texture_Entropy_Ph_golgi_10_00",
"Median_Cytoplasm_Texture_Entropy_Ph_golgi_3_00",
"Median_Cytoplasm_Texture_Entropy_Ph_golgi_5_00",
"Median_Cytoplasm_Texture_Entropy_Syto_10_00",
"Median_Cytoplasm_Texture_Entropy_Syto_3_00",
"Median_Cytoplasm_Texture_Entropy_Syto_5_00",
"Median_Cytoplasm_Texture_InfoMeas2_Syto_10_00",
"Median_Cytoplasm_Texture_InverseDifferenceMoment_ER_10_00",
"Median_Cytoplasm_Texture_InverseDifferenceMoment_ER_3_00",
"Median_Cytoplasm_Texture_InverseDifferenceMoment_ER_5_00",
"Median_Cytoplasm_Texture_InverseDifferenceMoment_Mito_10_00",
"Median_Cytoplasm_Texture_InverseDifferenceMoment_Mito_3_00",
"Median_Cytoplasm_Texture_InverseDifferenceMoment_Mito_5_00",
"Median_Cytoplasm_Texture_InverseDifferenceMoment_Ph_golgi_10_00",
"Median_Cytoplasm_Texture_InverseDifferenceMoment_Ph_golgi_3_00",
"Median_Cytoplasm_Texture_InverseDifferenceMoment_Ph_golgi_5_00",
"Median_Cytoplasm_Texture_InverseDifferenceMoment_Syto_10_00",
"Median_Cytoplasm_Texture_InverseDifferenceMoment_Syto_3_00",
"Median_Cytoplasm_Texture_InverseDifferenceMoment_Syto_5_00",
"Median_Cytoplasm_Texture_SumAverage_ER_10_00",
"Median_Cytoplasm_Texture_SumAverage_Mito_10_00",
"Median_Cytoplasm_Texture_SumAverage_Mito_3_00",
"Median_Cytoplasm_Texture_SumAverage_Mito_5_00",
"Median_Cytoplasm_Texture_SumAverage_Syto_10_00",
"Median_Cytoplasm_Texture_SumAverage_Syto_3_00",
"Median_Cytoplasm_Texture_SumAverage_Syto_5_00",
"Median_Cytoplasm_Texture_SumEntropy_Mito_10_00",
"Median_Cytoplasm_Texture_SumEntropy_Mito_3_00",
"Median_Cytoplasm_Texture_SumEntropy_Mito_5_00",
"Median_Cytoplasm_Texture_SumEntropy_Ph_golgi_10_00",
"Median_Cytoplasm_Texture_SumEntropy_Ph_golgi_3_00",
"Median_Cytoplasm_Texture_SumEntropy_Ph_golgi_5_00",
"Median_Cytoplasm_Texture_SumEntropy_Syto_10_00",
"Median_Cytoplasm_Texture_SumEntropy_Syto_3_00",
"Median_Cytoplasm_Texture_SumEntropy_Syto_5_00",
"Median_Cytoplasm_Texture_SumVariance_Hoechst_10_00",
"Median_Cytoplasm_Texture_SumVariance_Hoechst_3_00",
"Median_Cytoplasm_Texture_SumVariance_Hoechst_5_00",
"Median_Cytoplasm_Texture_SumVariance_Mito_10_00",
"Median_Cytoplasm_Texture_SumVariance_Mito_3_00",
"Median_Cytoplasm_Texture_SumVariance_Mito_5_00",
"Median_Cytoplasm_Texture_SumVariance_Ph_golgi_10_00",
"Median_Cytoplasm_Texture_SumVariance_Ph_golgi_3_00",
"Median_Cytoplasm_Texture_SumVariance_Ph_golgi_5_00",
"Median_Cytoplasm_Texture_SumVariance_Syto_10_00",
"Median_Cytoplasm_Texture_SumVariance_Syto_3_00",
"Median_Cytoplasm_Texture_SumVariance_Syto_5_00",
"Median_Cytoplasm_Texture_Variance_Hoechst_10_00",
"Median_Cytoplasm_Texture_Variance_Hoechst_3_00",
"Median_Cytoplasm_Texture_Variance_Hoechst_5_00",
"Median_Cytoplasm_Texture_Variance_Mito_10_00",
"Median_Cytoplasm_Texture_Variance_Mito_3_00",
"Median_Cytoplasm_Texture_Variance_Mito_5_00",
"Median_Cytoplasm_Texture_Variance_Ph_golgi_10_00",
"Median_Cytoplasm_Texture_Variance_Ph_golgi_3_00",
"Median_Cytoplasm_Texture_Variance_Ph_golgi_5_00",
"Median_Cytoplasm_Texture_Variance_Syto_10_00",
"Median_Cytoplasm_Texture_Variance_Syto_3_00",
"Median_Cytoplasm_Texture_Variance_Syto_5_00",
"Median_Nuclei_AreaShape_Area",
"Median_Nuclei_AreaShape_MajorAxisLength",
"Median_Nuclei_AreaShape_MaxFeretDiameter",
"Median_Nuclei_AreaShape_Perimeter",
"Median_Nuclei_AreaShape_Solidity",
"Median_Nuclei_Correlation_Correlation_Hoechst_Syto",
"Median_Nuclei_Correlation_Correlation_Mito_Ph_golgi",
"Median_Nuclei_Correlation_Correlation_Mito_Syto",
"Median_Nuclei_Correlation_K_Mito_Ph_golgi",
"Median_Nuclei_Correlation_K_Ph_golgi_Mito",
"Median_Nuclei_Correlation_K_Ph_golgi_Syto",
"Median_Nuclei_Correlation_K_Syto_Ph_golgi",
"Median_Nuclei_Correlation_Overlap_Hoechst_Mito",
"Median_Nuclei_Correlation_Overlap_Hoechst_Ph_golgi",
"Median_Nuclei_Correlation_Overlap_Hoechst_Syto",
"Median_Nuclei_Correlation_RWC_Mito_Syto",
"Median_Nuclei_Correlation_RWC_Syto_Mito",
"Median_Nuclei_Granularity_1_Mito",
"Median_Nuclei_Granularity_2_Hoechst",
"Median_Nuclei_Granularity_3_Mito",
"Median_Nuclei_Granularity_3_Ph_golgi",
"Median_Nuclei_Granularity_4_Mito",
"Median_Nuclei_Intensity_LowerQuartileIntensity_Hoechst",
"Median_Nuclei_Intensity_MADIntensity_Hoechst",
"Median_Nuclei_Intensity_MADIntensity_Mito",
"Median_Nuclei_Intensity_MaxIntensityEdge_Hoechst",
"Median_Nuclei_Intensity_MaxIntensityEdge_Mito",
"Median_Nuclei_Intensity_MaxIntensityEdge_Ph_golgi",
"Median_Nuclei_Intensity_MaxIntensityEdge_Syto",
"Median_Nuclei_Intensity_MaxIntensity_Hoechst",
"Median_Nuclei_Intensity_MaxIntensity_Mito",
"Median_Nuclei_Intensity_MaxIntensity_Ph_golgi",
"Median_Nuclei_Intensity_MeanIntensityEdge_Hoechst",
"Median_Nuclei_Intensity_MeanIntensity_Hoechst",
"Median_Nuclei_Intensity_MedianIntensity_Hoechst",
"Median_Nuclei_Intensity_MinIntensityEdge_Hoechst",
"Median_Nuclei_Intensity_MinIntensity_Hoechst",
"Median_Nuclei_Intensity_StdIntensityEdge_Mito",
"Median_Nuclei_Intensity_StdIntensityEdge_Ph_golgi",
"Median_Nuclei_Intensity_StdIntensityEdge_Syto",
"Median_Nuclei_Intensity_StdIntensity_Mito",
"Median_Nuclei_Intensity_StdIntensity_Ph_golgi",
"Median_Nuclei_Intensity_UpperQuartileIntensity_Hoechst",
"Median_Nuclei_RadialDistribution_FracAtD_Ph_golgi_3of4",
"Median_Nuclei_RadialDistribution_MeanFrac_Mito_1of4",
"Median_Nuclei_RadialDistribution_MeanFrac_Mito_2of4",
"Median_Nuclei_RadialDistribution_MeanFrac_Mito_3of4",
"Median_Nuclei_RadialDistribution_MeanFrac_Mito_4of4",
"Median_Nuclei_RadialDistribution_MeanFrac_Ph_golgi_2of4",
"Median_Nuclei_RadialDistribution_MeanFrac_Ph_golgi_3of4",
"Median_Nuclei_RadialDistribution_MeanFrac_Ph_golgi_4of4",
"Median_Nuclei_Texture_AngularSecondMoment_Hoechst_10_00",
"Median_Nuclei_Texture_AngularSecondMoment_Hoechst_3_00",
"Median_Nuclei_Texture_AngularSecondMoment_Hoechst_5_00",
"Median_Nuclei_Texture_AngularSecondMoment_Mito_3_00",
"Median_Nuclei_Texture_AngularSecondMoment_Mito_5_00",
"Median_Nuclei_Texture_Contrast_Hoechst_3_00",
"Median_Nuclei_Texture_Contrast_Hoechst_5_00",
"Median_Nuclei_Texture_Contrast_Mito_10_00",
"Median_Nuclei_Texture_Contrast_Mito_3_00",
"Median_Nuclei_Texture_Contrast_Mito_5_00",
"Median_Nuclei_Texture_Contrast_Ph_golgi_10_00",
"Median_Nuclei_Texture_Contrast_Ph_golgi_3_00",
"Median_Nuclei_Texture_Contrast_Ph_golgi_5_00",
"Median_Nuclei_Texture_Correlation_Ph_golgi_3_00",
"Median_Nuclei_Texture_DifferenceEntropy_Hoechst_10_00",
"Median_Nuclei_Texture_DifferenceEntropy_Hoechst_3_00",
"Median_Nuclei_Texture_DifferenceEntropy_Hoechst_5_00",
"Median_Nuclei_Texture_DifferenceEntropy_Mito_10_00",
"Median_Nuclei_Texture_DifferenceEntropy_Mito_3_00",
"Median_Nuclei_Texture_DifferenceEntropy_Mito_5_00",
"Median_Nuclei_Texture_DifferenceEntropy_Ph_golgi_3_00",
"Median_Nuclei_Texture_DifferenceEntropy_Ph_golgi_5_00",
"Median_Nuclei_Texture_DifferenceVariance_Hoechst_10_00",
"Median_Nuclei_Texture_DifferenceVariance_Hoechst_3_00",
"Median_Nuclei_Texture_DifferenceVariance_Hoechst_5_00",
"Median_Nuclei_Texture_DifferenceVariance_Mito_3_00",
"Median_Nuclei_Texture_DifferenceVariance_Mito_5_00",
"Median_Nuclei_Texture_DifferenceVariance_Ph_golgi_10_00",
"Median_Nuclei_Texture_DifferenceVariance_Ph_golgi_3_00",
"Median_Nuclei_Texture_DifferenceVariance_Ph_golgi_5_00",
"Median_Nuclei_Texture_Entropy_Hoechst_3_00",
"Median_Nuclei_Texture_Entropy_Hoechst_5_00",
"Median_Nuclei_Texture_Entropy_Mito_10_00",
"Median_Nuclei_Texture_Entropy_Mito_3_00",
"Median_Nuclei_Texture_Entropy_Mito_5_00",
"Median_Nuclei_Texture_InfoMeas2_Hoechst_10_00",
"Median_Nuclei_Texture_InfoMeas2_Mito_10_00",
"Median_Nuclei_Texture_InfoMeas2_Ph_golgi_10_00",
"Median_Nuclei_Texture_InfoMeas2_Ph_golgi_3_00",
"Median_Nuclei_Texture_InfoMeas2_Ph_golgi_5_00",
"Median_Nuclei_Texture_InverseDifferenceMoment_Hoechst_10_00",
"Median_Nuclei_Texture_InverseDifferenceMoment_Hoechst_3_00",
"Median_Nuclei_Texture_InverseDifferenceMoment_Hoechst_5_00",
"Median_Nuclei_Texture_InverseDifferenceMoment_Mito_10_00",
"Median_Nuclei_Texture_InverseDifferenceMoment_Mito_3_00",
"Median_Nuclei_Texture_InverseDifferenceMoment_Mito_5_00",
"Median_Nuclei_Texture_SumAverage_Hoechst_10_00",
"Median_Nuclei_Texture_SumAverage_Hoechst_3_00",
"Median_Nuclei_Texture_SumAverage_Hoechst_5_00",
"Median_Nuclei_Texture_SumEntropy_Mito_10_00",
"Median_Nuclei_Texture_SumEntropy_Mito_3_00",
"Median_Nuclei_Texture_SumEntropy_Mito_5_00",
"Median_Nuclei_Texture_SumEntropy_Ph_golgi_10_00",
"Median_Nuclei_Texture_SumEntropy_Ph_golgi_3_00",
"Median_Nuclei_Texture_SumEntropy_Ph_golgi_5_00",
"Median_Nuclei_Texture_SumVariance_Mito_10_00",
"Median_Nuclei_Texture_SumVariance_Mito_3_00",
"Median_Nuclei_Texture_SumVariance_Mito_5_00",
"Median_Nuclei_Texture_SumVariance_Ph_golgi_10_00",
"Median_Nuclei_Texture_SumVariance_Ph_golgi_3_00",
"Median_Nuclei_Texture_SumVariance_Ph_golgi_5_00",
"Median_Nuclei_Texture_Variance_Mito_10_00",
"Median_Nuclei_Texture_Variance_Mito_3_00",
"Median_Nuclei_Texture_Variance_Mito_5_00",
"Median_Nuclei_Texture_Variance_Ph_golgi_10_00",
"Median_Nuclei_Texture_Variance_Ph_golgi_3_00",
"Median_Nuclei_Texture_Variance_Ph_golgi_5_00",
]
def profile_sim(
prof1: Iterable[float],
prof2: Iterable[float],
) -> float:
"""Calculates the similarity of two activity_profiles of the same length.
The profiles are compared by distance correlation
``scipy.spatial.distance.correlation()`` (same as Pearson correlation).
Parameters:
===========
prof1: The first profile to compare.
prof2: The second profile to compare.
The two profiles have to be of equal length.
Returns:
========
Similarity value between 0.0 .. 1.0 (0.0 being very dissimilar and 1.0 identical)."""
assert len(prof1) == len(
prof2
), "Activity Profiles must have the same length to be compared."
if not isinstance(prof1, np.ndarray):
prof1 = np.array(prof1)
prof1 = np.clip(prof1, -25.0, 25.0)
if not isinstance(prof2, np.ndarray):
prof2 = np.array(prof2)
prof2 = np.clip(prof2, -25.0, 25.0)
result = 1 - dist.correlation(prof1, prof2)
if np.isnan(result) or result < 0.0:
result = 0.0
return result
def well_id_similarity(df: DataFrame, well_id1: str, well_id2: str) -> float:
"""Calculate the similarity of the activity profiles from two compounds
(identified by `Well_Id`). Returns value between 0 .. 1"""
act1 = df[df["Well_Id"] == well_id1][ACT_PROF_PARAMETERS].values[0]
act2 = df[df["Well_Id"] == well_id2][ACT_PROF_PARAMETERS].values[0]
return round(profile_sim(act1, act2), 3)