-
Notifications
You must be signed in to change notification settings - Fork 15
/
10R-Control-validation-analyses-TCGA.R
executable file
·1224 lines (1164 loc) · 102 KB
/
10R-Control-validation-analyses-TCGA.R
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
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#-----------------------------------------------------------------------------
# 10R-Control-validation-analyses-TCGA.R
# Copyright (c) 2021--, Greg Poore
# Purposes:
# - Split data into 2 stratified halves, normalize using VSNM, train ML models, and test on each other
# - Scramble metadata and shuffle samples and re-run ML as controls
# - Compare performance of ML controls to actual data for raw data (per seq center) and VSNM (all TCGA)
#-----------------------------------------------------------------------------
#----------------------------------------------------------#
# Load environments
#----------------------------------------------------------#
# Load dependencies
require(devtools)
require(doMC)
require(phyloseq)
require(microbiome)
require(vegan)
require(plyr)
require(dplyr)
require(reshape2)
require(ggpubr)
require(ggsci)
require(ANCOMBC)
require(biomformat)
require(Rhdf5lib)
numCores <- detectCores()
registerDoMC(cores=numCores)
#----------------------------------------------------------#
# Load TCGA fungi data
#----------------------------------------------------------#
load("Interim_data/snmDataFungi_DecontamV2_25Mar22.RData", verbose = T)
rep200TaxSplit <- read.csv("Supporting_data/rep200_lineage_map_split.csv", stringsAsFactors = FALSE, row.names = 1)
#----------------------------------------------------------#
# Split into 2 stratified halves
#----------------------------------------------------------#
require(data.table)
require(splitstackshape)
splitVars <- c("data_submitting_center_label","sample_type","disease_type")
set.seed(42)
stratSamplingHalvesMetadata <- stratified(metaQiitaCombined_Nonzero_DecontamV2,
group = splitVars,
size = 0.5,
keep.rownames = TRUE,
bothSets = TRUE,
replace = FALSE)
split1 <- as.data.frame(stratSamplingHalvesMetadata[[1]])
rownames(split1) <- split1$rn
split2 <- as.data.frame(stratSamplingHalvesMetadata[[2]])
rownames(split2) <- split2$rn
centerCompare <- data.frame(Split = c(rep("Split 1", dim(split1)[1]),
rep("Split 2", dim(split2)[1])),
SeqCenter = c(as.character(split1$data_submitting_center_label),
as.character(split2$data_submitting_center_label)),
SampleType = c(as.character(split1$sample_type),
as.character(split2$sample_type)),
DiseaseType = c(as.character(split1$investigation),
as.character(split2$investigation)),
PathStage = c(as.character(split1$pathologic_stage_label),
as.character(split2$pathologic_stage_label)))
ggplot(centerCompare, aes(x = SeqCenter, fill = Split)) + geom_bar(position = "dodge",stat = "count") +
theme(axis.text.x = element_text(angle = 15, hjust = 1)) + scale_fill_nejm() +
geom_text(stat='count', aes(label=..count..), vjust=-0.5, color="black", position = position_dodge(0.9)) +
ylim(c(0,floor(1.1*max(table(centerCompare$SeqCenter))/2))) + theme_bw() + rotate_x_text(15) +
labs(x = "Sequencing Center", y = "Count", title = "Validation split - Sequence center distribution")
ggsave(filename = "Figures/Other_Figures/tcga_validation_splits_seq_center.pdf", dpi = "retina", width = 14, units = "in")
ggplot(centerCompare, aes(x = SampleType, fill = Split)) + geom_bar(position = "dodge",stat = "count") +
theme(axis.text.x = element_text(angle = 15, hjust = 1)) + scale_fill_nejm() +
geom_text(stat='count', aes(label=..count..), vjust=-0.5, color="black", position = position_dodge(0.9)) +
ylim(c(0,floor(1.1*max(table(centerCompare$SampleType))/2))) + theme_bw() + rotate_x_text(0) +
labs(x = "Sample Type", y = "Count", title = "Validation split - Sample type distribution")
ggsave(filename = "Figures/Other_Figures/tcga_validation_splits_sample_type.pdf", dpi = "retina", width = 12, units = "in")
ggplot(centerCompare, aes(x = DiseaseType, fill = Split)) + geom_bar(position = "dodge",stat = "count") +
theme(axis.text.x = element_text(angle = 90, hjust = 1)) + scale_fill_nejm() +
geom_text(stat='count', aes(label=..count..), hjust=-0.25, color="black", position = position_dodge(0.9), angle=90) +
ylim(c(0,floor(1.15*max(table(centerCompare$DiseaseType))/2))) + theme_bw() + rotate_x_text(30) +
labs(x = "Sample Type", y = "Count", title = "Validation split - Disease type distribution")
ggsave(filename = "Figures/Other_Figures/tcga_validation_splits_dz_type.pdf", dpi = "retina", width = 12, units = "in")
ggplot(centerCompare, aes(x = PathStage, fill = Split)) + geom_bar(position = "dodge",stat = "count") +
theme(axis.text.x = element_text(angle = 90, hjust = 1)) + scale_fill_nejm() +
geom_text(stat='count', aes(label=..count..), hjust=-0.25, color="black", position = position_dodge(0.9), angle=90) +
ylim(c(0,floor(1.2*max(table(centerCompare$PathStage))/2))) + theme_bw() + rotate_x_text(30) +
labs(x = "Sample Type", y = "Count", title = "Validation split - Pathologic Stage distribution")
ggsave(filename = "Figures/Other_Figures/tcga_validation_splits_stage.pdf", dpi = "retina", width = 8, units = "in")
# Subset vb data using splits
valSplit1Metadata <- split1
valSplit2Metadata <- split2
valSplit1FungiCountDecontamV2Data <- rep200Data_WGS_RNA_HiSeq_Fungi_DecontamV2_Nonzero[rownames(valSplit1Metadata),]
valSplit2FungiCountDecontamV2Data <- rep200Data_WGS_RNA_HiSeq_Fungi_DecontamV2_Nonzero[rownames(valSplit2Metadata),]
#----------------------------------------------------------#
# VSNM batch correct each split and full dataset
#----------------------------------------------------------#
source("00-Functions.R") # for vsnmFunctionTCGA() function
## TCGA full data - biological variable: sample_type | technical variables: data_submitting_center_label + experimental_strategy
# Split 1
valSplit1FungiCountDecontamV2Data_VSNM_Obj <- vsnmFunctionTCGA(qcData = valSplit1FungiCountDecontamV2Data, qcMetadata = valSplit1Metadata) # converges
valSplit1FungiCountDecontamV2Data_VSNM <- valSplit1FungiCountDecontamV2Data_VSNM_Obj$snmData
# Split 2
valSplit2FungiCountDecontamV2Data_VSNM_Obj <- vsnmFunctionTCGA(qcData = valSplit2FungiCountDecontamV2Data, qcMetadata = valSplit2Metadata) # converges
valSplit2FungiCountDecontamV2Data_VSNM <- valSplit2FungiCountDecontamV2Data_VSNM_Obj$snmData
# Full data
valFullFungiCountDecontamV2Data_VSNM_Obj <- vsnmFunctionTCGA(qcData = rep200Data_WGS_RNA_HiSeq_Fungi_DecontamV2_Nonzero, qcMetadata = metaQiitaCombined_Nonzero_DecontamV2) # converges
valFullFungiCountDecontamV2Data_VSNM <- valFullFungiCountDecontamV2Data_VSNM_Obj$snmData
save(valSplit1Metadata,
valSplit1FungiCountDecontamV2Data,
valSplit1FungiCountDecontamV2Data_VSNM,
valSplit2Metadata,
valSplit2FungiCountDecontamV2Data,
valSplit2FungiCountDecontamV2Data_VSNM,
metaQiitaCombined_Nonzero_DecontamV2,
rep200Data_WGS_RNA_HiSeq_Fungi_DecontamV2_Nonzero,
valFullFungiCountDecontamV2Data_VSNM,
file = "Interim_data/validation_2halves_tcga_vsnm_data_4Apr22.RData")
# Scripts: S18R, S19R
#----------------------------------------------------------#
# Plot split performances
#----------------------------------------------------------#
source("00-Functions.R") # to load plotSplitPerfs() function
## Load data (note that the files each load a "perf" object, so it needs renaming)
rm(perf)
load("Interim_data/perf_raw_data_k10_4Apr22.RData", verbose = TRUE) # saved as perf object
perf_raw_data_k10 <- perf
rm(perf)
load("Interim_data/perf_vsnm_data_k10_4Apr22.RData", verbose = TRUE)
perf_val_halves_k10 <- perf
rm(perf)
## Plot
plotSplitPerfs(perfDf = perf_raw_data_k10, baseName = "val_halves_raw_data_k10")
plotSplitPerfs(perfDf = perf_val_halves_k10, baseName = "val_halves_vsnm_data_k10")
#----------------------------------------------------------#
# Scramble labels and data: raw data
#----------------------------------------------------------#
load("Interim_data/data_for_ml_tcga_by_seq_center_and_experimental_strategy_with_coverage_filter_decontamV2_2Apr22.RData")
#-----------------------Scramble metadata-----------------------#
# HMS
metaQiitaCombined_Nonzero_DecontamV2_HMS_scrambled <- metaQiitaCombined_Nonzero_DecontamV2_HMS
set.seed(42)
metaQiitaCombined_Nonzero_DecontamV2_HMS_scrambled$disease_type <- sample(metaQiitaCombined_Nonzero_DecontamV2_HMS_scrambled$disease_type)
set.seed(42)
metaQiitaCombined_Nonzero_DecontamV2_HMS_scrambled$sample_type <- sample(metaQiitaCombined_Nonzero_DecontamV2_HMS_scrambled$sample_type)
# BCM
metaQiitaCombined_Nonzero_DecontamV2_BCM_scrambled <- metaQiitaCombined_Nonzero_DecontamV2_BCM
set.seed(42)
metaQiitaCombined_Nonzero_DecontamV2_BCM_scrambled$disease_type <- sample(metaQiitaCombined_Nonzero_DecontamV2_BCM_scrambled$disease_type)
set.seed(42)
metaQiitaCombined_Nonzero_DecontamV2_BCM_scrambled$sample_type <- sample(metaQiitaCombined_Nonzero_DecontamV2_BCM_scrambled$sample_type)
# MDA
metaQiitaCombined_Nonzero_DecontamV2_MDA_scrambled <- metaQiitaCombined_Nonzero_DecontamV2_MDA
set.seed(42)
metaQiitaCombined_Nonzero_DecontamV2_MDA_scrambled$disease_type <- sample(metaQiitaCombined_Nonzero_DecontamV2_MDA_scrambled$disease_type)
set.seed(42)
metaQiitaCombined_Nonzero_DecontamV2_MDA_scrambled$sample_type <- sample(metaQiitaCombined_Nonzero_DecontamV2_MDA_scrambled$sample_type)
# WashU
metaQiitaCombined_Nonzero_DecontamV2_WashU_scrambled <- metaQiitaCombined_Nonzero_DecontamV2_WashU
set.seed(42)
metaQiitaCombined_Nonzero_DecontamV2_WashU_scrambled$disease_type <- sample(metaQiitaCombined_Nonzero_DecontamV2_WashU_scrambled$disease_type)
set.seed(42)
metaQiitaCombined_Nonzero_DecontamV2_WashU_scrambled$sample_type <- sample(metaQiitaCombined_Nonzero_DecontamV2_WashU_scrambled$sample_type)
# Broad_WGS
metaQiitaCombined_Nonzero_DecontamV2_Broad_WGS_scrambled <- metaQiitaCombined_Nonzero_DecontamV2_Broad_WGS
set.seed(42)
metaQiitaCombined_Nonzero_DecontamV2_Broad_WGS_scrambled$disease_type <- sample(metaQiitaCombined_Nonzero_DecontamV2_Broad_WGS_scrambled$disease_type)
set.seed(42)
metaQiitaCombined_Nonzero_DecontamV2_Broad_WGS_scrambled$sample_type <- sample(metaQiitaCombined_Nonzero_DecontamV2_Broad_WGS_scrambled$sample_type)
# UNC
metaQiitaCombined_Nonzero_DecontamV2_UNC_scrambled <- metaQiitaCombined_Nonzero_DecontamV2_UNC
set.seed(42)
metaQiitaCombined_Nonzero_DecontamV2_UNC_scrambled$disease_type <- sample(metaQiitaCombined_Nonzero_DecontamV2_UNC_scrambled$disease_type)
set.seed(42)
metaQiitaCombined_Nonzero_DecontamV2_UNC_scrambled$sample_type <- sample(metaQiitaCombined_Nonzero_DecontamV2_UNC_scrambled$sample_type)
# CMS
metaQiitaCombined_Nonzero_DecontamV2_CMS_scrambled <- metaQiitaCombined_Nonzero_DecontamV2_CMS
set.seed(42)
metaQiitaCombined_Nonzero_DecontamV2_CMS_scrambled$disease_type <- sample(metaQiitaCombined_Nonzero_DecontamV2_CMS_scrambled$disease_type)
set.seed(42)
metaQiitaCombined_Nonzero_DecontamV2_CMS_scrambled$sample_type <- sample(metaQiitaCombined_Nonzero_DecontamV2_CMS_scrambled$sample_type)
# Broad_RNA
metaQiitaCombined_Nonzero_DecontamV2_Broad_RNA_scrambled <- metaQiitaCombined_Nonzero_DecontamV2_Broad_RNA
set.seed(42)
metaQiitaCombined_Nonzero_DecontamV2_Broad_RNA_scrambled$disease_type <- sample(metaQiitaCombined_Nonzero_DecontamV2_Broad_RNA_scrambled$disease_type)
set.seed(42)
metaQiitaCombined_Nonzero_DecontamV2_Broad_RNA_scrambled$sample_type <- sample(metaQiitaCombined_Nonzero_DecontamV2_Broad_RNA_scrambled$sample_type)
#-----------------------Shuffle raw data-----------------------#
# HMS
set.seed(42)
rep200_HiSeq_Fungi_DecontamV2_HMS_shuffled <- rep200_HiSeq_Fungi_DecontamV2_HMS[sample(nrow(rep200_HiSeq_Fungi_DecontamV2_HMS)),]
rownames(rep200_HiSeq_Fungi_DecontamV2_HMS_shuffled) <- rownames(rep200_HiSeq_Fungi_DecontamV2_HMS)
# BCM
set.seed(42)
rep200_HiSeq_Fungi_DecontamV2_BCM_shuffled <- rep200_HiSeq_Fungi_DecontamV2_BCM[sample(nrow(rep200_HiSeq_Fungi_DecontamV2_BCM)),]
rownames(rep200_HiSeq_Fungi_DecontamV2_BCM_shuffled) <- rownames(rep200_HiSeq_Fungi_DecontamV2_BCM)
# MDA
set.seed(42)
rep200_HiSeq_Fungi_DecontamV2_MDA_shuffled <- rep200_HiSeq_Fungi_DecontamV2_MDA[sample(nrow(rep200_HiSeq_Fungi_DecontamV2_MDA)),]
rownames(rep200_HiSeq_Fungi_DecontamV2_MDA_shuffled) <- rownames(rep200_HiSeq_Fungi_DecontamV2_MDA)
# WashU
set.seed(42)
rep200_HiSeq_Fungi_DecontamV2_WashU_shuffled <- rep200_HiSeq_Fungi_DecontamV2_WashU[sample(nrow(rep200_HiSeq_Fungi_DecontamV2_WashU)),]
rownames(rep200_HiSeq_Fungi_DecontamV2_WashU_shuffled) <- rownames(rep200_HiSeq_Fungi_DecontamV2_WashU)
# Broad_WGS
set.seed(42)
rep200_HiSeq_Fungi_DecontamV2_Broad_WGS_shuffled <- rep200_HiSeq_Fungi_DecontamV2_Broad_WGS[sample(nrow(rep200_HiSeq_Fungi_DecontamV2_Broad_WGS)),]
rownames(rep200_HiSeq_Fungi_DecontamV2_Broad_WGS_shuffled) <- rownames(rep200_HiSeq_Fungi_DecontamV2_Broad_WGS)
# UNC
set.seed(42)
rep200_HiSeq_Fungi_DecontamV2_UNC_shuffled <- rep200_HiSeq_Fungi_DecontamV2_UNC[sample(nrow(rep200_HiSeq_Fungi_DecontamV2_UNC)),]
rownames(rep200_HiSeq_Fungi_DecontamV2_UNC_shuffled) <- rownames(rep200_HiSeq_Fungi_DecontamV2_UNC)
# CMS
set.seed(42)
rep200_HiSeq_Fungi_DecontamV2_CMS_shuffled <- rep200_HiSeq_Fungi_DecontamV2_CMS[sample(nrow(rep200_HiSeq_Fungi_DecontamV2_CMS)),]
rownames(rep200_HiSeq_Fungi_DecontamV2_CMS_shuffled) <- rownames(rep200_HiSeq_Fungi_DecontamV2_CMS)
# Broad_RNA
set.seed(42)
rep200_HiSeq_Fungi_DecontamV2_Broad_RNA_shuffled <- rep200_HiSeq_Fungi_DecontamV2_Broad_RNA[sample(nrow(rep200_HiSeq_Fungi_DecontamV2_Broad_RNA)),]
rownames(rep200_HiSeq_Fungi_DecontamV2_Broad_RNA_shuffled) <- rownames(rep200_HiSeq_Fungi_DecontamV2_Broad_RNA)
save(metaQiitaCombined_Nonzero_DecontamV2_HMS_scrambled,
metaQiitaCombined_Nonzero_DecontamV2_BCM_scrambled,
metaQiitaCombined_Nonzero_DecontamV2_MDA_scrambled,
metaQiitaCombined_Nonzero_DecontamV2_WashU_scrambled,
metaQiitaCombined_Nonzero_DecontamV2_Broad_WGS_scrambled,
metaQiitaCombined_Nonzero_DecontamV2_UNC_scrambled,
metaQiitaCombined_Nonzero_DecontamV2_CMS_scrambled,
metaQiitaCombined_Nonzero_DecontamV2_Broad_RNA_scrambled,
# Scrambled meta normal data
rep200_HiSeq_Fungi_DecontamV2_HMS,
rep200_HiSeq_Fungi_DecontamV2_BCM,
rep200_HiSeq_Fungi_DecontamV2_MDA,
rep200_HiSeq_Fungi_DecontamV2_WashU,
rep200_HiSeq_Fungi_DecontamV2_Broad_WGS,
rep200_HiSeq_Fungi_DecontamV2_UNC,
rep200_HiSeq_Fungi_DecontamV2_CMS,
rep200_HiSeq_Fungi_DecontamV2_Broad_RNA,
# Shuffled data normal metadata
metaQiitaCombined_Nonzero_DecontamV2_HMS,
metaQiitaCombined_Nonzero_DecontamV2_BCM,
metaQiitaCombined_Nonzero_DecontamV2_MDA,
metaQiitaCombined_Nonzero_DecontamV2_WashU,
metaQiitaCombined_Nonzero_DecontamV2_Broad_WGS,
metaQiitaCombined_Nonzero_DecontamV2_UNC,
metaQiitaCombined_Nonzero_DecontamV2_CMS,
metaQiitaCombined_Nonzero_DecontamV2_Broad_RNA,
rep200_HiSeq_Fungi_DecontamV2_HMS_shuffled,
rep200_HiSeq_Fungi_DecontamV2_BCM_shuffled,
rep200_HiSeq_Fungi_DecontamV2_MDA_shuffled,
rep200_HiSeq_Fungi_DecontamV2_WashU_shuffled,
rep200_HiSeq_Fungi_DecontamV2_Broad_WGS_shuffled,
rep200_HiSeq_Fungi_DecontamV2_UNC_shuffled,
rep200_HiSeq_Fungi_DecontamV2_CMS_shuffled,
rep200_HiSeq_Fungi_DecontamV2_Broad_RNA_shuffled,
file = "Interim_data/shuffled_controls_raw_data_TCGA_4Apr22.RData")
#----------------------------------------------------------#
# Scramble labels and data: VSNM data
#----------------------------------------------------------#
load("Interim_data/snmDataFungi_DecontamV2_25Mar22.RData")
load("Interim_data/validation_2halves_tcga_vsnm_data_4Apr22.RData")
# Scramble full metadata
metaQiitaCombined_Nonzero_DecontamV2_scrambled <- metaQiitaCombined_Nonzero_DecontamV2
set.seed(42)
metaQiitaCombined_Nonzero_DecontamV2_scrambled$disease_type <- sample(metaQiitaCombined_Nonzero_DecontamV2_scrambled$disease_type)
set.seed(42)
metaQiitaCombined_Nonzero_DecontamV2_scrambled$sample_type <- sample(metaQiitaCombined_Nonzero_DecontamV2_scrambled$sample_type)
# Shuffle VSNM data
set.seed(42)
valFullFungiCountDecontamV2Data_VSNM_Shuffled <- valFullFungiCountDecontamV2Data_VSNM[sample(nrow(valFullFungiCountDecontamV2Data_VSNM)),]
rownames(valFullFungiCountDecontamV2Data_VSNM_Shuffled) <- rownames(valFullFungiCountDecontamV2Data_VSNM)
save(metaQiitaCombined_Nonzero_DecontamV2_scrambled,
valFullFungiCountDecontamV2Data_VSNM,
metaQiitaCombined_Nonzero_DecontamV2,
valFullFungiCountDecontamV2Data_VSNM_Shuffled,
file = "Interim_data/shuffled_controls_VSNM_data_TCGA_4Apr22.RData")
#----------------------------------------------------------#
# Run ML
#----------------------------------------------------------#
# Script: S20R
#----------------------------------------------------------#
# Plot scrambled ML perf
#----------------------------------------------------------#
source("Supporting_scripts/S00-SummarySE.R") # Contains a function that calculates std error and 95% confidence intervals
mlPerfAll10k_Allcancer_Scrambled_Raw_VSNM <- read.csv("Interim_data/rep_perfFungi_10k_rep1_tcga_scrambled_and_shuffled_controls_ALL_DecontamV2_4Apr22.csv", stringsAsFactors = FALSE)
abbreviationsTCGA_Allcancer <- read.csv("Supporting_data/tcga_abbreviations.csv", stringsAsFactors = FALSE, row.names = 1)
mlPerfAll10k_Allcancer_Scrambled_Raw_VSNM$abbrev <- abbreviationsTCGA_Allcancer[mlPerfAll10k_Allcancer_Scrambled_Raw_VSNM$diseaseType,"abbrev"]
mlPerfAll10k_Allcancer_Scrambled_Raw_VSNM <- mlPerfAll10k_Allcancer_Scrambled_Raw_VSNM[,!(colnames(mlPerfAll10k_Allcancer_Scrambled_Raw_VSNM) == "X")]
colnames(mlPerfAll10k_Allcancer_Scrambled_Raw_VSNM)[1:2] <- c("AUROC","AUPR")
# Add null perf values. Note: AUPR null is prevalence of **positive class**
# For 1-vs-all-others, prevalence is (minority class)/(total samples)
# For PT vs. NAT, prevalence is (majority class [PT])/(total samples)
mlPerfAll10k_Allcancer_Scrambled_Raw_VSNM$nullAUPR <- ifelse(mlPerfAll10k_Allcancer_Scrambled_Raw_VSNM$minorityClassName == "SolidTissueNormal",
yes=mlPerfAll10k_Allcancer_Scrambled_Raw_VSNM$majorityClassSize/(mlPerfAll10k_Allcancer_Scrambled_Raw_VSNM$minorityClassSize+mlPerfAll10k_Allcancer_Scrambled_Raw_VSNM$majorityClassSize),
no=mlPerfAll10k_Allcancer_Scrambled_Raw_VSNM$minorityClassSize/(mlPerfAll10k_Allcancer_Scrambled_Raw_VSNM$minorityClassSize+mlPerfAll10k_Allcancer_Scrambled_Raw_VSNM$majorityClassSize))
mlPerfAll10k_Allcancer_Scrambled_Raw_VSNM$nullAUROC <- 0.5
# Rename entries in the "datasetName" column
table(mlPerfAll10k_Allcancer_Scrambled_Raw_VSNM$datasetName)
table(mlPerfAll10k_Allcancer_Scrambled_Raw_VSNM$metadataName)
mlPerfAll10k_Allcancer_Scrambled_Raw_VSNM$datasetName[mlPerfAll10k_Allcancer_Scrambled_Raw_VSNM$metadataName == "metaQiitaCombined_Nonzero_DecontamV2_HMS_scrambled"] <- "HMS metadata labels scrambled (WGS)"
mlPerfAll10k_Allcancer_Scrambled_Raw_VSNM$datasetName[mlPerfAll10k_Allcancer_Scrambled_Raw_VSNM$metadataName == "metaQiitaCombined_Nonzero_DecontamV2_HMS_shuffled"] <- "HMS count data shuffled (WGS)"
mlPerfAll10k_Allcancer_Scrambled_Raw_VSNM$datasetName[mlPerfAll10k_Allcancer_Scrambled_Raw_VSNM$metadataName == "metaQiitaCombined_Nonzero_DecontamV2_MDA_scrambled"] <- "MDA metadata labels scrambled (WGS)"
mlPerfAll10k_Allcancer_Scrambled_Raw_VSNM$datasetName[mlPerfAll10k_Allcancer_Scrambled_Raw_VSNM$metadataName == "metaQiitaCombined_Nonzero_DecontamV2_MDA_shuffled"] <- "MDA count data shuffled (WGS)"
mlPerfAll10k_Allcancer_Scrambled_Raw_VSNM$datasetName[mlPerfAll10k_Allcancer_Scrambled_Raw_VSNM$metadataName == "metaQiitaCombined_Nonzero_DecontamV2_BCM_scrambled"] <- "BCM metadata labels scrambled (WGS)"
mlPerfAll10k_Allcancer_Scrambled_Raw_VSNM$datasetName[mlPerfAll10k_Allcancer_Scrambled_Raw_VSNM$metadataName == "metaQiitaCombined_Nonzero_DecontamV2_BCM_shuffled"] <- "BCM count data shuffled (WGS)"
mlPerfAll10k_Allcancer_Scrambled_Raw_VSNM$datasetName[mlPerfAll10k_Allcancer_Scrambled_Raw_VSNM$metadataName == "metaQiitaCombined_Nonzero_DecontamV2_WashU_scrambled"] <- "WashU metadata labels scrambled (WGS)"
mlPerfAll10k_Allcancer_Scrambled_Raw_VSNM$datasetName[mlPerfAll10k_Allcancer_Scrambled_Raw_VSNM$metadataName == "metaQiitaCombined_Nonzero_DecontamV2_WashU_shuffled"] <- "WashU count data shuffled (WGS)"
mlPerfAll10k_Allcancer_Scrambled_Raw_VSNM$datasetName[mlPerfAll10k_Allcancer_Scrambled_Raw_VSNM$metadataName == "metaQiitaCombined_Nonzero_DecontamV2_Broad_WGS_scrambled"] <- "Broad metadata labels scrambled (WGS)"
mlPerfAll10k_Allcancer_Scrambled_Raw_VSNM$datasetName[mlPerfAll10k_Allcancer_Scrambled_Raw_VSNM$metadataName == "metaQiitaCombined_Nonzero_DecontamV2_Broad_WGS_shuffled"] <- "Broad count data shuffled (WGS)"
mlPerfAll10k_Allcancer_Scrambled_Raw_VSNM$datasetName[mlPerfAll10k_Allcancer_Scrambled_Raw_VSNM$metadataName == "metaQiitaCombined_Nonzero_DecontamV2_UNC_scrambled"] <- "UNC metadata labels scrambled (RNA-Seq)"
mlPerfAll10k_Allcancer_Scrambled_Raw_VSNM$datasetName[mlPerfAll10k_Allcancer_Scrambled_Raw_VSNM$metadataName == "metaQiitaCombined_Nonzero_DecontamV2_UNC_shuffled"] <- "UNC count data shuffled (RNA-Seq)"
mlPerfAll10k_Allcancer_Scrambled_Raw_VSNM$datasetName[mlPerfAll10k_Allcancer_Scrambled_Raw_VSNM$metadataName == "metaQiitaCombined_Nonzero_DecontamV2_CMS_scrambled"] <- "CMS metadata labels scrambled (RNA-Seq)"
mlPerfAll10k_Allcancer_Scrambled_Raw_VSNM$datasetName[mlPerfAll10k_Allcancer_Scrambled_Raw_VSNM$metadataName == "metaQiitaCombined_Nonzero_DecontamV2_CMS_shuffled"] <- "CMS count data shuffled (RNA-Seq)"
## NOTE: Broad_RNA only included GBM tumors, so no ML comparisons were made
mlPerfAll10k_Allcancer_Scrambled_Raw_VSNM$datasetName[mlPerfAll10k_Allcancer_Scrambled_Raw_VSNM$metadataName == "metaQiitaCombined_Nonzero_DecontamV2_scrambled"] <- "VSNM all metadata labels scrambled (WGS+RNA-Seq)"
mlPerfAll10k_Allcancer_Scrambled_Raw_VSNM$datasetName[mlPerfAll10k_Allcancer_Scrambled_Raw_VSNM$metadataName == "metaQiitaCombined_Nonzero_DecontamV2_shuffled"] <- "VSNM all count data shuffled (WGS+RNA-Seq)"
mlPerfAll10k_Allcancer_Scrambled_Raw_VSNM$datasetName <- factor(mlPerfAll10k_Allcancer_Scrambled_Raw_VSNM$datasetName,
levels = c("VSNM all metadata labels scrambled (WGS+RNA-Seq)",
"VSNM all count data shuffled (WGS+RNA-Seq)",
"HMS metadata labels scrambled (WGS)",
"HMS count data shuffled (WGS)",
"MDA metadata labels scrambled (WGS)",
"MDA count data shuffled (WGS)",
"BCM metadata labels scrambled (WGS)",
"BCM count data shuffled (WGS)",
"WashU metadata labels scrambled (WGS)",
"WashU count data shuffled (WGS)",
"Broad metadata labels scrambled (WGS)",
"Broad count data shuffled (WGS)",
"UNC metadata labels scrambled (RNA-Seq)",
"UNC count data shuffled (RNA-Seq)",
"CMS metadata labels scrambled (RNA-Seq)",
"CMS count data shuffled (RNA-Seq)"))
table(mlPerfAll10k_Allcancer_Scrambled_Raw_VSNM$datasetName)
#-------------------------Plot primary tumor 1 vs. all others performance-------------------------#
# HMS
mlPerfAll10k_Allcancer_Scrambled_Raw_VSNM %>%
filter(sampleType == "Primary Tumor") %>%
filter(grepl("HMS",datasetName)) %>%
distinct() %>% droplevels() %>%
reshape2::melt(id.vars = c("rep","abbrev","diseaseType","sampleType","datasetName","metadataName","minorityClassSize","majorityClassSize","minorityClassName","majorityClassName","nullAUPR","nullAUROC")) %>%
summarySE(measurevar = "value", groupvars = c("datasetName","metadataName","variable","abbrev","minorityClassSize","majorityClassSize","minorityClassName","majorityClassName","nullAUPR","nullAUROC")) %>%
mutate(nullAUPR = ifelse(variable=="AUROC",NA,nullAUPR), nullAUROC = ifelse(variable=="AUPR",NA,nullAUROC)) %>%
ggplot(aes(reorder(abbrev, value, FUN=median),value, color=datasetName)) +
geom_errorbar(aes(ymin=ifelse(value-ci<0,0,value-ci), ymax=ifelse(value+ci>1,1,value+ci)),width=0.4,size=0.6,position = position_dodge(0.9)) +
geom_errorbar(aes(y=nullAUPR,ymin=nullAUPR,ymax=nullAUPR),color="darkgray",lty="dotted",position = position_dodge(0.9)) +
geom_errorbar(aes(y=nullAUROC,ymin=nullAUROC,ymax=nullAUROC),color="darkgray",lty="dotted",position = position_dodge(0.9)) +
geom_point(position = position_dodge(0.9), size=1.5) + xlab("Cancer type") + ylab("Area Under Curve") + theme_pubr() +
facet_wrap(~variable) +
scale_y_continuous(breaks = seq(0, 1, by = 0.1), limits = c(0,1)) +
ggtitle("Harvard Medical School (WGS) | Raw Data | Primary Tumor | 1 Vs All\nScrambled & Shuffled Controls") + theme(plot.title = element_text(hjust = 0.5)) +
rotate_x_text(90) + scale_color_nejm(name = "Features") + geom_hline(yintercept = 1, linetype="dashed")
ggsave("Figures/Other_Figures/control_v2_scrambled_mlPerfAll10k_rep1_HMS_PT_species_decontamV2.pdf", dpi = "retina",
width = 6, height = 4, units = "in")
# MDA
mlPerfAll10k_Allcancer_Scrambled_Raw_VSNM %>%
filter(sampleType == "Primary Tumor") %>%
filter(grepl("MDA",datasetName)) %>%
distinct() %>% droplevels() %>%
reshape2::melt(id.vars = c("rep","abbrev","diseaseType","sampleType","datasetName","metadataName","minorityClassSize","majorityClassSize","minorityClassName","majorityClassName","nullAUPR","nullAUROC")) %>%
summarySE(measurevar = "value", groupvars = c("datasetName","metadataName","variable","abbrev","minorityClassSize","majorityClassSize","minorityClassName","majorityClassName","nullAUPR","nullAUROC")) %>%
mutate(nullAUPR = ifelse(variable=="AUROC",NA,nullAUPR), nullAUROC = ifelse(variable=="AUPR",NA,nullAUROC)) %>%
ggplot(aes(reorder(abbrev, value, FUN=median),value, color=datasetName)) +
geom_errorbar(aes(ymin=ifelse(value-ci<0,0,value-ci), ymax=ifelse(value+ci>1,1,value+ci)),width=0.4,size=0.6,position = position_dodge(0.9)) +
geom_errorbar(aes(y=nullAUPR,ymin=nullAUPR,ymax=nullAUPR),color="darkgray",lty="dotted",position = position_dodge(0.9)) +
geom_errorbar(aes(y=nullAUROC,ymin=nullAUROC,ymax=nullAUROC),color="darkgray",lty="dotted",position = position_dodge(0.9)) +
geom_point(position = position_dodge(0.9), size=1.5) + xlab("Cancer type") + ylab("Area Under Curve") + theme_pubr() +
facet_wrap(~variable) +
scale_y_continuous(breaks = seq(0, 1, by = 0.1), limits = c(0,1)) +
ggtitle("MD Anderson (WGS) | Raw Data | Primary Tumor | 1 Vs All\nScrambled & Shuffled Controls") + theme(plot.title = element_text(hjust = 0.5)) +
rotate_x_text(90) + scale_color_nejm(name = "Features") + geom_hline(yintercept = 1, linetype="dashed")
ggsave("Figures/Other_Figures/control_v2_scrambled_mlPerfAll10k_rep1_MDA_PT_species_decontamV2.pdf", dpi = "retina",
width = 6, height = 4, units = "in")
# BCM
mlPerfAll10k_Allcancer_Scrambled_Raw_VSNM %>%
filter(sampleType == "Primary Tumor") %>%
filter(grepl("BCM",datasetName)) %>%
distinct() %>% droplevels() %>%
reshape2::melt(id.vars = c("rep","abbrev","diseaseType","sampleType","datasetName","metadataName","minorityClassSize","majorityClassSize","minorityClassName","majorityClassName","nullAUPR","nullAUROC")) %>%
summarySE(measurevar = "value", groupvars = c("datasetName","metadataName","variable","abbrev","minorityClassSize","majorityClassSize","minorityClassName","majorityClassName","nullAUPR","nullAUROC")) %>%
mutate(nullAUPR = ifelse(variable=="AUROC",NA,nullAUPR), nullAUROC = ifelse(variable=="AUPR",NA,nullAUROC)) %>%
ggplot(aes(reorder(abbrev, value, FUN=median),value, color=datasetName)) +
geom_errorbar(aes(ymin=ifelse(value-ci<0,0,value-ci), ymax=ifelse(value+ci>1,1,value+ci)),width=0.4,size=0.6,position = position_dodge(0.9)) +
geom_errorbar(aes(y=nullAUPR,ymin=nullAUPR,ymax=nullAUPR),color="darkgray",lty="dotted",position = position_dodge(0.9)) +
geom_errorbar(aes(y=nullAUROC,ymin=nullAUROC,ymax=nullAUROC),color="darkgray",lty="dotted",position = position_dodge(0.9)) +
geom_point(position = position_dodge(0.9), size=1.5) + xlab("Cancer type") + ylab("Area Under Curve") + theme_pubr() +
facet_wrap(~variable) +
scale_y_continuous(breaks = seq(0, 1, by = 0.1), limits = c(0,1)) +
ggtitle("Baylor College of Medicine (WGS) | Raw Data | Primary Tumor | 1 Vs All\nScrambled & Shuffled Controls") + theme(plot.title = element_text(hjust = 0.5)) +
rotate_x_text(90) + scale_color_nejm(name = "Features") + geom_hline(yintercept = 1, linetype="dashed")
ggsave("Figures/Other_Figures/control_v2_scrambled_mlPerfAll10k_rep1_BCM_PT_species_decontamV2.pdf", dpi = "retina",
width = 6, height = 4, units = "in")
# WashU
mlPerfAll10k_Allcancer_Scrambled_Raw_VSNM %>%
filter(sampleType == "Primary Tumor") %>%
filter(grepl("WashU",datasetName)) %>%
distinct() %>% droplevels() %>%
reshape2::melt(id.vars = c("rep","abbrev","diseaseType","sampleType","datasetName","metadataName","minorityClassSize","majorityClassSize","minorityClassName","majorityClassName","nullAUPR","nullAUROC")) %>%
summarySE(measurevar = "value", groupvars = c("datasetName","metadataName","variable","abbrev","minorityClassSize","majorityClassSize","minorityClassName","majorityClassName","nullAUPR","nullAUROC")) %>%
mutate(nullAUPR = ifelse(variable=="AUROC",NA,nullAUPR), nullAUROC = ifelse(variable=="AUPR",NA,nullAUROC)) %>%
ggplot(aes(reorder(abbrev, value, FUN=median),value, color=datasetName)) +
geom_errorbar(aes(ymin=ifelse(value-ci<0,0,value-ci), ymax=ifelse(value+ci>1,1,value+ci)),width=0.4,size=0.6,position = position_dodge(0.9)) +
geom_errorbar(aes(y=nullAUPR,ymin=nullAUPR,ymax=nullAUPR),color="darkgray",lty="dotted",position = position_dodge(0.9)) +
geom_errorbar(aes(y=nullAUROC,ymin=nullAUROC,ymax=nullAUROC),color="darkgray",lty="dotted",position = position_dodge(0.9)) +
geom_point(position = position_dodge(0.9), size=1.5) + xlab("Cancer type") + ylab("Area Under Curve") + theme_pubr() +
facet_wrap(~variable) +
scale_y_continuous(breaks = seq(0, 1, by = 0.1), limits = c(0,1)) +
ggtitle("Washington University (WGS) | Raw Data | Primary Tumor | 1 Vs All\nScrambled & Shuffled Controls") + theme(plot.title = element_text(hjust = 0.5)) +
rotate_x_text(90) + scale_color_nejm(name = "Features") + geom_hline(yintercept = 1, linetype="dashed")
ggsave("Figures/Other_Figures/control_v2_scrambled_mlPerfAll10k_rep1_WashU_PT_species_decontamV2.pdf", dpi = "retina",
width = 5, height = 4, units = "in")
# Broad WGS
mlPerfAll10k_Allcancer_Scrambled_Raw_VSNM %>%
filter(sampleType == "Primary Tumor") %>%
filter(grepl("Broad",datasetName)) %>%
distinct() %>% droplevels() %>%
reshape2::melt(id.vars = c("rep","abbrev","diseaseType","sampleType","datasetName","metadataName","minorityClassSize","majorityClassSize","minorityClassName","majorityClassName","nullAUPR","nullAUROC")) %>%
summarySE(measurevar = "value", groupvars = c("datasetName","metadataName","variable","abbrev","minorityClassSize","majorityClassSize","minorityClassName","majorityClassName","nullAUPR","nullAUROC")) %>%
mutate(nullAUPR = ifelse(variable=="AUROC",NA,nullAUPR), nullAUROC = ifelse(variable=="AUPR",NA,nullAUROC)) %>%
ggplot(aes(reorder(abbrev, value, FUN=median),value, color=datasetName)) +
geom_errorbar(aes(ymin=ifelse(value-ci<0,0,value-ci), ymax=ifelse(value+ci>1,1,value+ci)),width=0.4,size=0.6,position = position_dodge(0.9)) +
geom_errorbar(aes(y=nullAUPR,ymin=nullAUPR,ymax=nullAUPR),color="darkgray",lty="dotted",position = position_dodge(0.9)) +
geom_errorbar(aes(y=nullAUROC,ymin=nullAUROC,ymax=nullAUROC),color="darkgray",lty="dotted",position = position_dodge(0.9)) +
geom_point(position = position_dodge(0.9), size=1.5) + xlab("Cancer type") + ylab("Area Under Curve") + theme_pubr() +
facet_wrap(~variable) +
scale_y_continuous(breaks = seq(0, 1, by = 0.1), limits = c(0,1)) +
ggtitle("Broad Institute (WGS) | Raw Data | Primary Tumor | 1 Vs All\nScrambled & Shuffled Controls") + theme(plot.title = element_text(hjust = 0.5)) +
rotate_x_text(90) + scale_color_nejm(name = "Features") + geom_hline(yintercept = 1, linetype="dashed")
ggsave("Figures/Other_Figures/control_v2_scrambled_mlPerfAll10k_rep1_Broad_WGS_PT_species_decontamV2.pdf", dpi = "retina",
width = 6, height = 4, units = "in")
# UNC
mlPerfAll10k_Allcancer_Scrambled_Raw_VSNM %>%
filter(sampleType == "Primary Tumor") %>%
filter(grepl("UNC",datasetName)) %>%
distinct() %>% droplevels() %>%
reshape2::melt(id.vars = c("rep","abbrev","diseaseType","sampleType","datasetName","metadataName","minorityClassSize","majorityClassSize","minorityClassName","majorityClassName","nullAUPR","nullAUROC")) %>%
summarySE(measurevar = "value", groupvars = c("datasetName","metadataName","variable","abbrev","minorityClassSize","majorityClassSize","minorityClassName","majorityClassName","nullAUPR","nullAUROC")) %>%
mutate(nullAUPR = ifelse(variable=="AUROC",NA,nullAUPR), nullAUROC = ifelse(variable=="AUPR",NA,nullAUROC)) %>%
ggplot(aes(reorder(abbrev, value, FUN=median),value, color=datasetName)) +
geom_errorbar(aes(ymin=ifelse(value-ci<0,0,value-ci), ymax=ifelse(value+ci>1,1,value+ci)),width=0.4,size=0.6,position = position_dodge(0.9)) +
geom_errorbar(aes(y=nullAUPR,ymin=nullAUPR,ymax=nullAUPR),color="darkgray",lty="dotted",position = position_dodge(0.9)) +
geom_errorbar(aes(y=nullAUROC,ymin=nullAUROC,ymax=nullAUROC),color="darkgray",lty="dotted",position = position_dodge(0.9)) +
geom_point(position = position_dodge(0.9), size=1.5) + xlab("Cancer type") + ylab("Area Under Curve") + theme_pubr() +
facet_wrap(~variable) +
scale_y_continuous(breaks = seq(0, 1, by = 0.1), limits = c(0,1)) +
ggtitle("University of North Carolina (RNA-Seq) | Raw Data | Primary Tumor | 1 Vs All\nScrambled & Shuffled Controls") + theme(plot.title = element_text(hjust = 0.5)) +
rotate_x_text(90) + scale_color_nejm(name = "Features") + geom_hline(yintercept = 1, linetype="dashed")
ggsave("Figures/Other_Figures/control_v2_scrambled_mlPerfAll10k_rep1_UNC_PT_species_decontamV2.pdf", dpi = "retina",
width = 8, height = 4, units = "in")
# CMS
mlPerfAll10k_Allcancer_Scrambled_Raw_VSNM %>%
filter(sampleType == "Primary Tumor") %>%
filter(grepl("CMS",datasetName)) %>%
distinct() %>% droplevels() %>%
reshape2::melt(id.vars = c("rep","abbrev","diseaseType","sampleType","datasetName","metadataName","minorityClassSize","majorityClassSize","minorityClassName","majorityClassName","nullAUPR","nullAUROC")) %>%
summarySE(measurevar = "value", groupvars = c("datasetName","metadataName","variable","abbrev","minorityClassSize","majorityClassSize","minorityClassName","majorityClassName","nullAUPR","nullAUROC")) %>%
mutate(nullAUPR = ifelse(variable=="AUROC",NA,nullAUPR), nullAUROC = ifelse(variable=="AUPR",NA,nullAUROC)) %>%
ggplot(aes(reorder(abbrev, value, FUN=median),value, color=datasetName)) +
geom_errorbar(aes(ymin=ifelse(value-ci<0,0,value-ci), ymax=ifelse(value+ci>1,1,value+ci)),width=0.4,size=0.6,position = position_dodge(0.9)) +
geom_errorbar(aes(y=nullAUPR,ymin=nullAUPR,ymax=nullAUPR),color="darkgray",lty="dotted",position = position_dodge(0.9)) +
geom_errorbar(aes(y=nullAUROC,ymin=nullAUROC,ymax=nullAUROC),color="darkgray",lty="dotted",position = position_dodge(0.9)) +
geom_point(position = position_dodge(0.9), size=1.5) + xlab("Cancer type") + ylab("Area Under Curve") + theme_pubr() +
facet_wrap(~variable) +
scale_y_continuous(breaks = seq(0, 1, by = 0.1), limits = c(0,1)) +
ggtitle("Canada's Michael Smith Genome Sciences Centre (RNA-Seq) | Raw Data | Primary Tumor | 1 Vs All\nScrambled & Shuffled Controls") + theme(plot.title = element_text(hjust = 0.5)) +
rotate_x_text(90) + scale_color_nejm(name = "Features") + geom_hline(yintercept = 1, linetype="dashed")
ggsave("Figures/Other_Figures/control_v2_scrambled_mlPerfAll10k_rep1_CMS_PT_species_decontamV2.pdf", dpi = "retina",
width = 6, height = 4, units = "in")
# Full dataset
mlPerfAll10k_Allcancer_Scrambled_Raw_VSNM %>%
filter(sampleType == "Primary Tumor") %>%
filter(grepl("VSNM",datasetName)) %>%
distinct() %>% droplevels() %>%
reshape2::melt(id.vars = c("rep","abbrev","diseaseType","sampleType","datasetName","metadataName","minorityClassSize","majorityClassSize","minorityClassName","majorityClassName","nullAUPR","nullAUROC")) %>%
summarySE(measurevar = "value", groupvars = c("datasetName","metadataName","variable","abbrev","minorityClassSize","majorityClassSize","minorityClassName","majorityClassName","nullAUPR","nullAUROC")) %>%
mutate(nullAUPR = ifelse(variable=="AUROC",NA,nullAUPR), nullAUROC = ifelse(variable=="AUPR",NA,nullAUROC)) %>%
ggplot(aes(reorder(abbrev, value, FUN=median),value, color=datasetName)) +
geom_errorbar(aes(ymin=ifelse(value-ci<0,0,value-ci), ymax=ifelse(value+ci>1,1,value+ci)),width=0.4,size=0.6,position = position_dodge(0.9)) +
geom_errorbar(aes(y=nullAUPR,ymin=nullAUPR,ymax=nullAUPR),color="darkgray",lty="dotted",position = position_dodge(0.9)) +
geom_errorbar(aes(y=nullAUROC,ymin=nullAUROC,ymax=nullAUROC),color="darkgray",lty="dotted",position = position_dodge(0.9)) +
geom_point(position = position_dodge(0.9), size=1.5) + xlab("Cancer type") + ylab("Area Under Curve") + theme_pubr() +
facet_wrap(~variable) +
scale_y_continuous(breaks = seq(0, 1, by = 0.1), limits = c(0,1)) +
ggtitle("Full dataset (WGS+RNA-Seq) | Voom-SNM | Primary Tumor | 1 Vs All\nScrambled & Shuffled Controls") + theme(plot.title = element_text(hjust = 0.5)) +
rotate_x_text(90) + scale_color_nejm(name = "Features") + geom_hline(yintercept = 1, linetype="dashed")
ggsave("Figures/Other_Figures/control_v2_scrambled_mlPerfAll10k_rep1_TCGA_VSNM_PT_species_decontamV2.pdf", dpi = "retina",
width = 6, height = 4, units = "in")
#-------------------------Plot primary tumor vs. NAT performance-------------------------#
# HMS
mlPerfAll10k_Allcancer_Scrambled_Raw_VSNM %>%
filter(sampleType == "Primary Tumor vs Solid Tissue Normal") %>%
filter(grepl("HMS",datasetName)) %>%
distinct() %>% droplevels() %>%
reshape2::melt(id.vars = c("rep","abbrev","diseaseType","sampleType","datasetName","metadataName","minorityClassSize","majorityClassSize","minorityClassName","majorityClassName","nullAUPR","nullAUROC")) %>%
summarySE(measurevar = "value", groupvars = c("datasetName","metadataName","variable","abbrev","minorityClassSize","majorityClassSize","minorityClassName","majorityClassName","nullAUPR","nullAUROC")) %>%
mutate(nullAUPR = ifelse(variable=="AUROC",NA,nullAUPR), nullAUROC = ifelse(variable=="AUPR",NA,nullAUROC)) %>%
ggplot(aes(reorder(abbrev, value, FUN=median),value, color=datasetName)) +
geom_errorbar(aes(ymin=ifelse(value-ci<0,0,value-ci), ymax=ifelse(value+ci>1,1,value+ci)),width=0.4,size=0.6,position = position_dodge(0.9)) +
geom_errorbar(aes(y=nullAUPR,ymin=nullAUPR,ymax=nullAUPR),color="darkgray",lty="dotted",position = position_dodge(0.9)) +
geom_errorbar(aes(y=nullAUROC,ymin=nullAUROC,ymax=nullAUROC),color="darkgray",lty="dotted",position = position_dodge(0.9)) +
geom_point(position = position_dodge(0.9), size=1.5) + xlab("Cancer type") + ylab("Area Under Curve") + theme_pubr() +
facet_wrap(~variable) +
scale_y_continuous(breaks = seq(0, 1, by = 0.1), limits = c(0,1)) +
ggtitle("Harvard Medical School (WGS) | Raw Data | Primary Tumor vs Solid Tissue Normal\nScrambled & Shuffled Controls") + theme(plot.title = element_text(hjust = 0.5)) +
rotate_x_text(90) + scale_color_nejm(name = "Features") + geom_hline(yintercept = 1, linetype="dashed")
ggsave("Figures/Other_Figures/control_v2_scrambled_mlPerfAll10k_rep1_HMS_PT_vs_NAT_species_decontamV2.pdf", dpi = "retina",
width = 6, height = 4, units = "in")
# MDA does not have sufficient PT and NAT samples to compare
# BCM
mlPerfAll10k_Allcancer_Scrambled_Raw_VSNM %>%
filter(sampleType == "Primary Tumor vs Solid Tissue Normal") %>%
filter(grepl("BCM",datasetName)) %>%
distinct() %>% droplevels() %>%
reshape2::melt(id.vars = c("rep","abbrev","diseaseType","sampleType","datasetName","metadataName","minorityClassSize","majorityClassSize","minorityClassName","majorityClassName","nullAUPR","nullAUROC")) %>%
summarySE(measurevar = "value", groupvars = c("datasetName","metadataName","variable","abbrev","minorityClassSize","majorityClassSize","minorityClassName","majorityClassName","nullAUPR","nullAUROC")) %>%
mutate(nullAUPR = ifelse(variable=="AUROC",NA,nullAUPR), nullAUROC = ifelse(variable=="AUPR",NA,nullAUROC)) %>%
ggplot(aes(reorder(abbrev, value, FUN=median),value, color=datasetName)) +
geom_errorbar(aes(ymin=ifelse(value-ci<0,0,value-ci), ymax=ifelse(value+ci>1,1,value+ci)),width=0.4,size=0.6,position = position_dodge(0.9)) +
geom_errorbar(aes(y=nullAUPR,ymin=nullAUPR,ymax=nullAUPR),color="darkgray",lty="dotted",position = position_dodge(0.9)) +
geom_errorbar(aes(y=nullAUROC,ymin=nullAUROC,ymax=nullAUROC),color="darkgray",lty="dotted",position = position_dodge(0.9)) +
geom_point(position = position_dodge(0.9), size=1.5) + xlab("Cancer type") + ylab("Area Under Curve") + theme_pubr() +
facet_wrap(~variable) +
scale_y_continuous(breaks = seq(0, 1, by = 0.1), limits = c(0,1)) +
ggtitle("Baylor College of Medicine (WGS) | Raw Data | Primary Tumor vs Solid Tissue Normal\nScrambled & Shuffled Controls") + theme(plot.title = element_text(hjust = 0.5)) +
rotate_x_text(90) + scale_color_nejm(name = "Features") + geom_hline(yintercept = 1, linetype="dashed")
ggsave("Figures/Other_Figures/control_v2_scrambled_mlPerfAll10k_rep1_BCM_PT_vs_NAT_species_decontamV2.pdf", dpi = "retina",
width = 6, height = 4, units = "in")
# WashU does not have sufficient PT and NAT samples to compare
# Broad WGS
mlPerfAll10k_Allcancer_Scrambled_Raw_VSNM %>%
filter(sampleType == "Primary Tumor vs Solid Tissue Normal") %>%
filter(grepl("Broad",datasetName)) %>%
distinct() %>% droplevels() %>%
reshape2::melt(id.vars = c("rep","abbrev","diseaseType","sampleType","datasetName","metadataName","minorityClassSize","majorityClassSize","minorityClassName","majorityClassName","nullAUPR","nullAUROC")) %>%
summarySE(measurevar = "value", groupvars = c("datasetName","metadataName","variable","abbrev","minorityClassSize","majorityClassSize","minorityClassName","majorityClassName","nullAUPR","nullAUROC")) %>%
mutate(nullAUPR = ifelse(variable=="AUROC",NA,nullAUPR), nullAUROC = ifelse(variable=="AUPR",NA,nullAUROC)) %>%
ggplot(aes(reorder(abbrev, value, FUN=median),value, color=datasetName)) +
geom_errorbar(aes(ymin=ifelse(value-ci<0,0,value-ci), ymax=ifelse(value+ci>1,1,value+ci)),width=0.4,size=0.6,position = position_dodge(0.9)) +
geom_errorbar(aes(y=nullAUPR,ymin=nullAUPR,ymax=nullAUPR),color="darkgray",lty="dotted",position = position_dodge(0.9)) +
geom_errorbar(aes(y=nullAUROC,ymin=nullAUROC,ymax=nullAUROC),color="darkgray",lty="dotted",position = position_dodge(0.9)) +
geom_point(position = position_dodge(0.9), size=1.5) + xlab("Cancer type") + ylab("Area Under Curve") + theme_pubr() +
facet_wrap(~variable) +
scale_y_continuous(breaks = seq(0, 1, by = 0.1), limits = c(0,1)) +
ggtitle("Broad Institute (WGS) | Raw Data | Primary Tumor vs Solid Tissue Normal\nScrambled & Shuffled Controls") + theme(plot.title = element_text(hjust = 0.5)) +
rotate_x_text(90) + scale_color_nejm(name = "Features") + geom_hline(yintercept = 1, linetype="dashed")
ggsave("Figures/Other_Figures/control_v2_scrambled_mlPerfAll10k_rep1_Broad_WGS_PT_vs_NAT_species_decontamV2.pdf", dpi = "retina",
width = 6, height = 4, units = "in")
# UNC
mlPerfAll10k_Allcancer_Scrambled_Raw_VSNM %>%
filter(sampleType == "Primary Tumor vs Solid Tissue Normal") %>%
filter(grepl("UNC",datasetName)) %>%
distinct() %>% droplevels() %>%
reshape2::melt(id.vars = c("rep","abbrev","diseaseType","sampleType","datasetName","metadataName","minorityClassSize","majorityClassSize","minorityClassName","majorityClassName","nullAUPR","nullAUROC")) %>%
summarySE(measurevar = "value", groupvars = c("datasetName","metadataName","variable","abbrev","minorityClassSize","majorityClassSize","minorityClassName","majorityClassName","nullAUPR","nullAUROC")) %>%
mutate(nullAUPR = ifelse(variable=="AUROC",NA,nullAUPR), nullAUROC = ifelse(variable=="AUPR",NA,nullAUROC)) %>%
ggplot(aes(reorder(abbrev, value, FUN=median),value, color=datasetName)) +
geom_errorbar(aes(ymin=ifelse(value-ci<0,0,value-ci), ymax=ifelse(value+ci>1,1,value+ci)),width=0.4,size=0.6,position = position_dodge(0.9)) +
geom_errorbar(aes(y=nullAUPR,ymin=nullAUPR,ymax=nullAUPR),color="darkgray",lty="dotted",position = position_dodge(0.9)) +
geom_errorbar(aes(y=nullAUROC,ymin=nullAUROC,ymax=nullAUROC),color="darkgray",lty="dotted",position = position_dodge(0.9)) +
geom_point(position = position_dodge(0.9), size=1.5) + xlab("Cancer type") + ylab("Area Under Curve") + theme_pubr() +
facet_wrap(~variable) +
scale_y_continuous(breaks = seq(0, 1, by = 0.1), limits = c(0,1)) +
ggtitle("University of North Carolina (RNA-Seq) | Raw Data | Primary Tumor vs Solid Tissue Normal\nScrambled & Shuffled Controls") + theme(plot.title = element_text(hjust = 0.5)) +
rotate_x_text(90) + scale_color_nejm(name = "Features") + geom_hline(yintercept = 1, linetype="dashed")
ggsave("Figures/Other_Figures/control_v2_scrambled_mlPerfAll10k_rep1_UNC_PT_vs_NAT_species_decontamV2.pdf", dpi = "retina",
width = 8, height = 4, units = "in")
# CMS
mlPerfAll10k_Allcancer_Scrambled_Raw_VSNM %>%
filter(sampleType == "Primary Tumor vs Solid Tissue Normal") %>%
filter(grepl("CMS",datasetName)) %>%
distinct() %>% droplevels() %>%
reshape2::melt(id.vars = c("rep","abbrev","diseaseType","sampleType","datasetName","metadataName","minorityClassSize","majorityClassSize","minorityClassName","majorityClassName","nullAUPR","nullAUROC")) %>%
summarySE(measurevar = "value", groupvars = c("datasetName","metadataName","variable","abbrev","minorityClassSize","majorityClassSize","minorityClassName","majorityClassName","nullAUPR","nullAUROC")) %>%
mutate(nullAUPR = ifelse(variable=="AUROC",NA,nullAUPR), nullAUROC = ifelse(variable=="AUPR",NA,nullAUROC)) %>%
ggplot(aes(reorder(abbrev, value, FUN=median),value, color=datasetName)) +
geom_errorbar(aes(ymin=ifelse(value-ci<0,0,value-ci), ymax=ifelse(value+ci>1,1,value+ci)),width=0.4,size=0.6,position = position_dodge(0.9)) +
geom_errorbar(aes(y=nullAUPR,ymin=nullAUPR,ymax=nullAUPR),color="darkgray",lty="dotted",position = position_dodge(0.9)) +
geom_errorbar(aes(y=nullAUROC,ymin=nullAUROC,ymax=nullAUROC),color="darkgray",lty="dotted",position = position_dodge(0.9)) +
geom_point(position = position_dodge(0.9), size=1.5) + xlab("Cancer type") + ylab("Area Under Curve") + theme_pubr() +
facet_wrap(~variable) +
scale_y_continuous(breaks = seq(0, 1, by = 0.1), limits = c(0,1)) +
ggtitle("Canada's Michael Smith Genome Sciences Centre (RNA-Seq) | Raw Data | Primary Tumor vs Solid Tissue Normal\nScrambled & Shuffled Controls") + theme(plot.title = element_text(hjust = 0.5)) +
rotate_x_text(90) + scale_color_nejm(name = "Features") + geom_hline(yintercept = 1, linetype="dashed")
ggsave("Figures/Other_Figures/control_v2_scrambled_mlPerfAll10k_rep1_CMS_PT_vs_NAT_species_decontamV2.pdf", dpi = "retina",
width = 6, height = 4, units = "in")
# Full dataset
mlPerfAll10k_Allcancer_Scrambled_Raw_VSNM %>%
filter(sampleType == "Primary Tumor vs Solid Tissue Normal") %>%
filter(grepl("VSNM",datasetName)) %>%
distinct() %>% droplevels() %>%
reshape2::melt(id.vars = c("rep","abbrev","diseaseType","sampleType","datasetName","metadataName","minorityClassSize","majorityClassSize","minorityClassName","majorityClassName","nullAUPR","nullAUROC")) %>%
summarySE(measurevar = "value", groupvars = c("datasetName","metadataName","variable","abbrev","minorityClassSize","majorityClassSize","minorityClassName","majorityClassName","nullAUPR","nullAUROC")) %>%
mutate(nullAUPR = ifelse(variable=="AUROC",NA,nullAUPR), nullAUROC = ifelse(variable=="AUPR",NA,nullAUROC)) %>%
ggplot(aes(reorder(abbrev, value, FUN=median),value, color=datasetName)) +
geom_errorbar(aes(ymin=ifelse(value-ci<0,0,value-ci), ymax=ifelse(value+ci>1,1,value+ci)),width=0.4,size=0.6,position = position_dodge(0.9)) +
geom_errorbar(aes(y=nullAUPR,ymin=nullAUPR,ymax=nullAUPR),color="darkgray",lty="dotted",position = position_dodge(0.9)) +
geom_errorbar(aes(y=nullAUROC,ymin=nullAUROC,ymax=nullAUROC),color="darkgray",lty="dotted",position = position_dodge(0.9)) +
geom_point(position = position_dodge(0.9), size=1.5) + xlab("Cancer type") + ylab("Area Under Curve") + theme_pubr() +
facet_wrap(~variable) +
scale_y_continuous(breaks = seq(0, 1, by = 0.1), limits = c(0,1)) +
ggtitle("Full dataset (WGS+RNA-Seq) | Voom-SNM | Primary Tumor vs Solid Tissue Normal | 1 Vs All\nScrambled & Shuffled Controls") + theme(plot.title = element_text(hjust = 0.5)) +
rotate_x_text(90) + scale_color_nejm(name = "Features") + geom_hline(yintercept = 1, linetype="dashed")
ggsave("Figures/Other_Figures/control_v2_scrambled_mlPerfAll10k_rep1_TCGA_VSNM_PT_vs_NAT_species_decontamV2.pdf", dpi = "retina",
width = 6, height = 4, units = "in")
#-------------------------Plot blood derived normal 1 vs. all others performance-------------------------#
# HMS
mlPerfAll10k_Allcancer_Scrambled_Raw_VSNM %>%
filter(sampleType == "Blood Derived Normal") %>%
filter(grepl("HMS",datasetName)) %>%
distinct() %>% droplevels() %>%
reshape2::melt(id.vars = c("rep","abbrev","diseaseType","sampleType","datasetName","metadataName","minorityClassSize","majorityClassSize","minorityClassName","majorityClassName","nullAUPR","nullAUROC")) %>%
summarySE(measurevar = "value", groupvars = c("datasetName","metadataName","variable","abbrev","minorityClassSize","majorityClassSize","minorityClassName","majorityClassName","nullAUPR","nullAUROC")) %>%
mutate(nullAUPR = ifelse(variable=="AUROC",NA,nullAUPR), nullAUROC = ifelse(variable=="AUPR",NA,nullAUROC)) %>%
ggplot(aes(reorder(abbrev, value, FUN=median),value, color=datasetName)) +
geom_errorbar(aes(ymin=ifelse(value-ci<0,0,value-ci), ymax=ifelse(value+ci>1,1,value+ci)),width=0.4,size=0.6,position = position_dodge(0.9)) +
geom_errorbar(aes(y=nullAUPR,ymin=nullAUPR,ymax=nullAUPR),color="darkgray",lty="dotted",position = position_dodge(0.9)) +
geom_errorbar(aes(y=nullAUROC,ymin=nullAUROC,ymax=nullAUROC),color="darkgray",lty="dotted",position = position_dodge(0.9)) +
geom_point(position = position_dodge(0.9), size=1.5) + xlab("Cancer type") + ylab("Area Under Curve") + theme_pubr() +
facet_wrap(~variable) +
scale_y_continuous(breaks = seq(0, 1, by = 0.1), limits = c(0,1)) +
ggtitle("Harvard Medical School (WGS) | Raw Data | Blood Derived Normal | 1 Vs All\nScrambled & Shuffled Controls") + theme(plot.title = element_text(hjust = 0.5)) +
rotate_x_text(90) + scale_color_nejm(name = "Features") + geom_hline(yintercept = 1, linetype="dashed")
ggsave("Figures/Other_Figures/control_v2_scrambled_mlPerfAll10k_rep1_HMS_BDN_species_decontamV2.pdf", dpi = "retina",
width = 6, height = 4, units = "in")
# MDA
mlPerfAll10k_Allcancer_Scrambled_Raw_VSNM %>%
filter(sampleType == "Blood Derived Normal") %>%
filter(grepl("MDA",datasetName)) %>%
distinct() %>% droplevels() %>%
reshape2::melt(id.vars = c("rep","abbrev","diseaseType","sampleType","datasetName","metadataName","minorityClassSize","majorityClassSize","minorityClassName","majorityClassName","nullAUPR","nullAUROC")) %>%
summarySE(measurevar = "value", groupvars = c("datasetName","metadataName","variable","abbrev","minorityClassSize","majorityClassSize","minorityClassName","majorityClassName","nullAUPR","nullAUROC")) %>%
mutate(nullAUPR = ifelse(variable=="AUROC",NA,nullAUPR), nullAUROC = ifelse(variable=="AUPR",NA,nullAUROC)) %>%
ggplot(aes(reorder(abbrev, value, FUN=median),value, color=datasetName)) +
geom_errorbar(aes(ymin=ifelse(value-ci<0,0,value-ci), ymax=ifelse(value+ci>1,1,value+ci)),width=0.4,size=0.6,position = position_dodge(0.9)) +
geom_errorbar(aes(y=nullAUPR,ymin=nullAUPR,ymax=nullAUPR),color="darkgray",lty="dotted",position = position_dodge(0.9)) +
geom_errorbar(aes(y=nullAUROC,ymin=nullAUROC,ymax=nullAUROC),color="darkgray",lty="dotted",position = position_dodge(0.9)) +
geom_point(position = position_dodge(0.9), size=1.5) + xlab("Cancer type") + ylab("Area Under Curve") + theme_pubr() +
facet_wrap(~variable) +
scale_y_continuous(breaks = seq(0, 1, by = 0.1), limits = c(0,1)) +
ggtitle("MD Anderson (WGS) | Raw Data | Blood Derived Normal | 1 Vs All\nScrambled & Shuffled Controls") + theme(plot.title = element_text(hjust = 0.5)) +
rotate_x_text(90) + scale_color_nejm(name = "Features") + geom_hline(yintercept = 1, linetype="dashed")
ggsave("Figures/Other_Figures/control_v2_scrambled_mlPerfAll10k_rep1_MDA_BDN_species_decontamV2.pdf", dpi = "retina",
width = 6, height = 4, units = "in")
# BCM
mlPerfAll10k_Allcancer_Scrambled_Raw_VSNM %>%
filter(sampleType == "Blood Derived Normal") %>%
filter(grepl("BCM",datasetName)) %>%
distinct() %>% droplevels() %>%
reshape2::melt(id.vars = c("rep","abbrev","diseaseType","sampleType","datasetName","metadataName","minorityClassSize","majorityClassSize","minorityClassName","majorityClassName","nullAUPR","nullAUROC")) %>%
summarySE(measurevar = "value", groupvars = c("datasetName","metadataName","variable","abbrev","minorityClassSize","majorityClassSize","minorityClassName","majorityClassName","nullAUPR","nullAUROC")) %>%
mutate(nullAUPR = ifelse(variable=="AUROC",NA,nullAUPR), nullAUROC = ifelse(variable=="AUPR",NA,nullAUROC)) %>%
ggplot(aes(reorder(abbrev, value, FUN=median),value, color=datasetName)) +
geom_errorbar(aes(ymin=ifelse(value-ci<0,0,value-ci), ymax=ifelse(value+ci>1,1,value+ci)),width=0.4,size=0.6,position = position_dodge(0.9)) +
geom_errorbar(aes(y=nullAUPR,ymin=nullAUPR,ymax=nullAUPR),color="darkgray",lty="dotted",position = position_dodge(0.9)) +
geom_errorbar(aes(y=nullAUROC,ymin=nullAUROC,ymax=nullAUROC),color="darkgray",lty="dotted",position = position_dodge(0.9)) +
geom_point(position = position_dodge(0.9), size=1.5) + xlab("Cancer type") + ylab("Area Under Curve") + theme_pubr() +
facet_wrap(~variable) +
scale_y_continuous(breaks = seq(0, 1, by = 0.1), limits = c(0,1)) +
ggtitle("Baylor College of Medicine (WGS) | Raw Data | Blood Derived Normal | 1 Vs All\nScrambled & Shuffled Controls") + theme(plot.title = element_text(hjust = 0.5)) +
rotate_x_text(90) + scale_color_nejm(name = "Features") + geom_hline(yintercept = 1, linetype="dashed")
ggsave("Figures/Other_Figures/control_v2_scrambled_mlPerfAll10k_rep1_BCM_BDN_species_decontamV2.pdf", dpi = "retina",
width = 6, height = 4, units = "in")
# WashU
mlPerfAll10k_Allcancer_Scrambled_Raw_VSNM %>%
filter(sampleType == "Blood Derived Normal") %>%
filter(grepl("WashU",datasetName)) %>%
distinct() %>% droplevels() %>%
reshape2::melt(id.vars = c("rep","abbrev","diseaseType","sampleType","datasetName","metadataName","minorityClassSize","majorityClassSize","minorityClassName","majorityClassName","nullAUPR","nullAUROC")) %>%
summarySE(measurevar = "value", groupvars = c("datasetName","metadataName","variable","abbrev","minorityClassSize","majorityClassSize","minorityClassName","majorityClassName","nullAUPR","nullAUROC")) %>%
mutate(nullAUPR = ifelse(variable=="AUROC",NA,nullAUPR), nullAUROC = ifelse(variable=="AUPR",NA,nullAUROC)) %>%
ggplot(aes(reorder(abbrev, value, FUN=median),value, color=datasetName)) +
geom_errorbar(aes(ymin=ifelse(value-ci<0,0,value-ci), ymax=ifelse(value+ci>1,1,value+ci)),width=0.4,size=0.6,position = position_dodge(0.9)) +
geom_errorbar(aes(y=nullAUPR,ymin=nullAUPR,ymax=nullAUPR),color="darkgray",lty="dotted",position = position_dodge(0.9)) +
geom_errorbar(aes(y=nullAUROC,ymin=nullAUROC,ymax=nullAUROC),color="darkgray",lty="dotted",position = position_dodge(0.9)) +
geom_point(position = position_dodge(0.9), size=1.5) + xlab("Cancer type") + ylab("Area Under Curve") + theme_pubr() +
facet_wrap(~variable) +
scale_y_continuous(breaks = seq(0, 1, by = 0.1), limits = c(0,1)) +
ggtitle("Washington University (WGS) | Raw Data | Blood Derived Normal | 1 Vs All\nScrambled & Shuffled Controls") + theme(plot.title = element_text(hjust = 0.5)) +
rotate_x_text(90) + scale_color_nejm(name = "Features") + geom_hline(yintercept = 1, linetype="dashed")
ggsave("Figures/Other_Figures/control_v2_scrambled_mlPerfAll10k_rep1_WashU_BDN_species_decontamV2.pdf", dpi = "retina",
width = 5, height = 4, units = "in")
# Broad WGS
mlPerfAll10k_Allcancer_Scrambled_Raw_VSNM %>%
filter(sampleType == "Blood Derived Normal") %>%
filter(grepl("Broad",datasetName)) %>%
distinct() %>% droplevels() %>%
reshape2::melt(id.vars = c("rep","abbrev","diseaseType","sampleType","datasetName","metadataName","minorityClassSize","majorityClassSize","minorityClassName","majorityClassName","nullAUPR","nullAUROC")) %>%
summarySE(measurevar = "value", groupvars = c("datasetName","metadataName","variable","abbrev","minorityClassSize","majorityClassSize","minorityClassName","majorityClassName","nullAUPR","nullAUROC")) %>%
mutate(nullAUPR = ifelse(variable=="AUROC",NA,nullAUPR), nullAUROC = ifelse(variable=="AUPR",NA,nullAUROC)) %>%
ggplot(aes(reorder(abbrev, value, FUN=median),value, color=datasetName)) +
geom_errorbar(aes(ymin=ifelse(value-ci<0,0,value-ci), ymax=ifelse(value+ci>1,1,value+ci)),width=0.4,size=0.6,position = position_dodge(0.9)) +
geom_errorbar(aes(y=nullAUPR,ymin=nullAUPR,ymax=nullAUPR),color="darkgray",lty="dotted",position = position_dodge(0.9)) +
geom_errorbar(aes(y=nullAUROC,ymin=nullAUROC,ymax=nullAUROC),color="darkgray",lty="dotted",position = position_dodge(0.9)) +
geom_point(position = position_dodge(0.9), size=1.5) + xlab("Cancer type") + ylab("Area Under Curve") + theme_pubr() +
facet_wrap(~variable) +
scale_y_continuous(breaks = seq(0, 1, by = 0.1), limits = c(0,1)) +
ggtitle("Broad Institute (WGS) | Raw Data | Blood Derived Normal | 1 Vs All\nScrambled & Shuffled Controls") + theme(plot.title = element_text(hjust = 0.5)) +
rotate_x_text(90) + scale_color_nejm(name = "Features") + geom_hline(yintercept = 1, linetype="dashed")
ggsave("Figures/Other_Figures/control_v2_scrambled_mlPerfAll10k_rep1_Broad_WGS_BDN_species_decontamV2.pdf", dpi = "retina",
width = 6, height = 4, units = "in")
# Full dataset
mlPerfAll10k_Allcancer_Scrambled_Raw_VSNM %>%
filter(sampleType == "Blood Derived Normal") %>%
filter(grepl("VSNM",datasetName)) %>%
distinct() %>% droplevels() %>%
reshape2::melt(id.vars = c("rep","abbrev","diseaseType","sampleType","datasetName","metadataName","minorityClassSize","majorityClassSize","minorityClassName","majorityClassName","nullAUPR","nullAUROC")) %>%
summarySE(measurevar = "value", groupvars = c("datasetName","metadataName","variable","abbrev","minorityClassSize","majorityClassSize","minorityClassName","majorityClassName","nullAUPR","nullAUROC")) %>%
mutate(nullAUPR = ifelse(variable=="AUROC",NA,nullAUPR), nullAUROC = ifelse(variable=="AUPR",NA,nullAUROC)) %>%
ggplot(aes(reorder(abbrev, value, FUN=median),value, color=datasetName)) +
geom_errorbar(aes(ymin=ifelse(value-ci<0,0,value-ci), ymax=ifelse(value+ci>1,1,value+ci)),width=0.4,size=0.6,position = position_dodge(0.9)) +
geom_errorbar(aes(y=nullAUPR,ymin=nullAUPR,ymax=nullAUPR),color="darkgray",lty="dotted",position = position_dodge(0.9)) +
geom_errorbar(aes(y=nullAUROC,ymin=nullAUROC,ymax=nullAUROC),color="darkgray",lty="dotted",position = position_dodge(0.9)) +
geom_point(position = position_dodge(0.9), size=1.5) + xlab("Cancer type") + ylab("Area Under Curve") + theme_pubr() +
facet_wrap(~variable) +
scale_y_continuous(breaks = seq(0, 1, by = 0.1), limits = c(0,1)) +
ggtitle("Full dataset (WGS+RNA-Seq) | Voom-SNM | Blood Derived Normal | 1 Vs All\nScrambled & Shuffled Controls") + theme(plot.title = element_text(hjust = 0.5)) +
rotate_x_text(90) + scale_color_nejm(name = "Features") + geom_hline(yintercept = 1, linetype="dashed")
ggsave("Figures/Other_Figures/control_v2_scrambled_mlPerfAll10k_rep1_TCGA_VSNM_BDN_species_decontamV2.pdf", dpi = "retina",
width = 6, height = 4, units = "in")
#----------------------------------------------------------#
# Overlay actual and (scrambled) control performance per seq center
#----------------------------------------------------------#
load("Interim_data/mlPerfAll10k_Allcancer_Raw_Taxa_Levels_and_Weizmann_2Apr22.RData") # mlPerfAll10k_Allcancer_Raw_Taxa_Levels_and_Weizmann
load("Interim_data/mlPerfAll10k_Allcancer_Raw_2Apr22.RData") # mlPerfAll10k_Allcancer_Raw
source("Supporting_scripts/S00-SummarySE.R") # Contains a function that calculates std error and 95% confidence intervals
mlPerfAll10k_Allcancer_Raw_Control_Overlay <- rbind(mlPerfAll10k_Allcancer_Scrambled_Raw_VSNM,
mlPerfAll10k_Allcancer_Raw_Taxa_Levels_and_Weizmann,
mlPerfAll10k_Allcancer_Raw)
mlPerfAll10k_Allcancer_Raw_Control_Overlay_Filt <- mlPerfAll10k_Allcancer_Raw_Control_Overlay
mlPerfAll10k_Allcancer_Raw_Control_Overlay_Filt$datasetName <- factor(mlPerfAll10k_Allcancer_Raw_Control_Overlay_Filt$datasetName,
levels = rev(levels(mlPerfAll10k_Allcancer_Raw_Control_Overlay_Filt$datasetName)))
#-------------------------Plot primary tumor 1 vs. all others performance-------------------------#
# HMS - overlay
mlPerfAll10k_Allcancer_Raw_Control_Overlay_Filt %>%
filter(sampleType == "Primary Tumor") %>%
filter(grepl("HMS",datasetName)) %>%
filter(grepl("species|shuffled|scrambled",datasetName)) %>%
distinct() %>% droplevels() %>%
reshape2::melt(id.vars = c("rep","abbrev","diseaseType","sampleType","datasetName","metadataName","minorityClassSize","majorityClassSize","minorityClassName","majorityClassName","nullAUPR","nullAUROC")) %>%
summarySE(measurevar = "value", groupvars = c("datasetName","metadataName","variable","abbrev","minorityClassSize","majorityClassSize","minorityClassName","majorityClassName","nullAUPR","nullAUROC")) %>%
mutate(nullAUPR = ifelse(variable=="AUROC",NA,nullAUPR), nullAUROC = ifelse(variable=="AUPR",NA,nullAUROC)) %>%
ggplot(aes(reorder(abbrev, value, FUN=median),value, color=datasetName)) +
geom_errorbar(aes(ymin=ifelse(value-ci<0,0,value-ci), ymax=ifelse(value+ci>1,1,value+ci)),width=0.4,size=0.6,position = position_dodge(0.9)) +
geom_errorbar(aes(y=nullAUPR,ymin=nullAUPR,ymax=nullAUPR),lty="dotted",position = position_dodge(0.9)) +
geom_errorbar(aes(y=nullAUROC,ymin=nullAUROC,ymax=nullAUROC),color="darkgray",lty="dotted",position = position_dodge(0.9)) +
geom_point(position = position_dodge(0.9), size=1.5) + xlab("Cancer type") + ylab("Area Under Curve") + theme_pubr() +
facet_wrap(~variable) +
guides(color=guide_legend(nrow=2, byrow=TRUE)) +
scale_y_continuous(breaks = seq(0, 1, by = 0.1), limits = c(0,1)) +
ggtitle("Harvard Medical School (WGS) | Raw Data | Primary Tumor | 1 Vs All | Species") + theme(plot.title = element_text(hjust = 0.5)) +
rotate_x_text(90) + scale_color_nejm(name = "Features") + geom_hline(yintercept = 1, linetype="dashed")
ggsave("Figures/Other_Figures/control_v2_scrambled_mlPerfAll10k_rep1_HMS_PT_species_overlay_decontamV2.svg", dpi = "retina",
width = 8, height = 4, units = "in")
# BCM - overlay
mlPerfAll10k_Allcancer_Raw_Control_Overlay_Filt %>%
filter(sampleType == "Primary Tumor") %>%
filter(grepl("BCM",datasetName)) %>%
filter(grepl("species|shuffled|scrambled",datasetName)) %>%
distinct() %>% droplevels() %>%
reshape2::melt(id.vars = c("rep","abbrev","diseaseType","sampleType","datasetName","metadataName","minorityClassSize","majorityClassSize","minorityClassName","majorityClassName","nullAUPR","nullAUROC")) %>%
summarySE(measurevar = "value", groupvars = c("datasetName","metadataName","variable","abbrev","minorityClassSize","majorityClassSize","minorityClassName","majorityClassName","nullAUPR","nullAUROC")) %>%
mutate(nullAUPR = ifelse(variable=="AUROC",NA,nullAUPR), nullAUROC = ifelse(variable=="AUPR",NA,nullAUROC)) %>%
ggplot(aes(reorder(abbrev, value, FUN=median),value, color=datasetName)) +
geom_errorbar(aes(ymin=ifelse(value-ci<0,0,value-ci), ymax=ifelse(value+ci>1,1,value+ci)),width=0.4,size=0.6,position = position_dodge(0.9)) +
geom_errorbar(aes(y=nullAUPR,ymin=nullAUPR,ymax=nullAUPR),lty="dotted",position = position_dodge(0.9)) +
geom_errorbar(aes(y=nullAUROC,ymin=nullAUROC,ymax=nullAUROC),color="darkgray",lty="dotted",position = position_dodge(0.9)) +
geom_point(position = position_dodge(0.9), size=1.5) + xlab("Cancer type") + ylab("Area Under Curve") + theme_pubr() +
facet_wrap(~variable) +
guides(color=guide_legend(nrow=2, byrow=TRUE)) +
scale_y_continuous(breaks = seq(0, 1, by = 0.1), limits = c(0,1)) +
ggtitle("Baylor College of Medicine (WGS) | Raw Data | Primary Tumor | 1 Vs All | Species") + theme(plot.title = element_text(hjust = 0.5)) +
rotate_x_text(90) + scale_color_nejm(name = "Features") + geom_hline(yintercept = 1, linetype="dashed")
ggsave("Figures/Other_Figures/control_v2_scrambled_mlPerfAll10k_rep1_BCM_PT_species_overlay_decontamV2.svg", dpi = "retina",
width = 8, height = 4, units = "in")
# MDA - overlay
mlPerfAll10k_Allcancer_Raw_Control_Overlay_Filt %>%
filter(sampleType == "Primary Tumor") %>%
filter(grepl("MDA",datasetName)) %>%
filter(grepl("species|shuffled|scrambled",datasetName)) %>%
distinct() %>% droplevels() %>%
reshape2::melt(id.vars = c("rep","abbrev","diseaseType","sampleType","datasetName","metadataName","minorityClassSize","majorityClassSize","minorityClassName","majorityClassName","nullAUPR","nullAUROC")) %>%
summarySE(measurevar = "value", groupvars = c("datasetName","metadataName","variable","abbrev","minorityClassSize","majorityClassSize","minorityClassName","majorityClassName","nullAUPR","nullAUROC")) %>%
mutate(nullAUPR = ifelse(variable=="AUROC",NA,nullAUPR), nullAUROC = ifelse(variable=="AUPR",NA,nullAUROC)) %>%
ggplot(aes(reorder(abbrev, value, FUN=median),value, color=datasetName)) +
geom_errorbar(aes(ymin=ifelse(value-ci<0,0,value-ci), ymax=ifelse(value+ci>1,1,value+ci)),width=0.4,size=0.6,position = position_dodge(0.9)) +
geom_errorbar(aes(y=nullAUPR,ymin=nullAUPR,ymax=nullAUPR),lty="dotted",position = position_dodge(0.9)) +
geom_errorbar(aes(y=nullAUROC,ymin=nullAUROC,ymax=nullAUROC),color="darkgray",lty="dotted",position = position_dodge(0.9)) +
geom_point(position = position_dodge(0.9), size=1.5) + xlab("Cancer type") + ylab("Area Under Curve") + theme_pubr() +
facet_wrap(~variable) +
guides(color=guide_legend(nrow=2, byrow=TRUE)) +
scale_y_continuous(breaks = seq(0, 1, by = 0.1), limits = c(0,1)) +
ggtitle("MD Anderson (WGS) | Raw Data | Primary Tumor | 1 Vs All | Species") + theme(plot.title = element_text(hjust = 0.5)) +
rotate_x_text(90) + scale_color_nejm(name = "Features") + geom_hline(yintercept = 1, linetype="dashed")
ggsave("Figures/Other_Figures/control_v2_scrambled_mlPerfAll10k_rep1_MDA_PT_species_overlay_decontamV2.svg", dpi = "retina",
width = 8, height = 4, units = "in")
# WashU - overlay
mlPerfAll10k_Allcancer_Raw_Control_Overlay_Filt %>%
filter(sampleType == "Primary Tumor") %>%
filter(grepl("WashU",datasetName)) %>%
filter(grepl("species|shuffled|scrambled",datasetName)) %>%
distinct() %>% droplevels() %>%
reshape2::melt(id.vars = c("rep","abbrev","diseaseType","sampleType","datasetName","metadataName","minorityClassSize","majorityClassSize","minorityClassName","majorityClassName","nullAUPR","nullAUROC")) %>%
summarySE(measurevar = "value", groupvars = c("datasetName","metadataName","variable","abbrev","minorityClassSize","majorityClassSize","minorityClassName","majorityClassName","nullAUPR","nullAUROC")) %>%
mutate(nullAUPR = ifelse(variable=="AUROC",NA,nullAUPR), nullAUROC = ifelse(variable=="AUPR",NA,nullAUROC)) %>%
ggplot(aes(reorder(abbrev, value, FUN=median),value, color=datasetName)) +
geom_errorbar(aes(ymin=ifelse(value-ci<0,0,value-ci), ymax=ifelse(value+ci>1,1,value+ci)),width=0.4,size=0.6,position = position_dodge(0.9)) +
geom_errorbar(aes(y=nullAUPR,ymin=nullAUPR,ymax=nullAUPR),lty="dotted",position = position_dodge(0.9)) +
geom_errorbar(aes(y=nullAUROC,ymin=nullAUROC,ymax=nullAUROC),color="darkgray",lty="dotted",position = position_dodge(0.9)) +
geom_point(position = position_dodge(0.9), size=1.5) + xlab("Cancer type") + ylab("Area Under Curve") + theme_pubr() +
facet_wrap(~variable) +
guides(color=guide_legend(nrow=2, byrow=TRUE)) +
scale_y_continuous(breaks = seq(0, 1, by = 0.1), limits = c(0,1)) +
ggtitle("WashU (WGS) | Raw Data | Primary Tumor | 1 Vs All | Species") + theme(plot.title = element_text(hjust = 0.5)) +
rotate_x_text(90) + scale_color_nejm(name = "Features") + geom_hline(yintercept = 1, linetype="dashed")
ggsave("Figures/Other_Figures/control_v2_scrambled_mlPerfAll10k_rep1_WashU_PT_species_overlay_decontamV2.svg", dpi = "retina",
width = 8, height = 4, units = "in")
# Broad_WGS - overlay
mlPerfAll10k_Allcancer_Raw_Control_Overlay_Filt %>%
filter(sampleType == "Primary Tumor") %>%
filter(grepl("Broad",datasetName)) %>%
filter(grepl("species|shuffled|scrambled",datasetName)) %>%
distinct() %>% droplevels() %>%
reshape2::melt(id.vars = c("rep","abbrev","diseaseType","sampleType","datasetName","metadataName","minorityClassSize","majorityClassSize","minorityClassName","majorityClassName","nullAUPR","nullAUROC")) %>%
summarySE(measurevar = "value", groupvars = c("datasetName","metadataName","variable","abbrev","minorityClassSize","majorityClassSize","minorityClassName","majorityClassName","nullAUPR","nullAUROC")) %>%
mutate(nullAUPR = ifelse(variable=="AUROC",NA,nullAUPR), nullAUROC = ifelse(variable=="AUPR",NA,nullAUROC)) %>%
ggplot(aes(reorder(abbrev, value, FUN=median),value, color=datasetName)) +
geom_errorbar(aes(ymin=ifelse(value-ci<0,0,value-ci), ymax=ifelse(value+ci>1,1,value+ci)),width=0.4,size=0.6,position = position_dodge(0.9)) +
geom_errorbar(aes(y=nullAUPR,ymin=nullAUPR,ymax=nullAUPR),lty="dotted",position = position_dodge(0.9)) +
geom_errorbar(aes(y=nullAUROC,ymin=nullAUROC,ymax=nullAUROC),color="darkgray",lty="dotted",position = position_dodge(0.9)) +
geom_point(position = position_dodge(0.9), size=1.5) + xlab("Cancer type") + ylab("Area Under Curve") + theme_pubr() +
facet_wrap(~variable) +
guides(color=guide_legend(nrow=2, byrow=TRUE)) +
scale_y_continuous(breaks = seq(0, 1, by = 0.1), limits = c(0,1)) +
ggtitle("Broad Institute (WGS) | Raw Data | Primary Tumor | 1 Vs All | Species") + theme(plot.title = element_text(hjust = 0.5)) +
rotate_x_text(90) + scale_color_nejm(name = "Features") + geom_hline(yintercept = 1, linetype="dashed")
ggsave("Figures/Other_Figures/control_v2_scrambled_mlPerfAll10k_rep1_Broad_WGS_PT_species_overlay_decontamV2.svg", dpi = "retina",
width = 8, height = 4, units = "in")
# UNC - overlay
mlPerfAll10k_Allcancer_Raw_Control_Overlay_Filt %>%
filter(sampleType == "Primary Tumor") %>%
filter(grepl("UNC",datasetName)) %>%
filter(grepl("species|shuffled|scrambled",datasetName)) %>%
distinct() %>% droplevels() %>%
reshape2::melt(id.vars = c("rep","abbrev","diseaseType","sampleType","datasetName","metadataName","minorityClassSize","majorityClassSize","minorityClassName","majorityClassName","nullAUPR","nullAUROC")) %>%
summarySE(measurevar = "value", groupvars = c("datasetName","metadataName","variable","abbrev","minorityClassSize","majorityClassSize","minorityClassName","majorityClassName","nullAUPR","nullAUROC")) %>%
mutate(nullAUPR = ifelse(variable=="AUROC",NA,nullAUPR), nullAUROC = ifelse(variable=="AUPR",NA,nullAUROC)) %>%
ggplot(aes(reorder(abbrev, value, FUN=median),value, color=datasetName)) +
geom_errorbar(aes(ymin=ifelse(value-ci<0,0,value-ci), ymax=ifelse(value+ci>1,1,value+ci)),width=0.4,size=0.6,position = position_dodge(0.9)) +
geom_errorbar(aes(y=nullAUPR,ymin=nullAUPR,ymax=nullAUPR),lty="dotted",position = position_dodge(0.9)) +
geom_errorbar(aes(y=nullAUROC,ymin=nullAUROC,ymax=nullAUROC),color="darkgray",lty="dotted",position = position_dodge(0.9)) +
geom_point(position = position_dodge(0.9), size=1.5) + xlab("Cancer type") + ylab("Area Under Curve") + theme_pubr() +
facet_wrap(~variable) +
guides(color=guide_legend(nrow=2, byrow=TRUE)) +
scale_y_continuous(breaks = seq(0, 1, by = 0.1), limits = c(0,1)) +
ggtitle("University North Carolina (RNA-Seq) | Raw Data | Primary Tumor | 1 Vs All | Species") + theme(plot.title = element_text(hjust = 0.5)) +
rotate_x_text(90) + scale_color_nejm(name = "Features") + geom_hline(yintercept = 1, linetype="dashed")
ggsave("Figures/Other_Figures/control_v2_scrambled_mlPerfAll10k_rep1_UNC_PT_species_overlay_decontamV2.svg", dpi = "retina",
width = 8, height = 4, units = "in")
# CMS - overlay
mlPerfAll10k_Allcancer_Raw_Control_Overlay_Filt %>%
filter(sampleType == "Primary Tumor") %>%
filter(grepl("CMS",datasetName)) %>%
filter(grepl("species|shuffled|scrambled",datasetName)) %>%
distinct() %>% droplevels() %>%
reshape2::melt(id.vars = c("rep","abbrev","diseaseType","sampleType","datasetName","metadataName","minorityClassSize","majorityClassSize","minorityClassName","majorityClassName","nullAUPR","nullAUROC")) %>%
summarySE(measurevar = "value", groupvars = c("datasetName","metadataName","variable","abbrev","minorityClassSize","majorityClassSize","minorityClassName","majorityClassName","nullAUPR","nullAUROC")) %>%
mutate(nullAUPR = ifelse(variable=="AUROC",NA,nullAUPR), nullAUROC = ifelse(variable=="AUPR",NA,nullAUROC)) %>%
ggplot(aes(reorder(abbrev, value, FUN=median),value, color=datasetName)) +
geom_errorbar(aes(ymin=ifelse(value-ci<0,0,value-ci), ymax=ifelse(value+ci>1,1,value+ci)),width=0.4,size=0.6,position = position_dodge(0.9)) +
geom_errorbar(aes(y=nullAUPR,ymin=nullAUPR,ymax=nullAUPR),lty="dotted",position = position_dodge(0.9)) +
geom_errorbar(aes(y=nullAUROC,ymin=nullAUROC,ymax=nullAUROC),color="darkgray",lty="dotted",position = position_dodge(0.9)) +
geom_point(position = position_dodge(0.9), size=1.5) + xlab("Cancer type") + ylab("Area Under Curve") + theme_pubr() +
facet_wrap(~variable) +
guides(color=guide_legend(nrow=2, byrow=TRUE)) +
scale_y_continuous(breaks = seq(0, 1, by = 0.1), limits = c(0,1)) +
ggtitle("Canada's Michael Smith Genome Sciences Centre (RNA-Seq) | Raw Data | Primary Tumor | 1 Vs All | Species") + theme(plot.title = element_text(hjust = 0.5)) +
rotate_x_text(90) + scale_color_nejm(name = "Features") + geom_hline(yintercept = 1, linetype="dashed")
ggsave("Figures/Other_Figures/control_v2_scrambled_mlPerfAll10k_rep1_CMS_PT_species_overlay_decontamV2.svg", dpi = "retina",
width = 8, height = 4, units = "in")
#-------------------------Plot primary tumor vs. NAT performance-------------------------#
# HMS - overlay
mlPerfAll10k_Allcancer_Raw_Control_Overlay_Filt %>%
filter(sampleType == "Primary Tumor vs Solid Tissue Normal") %>%
filter(grepl("HMS",datasetName)) %>%
filter(grepl("species|shuffled|scrambled",datasetName)) %>%
distinct() %>% droplevels() %>%
reshape2::melt(id.vars = c("rep","abbrev","diseaseType","sampleType","datasetName","metadataName","minorityClassSize","majorityClassSize","minorityClassName","majorityClassName","nullAUPR","nullAUROC")) %>%
summarySE(measurevar = "value", groupvars = c("datasetName","metadataName","variable","abbrev","minorityClassSize","majorityClassSize","minorityClassName","majorityClassName","nullAUPR","nullAUROC")) %>%
mutate(nullAUPR = ifelse(variable=="AUROC",NA,nullAUPR), nullAUROC = ifelse(variable=="AUPR",NA,nullAUROC)) %>%
ggplot(aes(reorder(abbrev, value, FUN=median),value, color=datasetName)) +
geom_errorbar(aes(ymin=ifelse(value-ci<0,0,value-ci), ymax=ifelse(value+ci>1,1,value+ci)),width=0.4,size=0.6,position = position_dodge(0.9)) +
geom_errorbar(aes(y=nullAUPR,ymin=nullAUPR,ymax=nullAUPR),lty="dotted",position = position_dodge(0.9)) +
geom_errorbar(aes(y=nullAUROC,ymin=nullAUROC,ymax=nullAUROC),color="darkgray",lty="dotted",position = position_dodge(0.9)) +
geom_point(position = position_dodge(0.9), size=1.5) + xlab("Cancer type") + ylab("Area Under Curve") + theme_pubr() +
facet_wrap(~variable) +
guides(color=guide_legend(nrow=2, byrow=TRUE)) +
scale_y_continuous(breaks = seq(0, 1, by = 0.1), limits = c(0,1)) +
ggtitle("Harvard Medical School (WGS) | Raw Data | Primary Tumor vs Solid Tissue Normal | 1 Vs All | Species") + theme(plot.title = element_text(hjust = 0.5)) +
rotate_x_text(90) + scale_color_nejm(name = "Features") + geom_hline(yintercept = 1, linetype="dashed")
ggsave("Figures/Other_Figures/control_v2_scrambled_mlPerfAll10k_rep1_HMS_PT_vs_NAT_species_overlay_decontamV2.svg", dpi = "retina",
width = 8, height = 4, units = "in")
# BCM - overlay
mlPerfAll10k_Allcancer_Raw_Control_Overlay_Filt %>%
filter(sampleType == "Primary Tumor vs Solid Tissue Normal") %>%
filter(grepl("BCM",datasetName)) %>%
filter(grepl("species|shuffled|scrambled",datasetName)) %>%
distinct() %>% droplevels() %>%
reshape2::melt(id.vars = c("rep","abbrev","diseaseType","sampleType","datasetName","metadataName","minorityClassSize","majorityClassSize","minorityClassName","majorityClassName","nullAUPR","nullAUROC")) %>%
summarySE(measurevar = "value", groupvars = c("datasetName","metadataName","variable","abbrev","minorityClassSize","majorityClassSize","minorityClassName","majorityClassName","nullAUPR","nullAUROC")) %>%
mutate(nullAUPR = ifelse(variable=="AUROC",NA,nullAUPR), nullAUROC = ifelse(variable=="AUPR",NA,nullAUROC)) %>%
ggplot(aes(reorder(abbrev, value, FUN=median),value, color=datasetName)) +
geom_errorbar(aes(ymin=ifelse(value-ci<0,0,value-ci), ymax=ifelse(value+ci>1,1,value+ci)),width=0.4,size=0.6,position = position_dodge(0.9)) +
geom_errorbar(aes(y=nullAUPR,ymin=nullAUPR,ymax=nullAUPR),lty="dotted",position = position_dodge(0.9)) +
geom_errorbar(aes(y=nullAUROC,ymin=nullAUROC,ymax=nullAUROC),color="darkgray",lty="dotted",position = position_dodge(0.9)) +
geom_point(position = position_dodge(0.9), size=1.5) + xlab("Cancer type") + ylab("Area Under Curve") + theme_pubr() +
facet_wrap(~variable) +
guides(color=guide_legend(nrow=2, byrow=TRUE)) +
scale_y_continuous(breaks = seq(0, 1, by = 0.1), limits = c(0,1)) +
ggtitle("Baylor College of Medicine (WGS) | Raw Data | Primary Tumor vs Solid Tissue Normal | 1 Vs All | Species") + theme(plot.title = element_text(hjust = 0.5)) +
rotate_x_text(90) + scale_color_nejm(name = "Features") + geom_hline(yintercept = 1, linetype="dashed")
ggsave("Figures/Other_Figures/control_v2_scrambled_mlPerfAll10k_rep1_BCM_PT_vs_NAT_species_overlay_decontamV2.svg", dpi = "retina",
width = 8, height = 4, units = "in")
## NOTE: Neither MDA nor WashU had sufficient samples to plot primary tumor vs. NAT performance
# Broad_WGS - overlay
mlPerfAll10k_Allcancer_Raw_Control_Overlay_Filt %>%
filter(sampleType == "Primary Tumor vs Solid Tissue Normal") %>%
filter(grepl("Broad",datasetName)) %>%
filter(grepl("species|shuffled|scrambled",datasetName)) %>%
distinct() %>% droplevels() %>%
reshape2::melt(id.vars = c("rep","abbrev","diseaseType","sampleType","datasetName","metadataName","minorityClassSize","majorityClassSize","minorityClassName","majorityClassName","nullAUPR","nullAUROC")) %>%
summarySE(measurevar = "value", groupvars = c("datasetName","metadataName","variable","abbrev","minorityClassSize","majorityClassSize","minorityClassName","majorityClassName","nullAUPR","nullAUROC")) %>%
mutate(nullAUPR = ifelse(variable=="AUROC",NA,nullAUPR), nullAUROC = ifelse(variable=="AUPR",NA,nullAUROC)) %>%
ggplot(aes(reorder(abbrev, value, FUN=median),value, color=datasetName)) +
geom_errorbar(aes(ymin=ifelse(value-ci<0,0,value-ci), ymax=ifelse(value+ci>1,1,value+ci)),width=0.4,size=0.6,position = position_dodge(0.9)) +
geom_errorbar(aes(y=nullAUPR,ymin=nullAUPR,ymax=nullAUPR),lty="dotted",position = position_dodge(0.9)) +
geom_errorbar(aes(y=nullAUROC,ymin=nullAUROC,ymax=nullAUROC),color="darkgray",lty="dotted",position = position_dodge(0.9)) +
geom_point(position = position_dodge(0.9), size=1.5) + xlab("Cancer type") + ylab("Area Under Curve") + theme_pubr() +
facet_wrap(~variable) +
guides(color=guide_legend(nrow=2, byrow=TRUE)) +
scale_y_continuous(breaks = seq(0, 1, by = 0.1), limits = c(0,1)) +
ggtitle("Broad Institute (WGS) | Raw Data | Primary Tumor vs Solid Tissue Normal | 1 Vs All | Species") + theme(plot.title = element_text(hjust = 0.5)) +
rotate_x_text(90) + scale_color_nejm(name = "Features") + geom_hline(yintercept = 1, linetype="dashed")
ggsave("Figures/Other_Figures/control_v2_scrambled_mlPerfAll10k_rep1_Broad_WGS_PT_vs_NAT_species_overlay_decontamV2.svg", dpi = "retina",
width = 8, height = 4, units = "in")
# UNC - overlay
mlPerfAll10k_Allcancer_Raw_Control_Overlay_Filt %>%
filter(sampleType == "Primary Tumor vs Solid Tissue Normal") %>%
filter(grepl("UNC",datasetName)) %>%
filter(grepl("species|shuffled|scrambled",datasetName)) %>%
distinct() %>% droplevels() %>%
reshape2::melt(id.vars = c("rep","abbrev","diseaseType","sampleType","datasetName","metadataName","minorityClassSize","majorityClassSize","minorityClassName","majorityClassName","nullAUPR","nullAUROC")) %>%
summarySE(measurevar = "value", groupvars = c("datasetName","metadataName","variable","abbrev","minorityClassSize","majorityClassSize","minorityClassName","majorityClassName","nullAUPR","nullAUROC")) %>%
mutate(nullAUPR = ifelse(variable=="AUROC",NA,nullAUPR), nullAUROC = ifelse(variable=="AUPR",NA,nullAUROC)) %>%
ggplot(aes(reorder(abbrev, value, FUN=median),value, color=datasetName)) +
geom_errorbar(aes(ymin=ifelse(value-ci<0,0,value-ci), ymax=ifelse(value+ci>1,1,value+ci)),width=0.4,size=0.6,position = position_dodge(0.9)) +
geom_errorbar(aes(y=nullAUPR,ymin=nullAUPR,ymax=nullAUPR),lty="dotted",position = position_dodge(0.9)) +