-
Notifications
You must be signed in to change notification settings - Fork 15
/
12R-Plasma-validation-cohort-Hopkins.R
executable file
·1594 lines (1470 loc) · 107 KB
/
12R-Plasma-validation-cohort-Hopkins.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
#-----------------------------------------------------------------------------
# 12R-Plasma-validation-cohort-Hopkins.R
# Copyright (c) 2021--, Greg Poore
# Purposes:
# - Import rep200 data for plasma validation cohort #2 (Cristiano et al. 2019. Nature)
# - Remove contaminants identified in TCGA and plasma validation cohort #1
# - Perform machine learning between cancer vs. healthy groups and between stages
#-----------------------------------------------------------------------------
#----------------------------------------------------------#
# Load environments
#----------------------------------------------------------#
# Load dependencies
require(devtools)
require(doMC)
require(plyr)
require(dplyr)
require(reshape2)
require(ggpubr)
require(ggsci)
require(tibble)
require(phyloseq)
require(microbiome)
require(vegan)
require(biomformat)
require(rhdf5)
numCores <- detectCores()
registerDoMC(cores=numCores)
#----------------------------------------------------------#
# Rep200 fungal species identification
#----------------------------------------------------------#
rep200TaxSplit <- read.csv("Supporting_data/rep200_lineage_map_split.csv", stringsAsFactors = FALSE, row.names = 1)
rep200Kingdoms <- read.csv("Supporting_data/rep200_gOTU_kingdom_mapping.csv", stringsAsFactors = FALSE)
rep200Kingdoms_Fungi <- rep200Kingdoms[which(rep200Kingdoms$kingdom == "fungi"),]
rep200Kingdoms_Bacteria <- rep200Kingdoms[which(rep200Kingdoms$kingdom == "bacteria"),]
rep200TaxSplit_Fungi <- rep200TaxSplit[rownames(rep200TaxSplit) %in% rep200Kingdoms_Fungi$genomeID,,drop=FALSE]
dim(rep200TaxSplit_Fungi) # 320 7
rep200TaxSplit_Bacteria <- rep200TaxSplit[rownames(rep200TaxSplit) %in% rep200Kingdoms_Bacteria$genomeID,,drop=FALSE]
dim(rep200TaxSplit_Bacteria) # 11080 7
fungiOGUs <- rownames(rep200TaxSplit_Fungi)
bacteriaOGUs <- rownames(rep200TaxSplit_Bacteria)
#----------------------------------------------------------#
# Microbial data import
#----------------------------------------------------------#
# The biom table and metadata were loaded from the following
# Qiita analysis (to be made public upon publication)
# https://qiita.ucsd.edu/analysis/description/47106/
## Import Qiita metadata
metaCristiano <- read.csv("Input_data/qiita_metadata_plasma_validation_cohort_Hopkins.csv", stringsAsFactors = FALSE, row.names = 1)
## Filter based on pre-treatment / treatment naive status.
# For patients with more than 1 pre-treatment sample, take the earliest one.
metaCristianoTxNaive <- metaCristiano %>% filter(grepl("Preoperative treatment naive|Pre-treatment", subject_id)) %>% droplevels()
metaCristianoTxNaive$patientWithoutDay <- gsub("_D.+","",metaCristianoTxNaive$alias)
metaCristianoTxNaive$dayPreTx <- as.numeric(gsub("CG.+ Day ","",metaCristianoTxNaive$subject_id))
# The following code finds patients with more than 1 sample, finds which sample was taken earliest,
# and then creates a list of the samples to remove
patientsWithMultipleSamples <- metaCristianoTxNaive[duplicated(metaCristianoTxNaive$patientWithoutDay)|
duplicated(metaCristianoTxNaive$patientWithoutDay, fromLast = TRUE),
c("patientWithoutDay","dayPreTx")]
patientsWithMultipleSamplesFixed <- patientsWithMultipleSamples %>%
arrange(patientWithoutDay, dayPreTx) %>%
distinct(patientWithoutDay, .keep_all = TRUE)
samplesToRemove <- rownames(patientsWithMultipleSamples[!(rownames(patientsWithMultipleSamples) %in%
rownames(patientsWithMultipleSamplesFixed)),])
# Create final filtered metadata table
metaCristianoTxNaiveFilt <- droplevels(metaCristianoTxNaive[!(rownames(metaCristianoTxNaive) %in% samplesToRemove),])
metaCristianoTxNaiveFilt$phenotype <- factor(metaCristianoTxNaiveFilt$phenotype)
metaCristianoTxNaiveFilt$cancer_status <- factor(ifelse(metaCristianoTxNaiveFilt$phenotype == "Healthy",
yes="Healthy",no="Cancer"), levels = c("Cancer","Healthy"))
metaCristianoTxNaiveFilt$stage[metaCristianoTxNaiveFilt$phenotype == "Healthy"] <- "Healthy"
## Import read count data
cristiano_rep200Data_BIOM <- read_biom(biom_file = "Input_data/Qiita_results/rep200_OGU_plasma_validation_cohort_Hopkins.biom")
cristiano_rep200Data <- t(as(biom_data(cristiano_rep200Data_BIOM), "matrix"))
cristiano_rep200Data_Filt <- cristiano_rep200Data[rownames(metaCristianoTxNaiveFilt),]
dim(cristiano_rep200Data_Filt) # 491 7418
## Extract only fungal features
cristiano_rep200Data_Filt_Fungi <- cristiano_rep200Data_Filt[,colnames(cristiano_rep200Data_Filt) %in% fungiOGUs]
dim(cristiano_rep200Data_Filt_Fungi) # 491 296
## Extract only bacterial features
cristiano_rep200Data_Filt_Bacteria <- cristiano_rep200Data_Filt[,colnames(cristiano_rep200Data_Filt) %in% bacteriaOGUs]
dim(cristiano_rep200Data_Filt_Bacteria) # 491 6908
#----------------------------------------------------------------------------------------------#
# Create fungi phyloseq object to summarize reads at various taxa levels and match to Weizmann features
#----------------------------------------------------------------------------------------------#
rep200TaxSplit_Fungi_Paired_to_Weizmann <- read.csv("Supporting_data/rep200TaxSplit_Fungi_Paired_To_Weizmann_Final.csv", stringsAsFactors = FALSE, row.names = 1)
# Build phyloseq object
psCristianoFungi <- phyloseq(otu_table(cristiano_rep200Data_Filt_Fungi, taxa_are_rows = FALSE),
tax_table(as.matrix(rep200TaxSplit_Fungi_Paired_to_Weizmann)),
sample_data(metaCristianoTxNaiveFilt))
## Aggregate counts
psCristianoFungi_phylum = aggregate_taxa(psCristianoFungi, "phylum")
psCristianoFungi_class = aggregate_taxa(psCristianoFungi, "class")
psCristianoFungi_order = aggregate_taxa(psCristianoFungi, "order")
psCristianoFungi_family = aggregate_taxa(psCristianoFungi, "family")
psCristianoFungi_genus = aggregate_taxa(psCristianoFungi, "genus")
psCristianoFungi_species = cristiano_rep200Data_Filt_Fungi
colnames(psCristianoFungi_species) <- rep200TaxSplit_Fungi_Paired_to_Weizmann[colnames(psCristianoFungi_species),"species"]
## Load shared features with Weizmann
load("Interim_data/shared_fungi_features_at_each_taxa_level_29Mar22.RData")
## Subset taxa to those shared with the Weizmann data
psCristianoFungi_phylum_shared <- subset_taxa(psCristianoFungi_phylum, phylum %in% sharedPhylum)
psCristianoFungi_class_shared <- subset_taxa(psCristianoFungi_class, class %in% sharedClass)
psCristianoFungi_order_shared <- subset_taxa(psCristianoFungi_order, order %in% sharedOrder)
psCristianoFungi_family_shared <- subset_taxa(psCristianoFungi_family, family %in% sharedFamily)
psCristianoFungi_genus_shared <- subset_taxa(psCristianoFungi_genus, genus %in% sharedGenus)
psCristianoFungi_species_shared <- psCristianoFungi_species[,colnames(psCristianoFungi_species) %in% sharedSpecies]
## Create data.frames of summarized data with and without feature intersection
# Without feature intersection
cristianoRep200FungiPhylum <- data.frame(t(otu_table(psCristianoFungi_phylum)))
cristianoRep200FungiClass <- data.frame(t(otu_table(psCristianoFungi_class)))
cristianoRep200FungiOrder <- data.frame(t(otu_table(psCristianoFungi_order)))
cristianoRep200FungiFamily <- data.frame(t(otu_table(psCristianoFungi_family)))
cristianoRep200FungiGenus <- data.frame(t(otu_table(psCristianoFungi_genus)))
cristianoRep200FungiSpecies <- data.frame(psCristianoFungi_species)
cristianoRep200FungiSpecies[1:3,1:3]
# With feature intersection
cristianoRep200FungiPhylumShared <- data.frame(t(otu_table(psCristianoFungi_phylum_shared)))
cristianoRep200FungiClassShared <- data.frame(t(otu_table(psCristianoFungi_class_shared)))
cristianoRep200FungiOrderShared <- data.frame(t(otu_table(psCristianoFungi_order_shared)))
cristianoRep200FungiFamilyShared <- data.frame(t(otu_table(psCristianoFungi_family_shared)))
cristianoRep200FungiGenusShared <- data.frame(t(otu_table(psCristianoFungi_genus_shared)))
cristianoRep200FungiSpeciesShared <- data.frame(psCristianoFungi_species_shared)
cristianoRep200FungiGenusShared[1:3,1:3]
#-----------------------------------------------#
# Decontaminate using TCGA data
#-----------------------------------------------#
load("Interim_data/decontamResultsV2_25Mar22.RData")
cristiano_rep200Data_Filt_Fungi_Decontam <- cristiano_rep200Data_Filt_Fungi[,colnames(cristiano_rep200Data_Filt_Fungi) %in%
rownames(decontamResultsV2[decontamResultsV2$decision == "KEEP",])]
# Build phyloseq object
psCristianoFungiDecontam <- phyloseq(otu_table(cristiano_rep200Data_Filt_Fungi_Decontam, taxa_are_rows = FALSE),
tax_table(as.matrix(rep200TaxSplit_Fungi_Paired_to_Weizmann)),
sample_data(metaCristianoTxNaiveFilt))
## Aggregate counts
psCristianoFungiDecontam_phylum = aggregate_taxa(psCristianoFungiDecontam, "phylum")
psCristianoFungiDecontam_class = aggregate_taxa(psCristianoFungiDecontam, "class")
psCristianoFungiDecontam_order = aggregate_taxa(psCristianoFungiDecontam, "order")
psCristianoFungiDecontam_family = aggregate_taxa(psCristianoFungiDecontam, "family")
psCristianoFungiDecontam_genus = aggregate_taxa(psCristianoFungiDecontam, "genus")
psCristianoFungiDecontam_species = cristiano_rep200Data_Filt_Fungi_Decontam
colnames(psCristianoFungiDecontam_species) <- rep200TaxSplit_Fungi_Paired_to_Weizmann[
colnames(psCristianoFungiDecontam_species),"species"]
## Create data.frames of summarized data
cristianoRep200FungiDecontamPhylum <- data.frame(t(otu_table(psCristianoFungiDecontam_phylum)))
cristianoRep200FungiDecontamClass <- data.frame(t(otu_table(psCristianoFungiDecontam_class)))
cristianoRep200FungiDecontamOrder <- data.frame(t(otu_table(psCristianoFungiDecontam_order)))
cristianoRep200FungiDecontamFamily <- data.frame(t(otu_table(psCristianoFungiDecontam_family)))
cristianoRep200FungiDecontamGenus <- data.frame(t(otu_table(psCristianoFungiDecontam_genus)))
cristianoRep200FungiDecontamSpecies <- data.frame(psCristianoFungiDecontam_species)
#----------------------------------------------------------------------------------------------#
# Create bacteria phyloseq object to compare performance of fungi to bacteria
#----------------------------------------------------------------------------------------------#
# Modify bacterial taxa table
rep200TaxSplit_Bacteria_Formatted <- apply(rep200TaxSplit_Bacteria, 2, function(x) gsub("^[k|p|c|o|f|g|s]__","",x))
rep200TaxSplit_Bacteria_Formatted[rep200TaxSplit_Bacteria_Formatted == ""] <- "other"
# Build phyloseq object
psCristianoBacteria <- phyloseq(otu_table(cristiano_rep200Data_Filt_Bacteria, taxa_are_rows = FALSE),
tax_table(as.matrix(rep200TaxSplit_Bacteria_Formatted)),
sample_data(metaCristianoTxNaiveFilt))
## Aggregate counts
psCristianoBacteria_phylum = aggregate_taxa(psCristianoBacteria, "Phylum")
psCristianoBacteria_class = aggregate_taxa(psCristianoBacteria, "Class")
psCristianoBacteria_order = aggregate_taxa(psCristianoBacteria, "Order")
psCristianoBacteria_family = aggregate_taxa(psCristianoBacteria, "Family")
psCristianoBacteria_genus = aggregate_taxa(psCristianoBacteria, "Genus")
psCristianoBacteria_species = aggregate_taxa(psCristianoBacteria, "Species") #cristiano_rep200Data_Filt_Bacteria
# colnames(psCristianoBacteria_species) <- rep200TaxSplit_Bacteria_Formatted[colnames(psCristianoBacteria_species),"Species"]
## Create data.frames of summarized data
cristianoRep200BacteriaPhylum <- data.frame(t(otu_table(psCristianoBacteria_phylum)))
cristianoRep200BacteriaClass <- data.frame(t(otu_table(psCristianoBacteria_class)))
cristianoRep200BacteriaOrder <- data.frame(t(otu_table(psCristianoBacteria_order)))
cristianoRep200BacteriaFamily <- data.frame(t(otu_table(psCristianoBacteria_family)))
cristianoRep200BacteriaGenus <- data.frame(t(otu_table(psCristianoBacteria_genus)))
cristianoRep200BacteriaSpecies <- data.frame(t(otu_table(psCristianoBacteria_species))) #data.frame(psCristianoBacteria_species)
cristianoRep200BacteriaSpecies[1:3,1:3]
## Subset taxa to those shared with the Weizmann data
load("Interim_data/shared_bacterial_features_at_each_taxa_level_29Mar22.RData")
psCristianoBacteria_phylum_shared <- subset_taxa(psCristianoBacteria_phylum, Phylum %in% sharedPhylumBacteria$intersectedTaxa)
psCristianoBacteria_class_shared <- subset_taxa(psCristianoBacteria_class, Class %in% sharedClassBacteria$intersectedTaxa)
psCristianoBacteria_order_shared <- subset_taxa(psCristianoBacteria_order, Order %in% sharedOrderBacteria$intersectedTaxa)
psCristianoBacteria_family_shared <- subset_taxa(psCristianoBacteria_family, Family %in% sharedFamilyBacteria$intersectedTaxa)
psCristianoBacteria_genus_shared <- subset_taxa(psCristianoBacteria_genus, Genus %in% sharedGenusBacteria$intersectedTaxa)
psCristianoBacteria_species_shared <- subset_taxa(psCristianoBacteria_species, Species %in% sharedSpeciesBacteria$intersectedTaxa)
# psCristianoBacteria_species_shared <- psCristianoBacteria_species[,colnames(psCristianoBacteria_species) %in% sharedSpeciesBacteria$intersectedTaxa]
## Create data.frames of summarized data with feature intersection
cristianoRep200BacteriaPhylumShared <- data.frame(t(otu_table(psCristianoBacteria_phylum_shared)))
cristianoRep200BacteriaClassShared <- data.frame(t(otu_table(psCristianoBacteria_class_shared)))
cristianoRep200BacteriaOrderShared <- data.frame(t(otu_table(psCristianoBacteria_order_shared)))
cristianoRep200BacteriaFamilyShared <- data.frame(t(otu_table(psCristianoBacteria_family_shared)))
cristianoRep200BacteriaGenusShared <- data.frame(t(otu_table(psCristianoBacteria_genus_shared)))
cristianoRep200BacteriaSpeciesShared <- data.frame(t(otu_table(psCristianoBacteria_species_shared))) # data.frame(psCristianoBacteria_species_shared)
cristianoRep200BacteriaSpeciesShared[1:3,1:3]
#-----------------------------------------#
# Calculating log ratios based on MMvec findings
#-----------------------------------------#
f1Genera <- c("Malassezia","Trichosporon","Ramularia")
f2Genera <- c("Aspergillus","Candida")
f3Genera <- c("Colletotrichum","Fusarium","Cutaneotrichosporon","Phialocephala","Trichoderma","Talaromyces",
"Yarrowia","Stereum","Aureobasidium","Hyphopichia","Dissoconium","Agaricus","Exophiala",
"Alternaria","Tilletiopsis","Cryptococcus","Penicillium","Puccinia")
# Subset with a pseudocount (to avoid dropping many samples)
cristianoRep200FungiGenusSubset <- cristianoRep200FungiGenus[,c(f1Genera,f2Genera,f3Genera)]+1
lrMetaHopkins <- metaCristianoTxNaiveFilt
lrMetaHopkins$lr_labels <- gsub(" cancer| Cancer","", lrMetaHopkins$phenotype)
lrMetaHopkins$lr_f1_f2 <- log10(rowSums(cristianoRep200FungiGenusSubset[,f1Genera])/rowSums(cristianoRep200FungiGenusSubset[,f2Genera]))
lrMetaHopkins$lr_f1_f3 <- log10(rowSums(cristianoRep200FungiGenusSubset[,f1Genera])/rowSums(cristianoRep200FungiGenusSubset[,f3Genera]))
lrMetaHopkins$lr_f2_f3 <- log10(rowSums(cristianoRep200FungiGenusSubset[,f2Genera])/rowSums(cristianoRep200FungiGenusSubset[,f3Genera]))
#------------Between cancer types------------#
# NOTE: Duodenal Cancer only has 1 sample and is removed below
lrMetaHopkins %>%
filter(phenotype != "Healthy") %>%
filter(phenotype != "Duodenal Cancer") %>%
filter(is.finite(lr_f1_f2)) %>%
filter(!is.na(lr_f1_f2)) %>%
ggplot(aes(reorder(lr_labels, -lr_f1_f2, FUN=median),lr_f1_f2, fill=lr_labels)) +
geom_boxplot(notch = TRUE) + scale_fill_nejm() + theme_pubr() + geom_point(alpha=0.4) +
theme(legend.position = "none", plot.title = element_text(hjust=0.5)) +
labs(x = "Cancer Types", y = "log(F1/F2)", title = "Log ratio of F1/F2 in plasma data") +
stat_compare_means(method = "anova", label.y = 2.2)
ggsave(filename = "Figures/Supplementary_Figures/log_ratio_hopkins_f1_f2.svg", dpi = "retina",
units = "in", width = 6.5, height = 4)
lrMetaHopkins %>%
filter(phenotype != "Healthy") %>%
filter(phenotype != "Duodenal Cancer") %>%
filter(is.finite(lr_f1_f3)) %>%
filter(!is.na(lr_f1_f3)) %>%
ggplot(aes(reorder(lr_labels, -lr_f1_f3, FUN=median),lr_f1_f3, fill=lr_labels)) +
geom_boxplot(notch = TRUE) + scale_fill_nejm() + theme_pubr() + geom_point(alpha=0.4) +
theme(legend.position = "none", plot.title = element_text(hjust=0.5)) +
labs(x = "Cancer Types", y = "log(F1/F3)", title = "Log ratio of F1/F3 in plasma data") +
stat_compare_means(method = "anova", label.y = 1.5)
ggsave(filename = "Figures/Supplementary_Figures/log_ratio_hopkins_f1_f3.svg", dpi = "retina",
units = "in", width = 6.5, height = 4)
lrMetaHopkins %>%
filter(phenotype != "Healthy") %>%
filter(phenotype != "Duodenal Cancer") %>%
filter(is.finite(lr_f2_f3)) %>%
filter(!is.na(lr_f2_f3)) %>%
ggplot(aes(reorder(lr_labels, -lr_f2_f3, FUN=mean),lr_f2_f3, fill=lr_labels)) +
geom_boxplot(notch = TRUE) + scale_fill_nejm() + theme_pubr() + geom_point(alpha=0.4) +
theme(legend.position = "none", plot.title = element_text(hjust=0.5)) +
labs(x = "Cancer Types", y = "log(F2/F3)", title = "Log ratio of F2/F3 in plasma data") +
stat_compare_means(method = "anova", label.y = 0.5)
ggsave(filename = "Figures/Supplementary_Figures/log_ratio_hopkins_f2_f3.svg", dpi = "retina",
units = "in", width = 6.5, height = 4)
#------------Cancer vs Healthy------------#
lrMetaHopkins %>%
filter(is.finite(lr_f1_f2)) %>%
filter(!is.na(lr_f1_f2)) %>%
ggplot(aes(reorder(cancer_status, -lr_f1_f2, FUN=median),lr_f1_f2, fill=cancer_status)) +
geom_boxplot(notch = TRUE) + scale_fill_nejm() + theme_pubr() + geom_point(alpha=0.4) +
theme(legend.position = "none", plot.title = element_text(hjust=0.5)) +
labs(x = "Disease Status", y = "log(F1/F2)", title = "Hopkins: Log ratio of F1/F2") +
stat_compare_means(method = "wilcox.test", label.y = 2.2, comparisons = list(c("Cancer","Healthy")))
ggsave(filename = "Figures/Supplementary_Figures/log_ratio_hopkins_f1_f2_cancer_vs_healthy.svg", dpi = "retina",
units = "in", width = 3, height = 4)
lrMetaHopkins %>%
filter(is.finite(lr_f1_f3)) %>%
filter(!is.na(lr_f1_f3)) %>%
ggplot(aes(reorder(cancer_status, -lr_f1_f3, FUN=median),lr_f1_f3, fill=cancer_status)) +
geom_boxplot(notch = TRUE) + scale_fill_nejm() + theme_pubr() + geom_point(alpha=0.4) +
theme(legend.position = "none", plot.title = element_text(hjust=0.5)) +
labs(x = "Disease Status", y = "log(F1/F3)", title = "Hopkins: Log ratio of F1/F3") +
stat_compare_means(method = "wilcox.test", label.y = 2.2, comparisons = list(c("Cancer","Healthy")))
ggsave(filename = "Figures/Supplementary_Figures/log_ratio_hopkins_f1_f3_cancer_vs_healthy.svg", dpi = "retina",
units = "in", width = 3, height = 4)
lrMetaHopkins %>%
filter(is.finite(lr_f2_f3)) %>%
filter(!is.na(lr_f2_f3)) %>%
ggplot(aes(reorder(cancer_status, -lr_f2_f3, FUN=median),lr_f2_f3, fill=cancer_status)) +
geom_boxplot(notch = TRUE) + scale_fill_nejm() + theme_pubr() + geom_point(alpha=0.4) +
theme(legend.position = "none", plot.title = element_text(hjust=0.5)) +
labs(x = "Disease Status", y = "log(F2/F3)", title = "Hopkins: Log ratio of F2/F3") +
stat_compare_means(method = "wilcox.test", label.y = 1.2, comparisons = list(c("Cancer","Healthy")))
ggsave(filename = "Figures/Supplementary_Figures/log_ratio_hopkins_f2_f3_cancer_vs_healthy.svg", dpi = "retina",
units = "in", width = 3, height = 4)
#-----------------------------------------#
# Machine learning: Healthy vs. Cancer
# - Full rep200 vs.
# - Bacteria only vs.
# - Fungi only vs.
# - Intersected fungi only
#-----------------------------------------#
source("00-Functions.R") # for mlCristiano() function
cristianoCancerVsHealthy_FullRep200 <- mlCristiano(metaData = metaCristianoTxNaiveFilt,
countData = cristiano_rep200Data_Filt,
dataString = "full_rep200",
col2Predict = "cancer_status",
varImpFlag = FALSE)
cristianoCancerVsHealthy_BacteriaOnly <- mlCristiano(metaData = metaCristianoTxNaiveFilt,
countData = cristianoRep200BacteriaSpecies,
dataString = "bacteria_only",
col2Predict = "cancer_status",
varImpFlag = FALSE)
cristianoCancerVsHealthy_FungiOnly <- mlCristiano(metaData = metaCristianoTxNaiveFilt,
countData = cristianoRep200FungiSpecies,
dataString = "fungi_only",
col2Predict = "cancer_status",
varImpFlag = FALSE)
cristianoCancerVsHealthy_FungiDecontam <- mlCristiano(metaData = metaCristianoTxNaiveFilt,
countData = cristiano_rep200Data_Filt_Fungi_Decontam,
dataString = "fungi_decontam",
col2Predict = "cancer_status",
varImpFlag = FALSE)
cristianoCancerVsHealthy_FungiIntersect <- mlCristiano(metaData = metaCristianoTxNaiveFilt,
countData = cristianoRep200FungiSpeciesShared,
dataString = "fungi_intersected_with_Weizmann",
col2Predict = "cancer_status",
varImpFlag = FALSE)
cristianoCancerVsHealthy_BacteriaIntersect <- mlCristiano(metaData = metaCristianoTxNaiveFilt,
countData = cristianoRep200BacteriaSpeciesShared,
dataString = "bacteria_intersected_with_Weizmann",
col2Predict = "cancer_status",
varImpFlag = FALSE)
cristianoCancerVsHealthy_FungiBacteriaIntersect <- mlCristiano(metaData = metaCristianoTxNaiveFilt,
countData = cbind(cristianoRep200FungiSpeciesShared,
cristianoRep200BacteriaSpeciesShared),
dataString = "fungi_and_bacteria_intersected_with_Weizmann",
col2Predict = "cancer_status",
varImpFlag = FALSE)
# Compile results
cristianoCancerVsHealthyResults <- rbind(cristianoCancerVsHealthy_FullRep200$rep_perf,
cristianoCancerVsHealthy_BacteriaOnly$rep_perf,
cristianoCancerVsHealthy_FungiOnly$rep_perf,
cristianoCancerVsHealthy_FungiDecontam$rep_perf,
cristianoCancerVsHealthy_FungiIntersect$rep_perf,
cristianoCancerVsHealthy_BacteriaIntersect$rep_perf,
cristianoCancerVsHealthy_FungiBacteriaIntersect$rep_perf)
colnames(cristianoCancerVsHealthyResults)[1:2] <- c("AUROC","AUPR")
cristianoCancerVsHealthyResults$nullAUROC <- 0.5
# In the line below, "minorityClassSize" isn't technically the minority but rather
# the positive class (cancer), so it still serves to infer the null AUPR
cristianoCancerVsHealthyResults$nullAUPR <- cristianoCancerVsHealthyResults$minorityClassSize/
(cristianoCancerVsHealthyResults$minorityClassSize+cristianoCancerVsHealthyResults$majorityClassSize)
cristianoCancerVsHealthyResults$dataString[cristianoCancerVsHealthyResults$dataString=="full_rep200"] <- "Full multikingdom database (rep200)"
cristianoCancerVsHealthyResults$dataString[cristianoCancerVsHealthyResults$dataString=="bacteria_only"] <- "Bacteria all (Species)"
cristianoCancerVsHealthyResults$dataString[cristianoCancerVsHealthyResults$dataString=="fungi_only"] <- "Fungi all (Species)"
cristianoCancerVsHealthyResults$dataString[cristianoCancerVsHealthyResults$dataString=="fungi_decontam"] <- "Fungi decontaminated (Species)"
cristianoCancerVsHealthyResults$dataString[cristianoCancerVsHealthyResults$dataString=="fungi_intersected_with_Weizmann"] <- "Fungi ∩ WIS (Species)"
cristianoCancerVsHealthyResults$dataString[cristianoCancerVsHealthyResults$dataString=="bacteria_intersected_with_Weizmann"] <- "Bacteria ∩ WIS (Species)"
cristianoCancerVsHealthyResults$dataString[cristianoCancerVsHealthyResults$dataString=="fungi_and_bacteria_intersected_with_Weizmann"] <- "Fungi+bacteria ∩ WIS (Species)"
cristianoCancerVsHealthyResults$dataString <- factor(cristianoCancerVsHealthyResults$dataString, levels = c("Full multikingdom database (rep200)",
"Fungi+bacteria ∩ WIS (Species)",
"Bacteria all (Species)",
"Fungi all (Species)",
"Fungi decontaminated (Species)",
"Fungi ∩ WIS (Species)",
"Bacteria ∩ WIS (Species)"))
save(cristianoCancerVsHealthyResults,
file = "Interim_data/cristianoCancerVsHealthyResults_4Apr22.RData")
require(ggrepel)
source("Supporting_scripts/S00-SummarySE.R")
# Facet by AUROC vs AUPR; color by full dataset vs fungi (dataString)
cristianoCancerVsHealthyResults %>%
filter(grepl("Full|\\+|decontam",dataString)) %>%
reshape2::melt(id.vars = c("dataString","rep","diseaseType", "col2Predict","minorityClassSize","majorityClassSize","nullAUPR","nullAUROC")) %>%
summarySE(measurevar = "value", groupvars = c("diseaseType","dataString","variable","minorityClassSize","majorityClassSize","nullAUPR","nullAUROC")) %>%
mutate(nullAUPR = ifelse(variable=="AUROC",NA,nullAUPR), nullAUROC = ifelse(variable=="AUPR",NA,nullAUROC)) %>%
ggplot(aes(reorder(diseaseType, value, FUN=median),value, color=dataString)) +
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="solid",position = position_dodge(0.9)) +
geom_errorbar(aes(y=nullAUROC,ymin=nullAUROC,ymax=nullAUROC),lty="dotted",position = position_dodge(0.9)) +
geom_point(position = position_dodge(0.9), size=1.5) +
ylab("Area Under Curve") + theme_pubr() +
facet_wrap(~variable) +
ggtitle("Hopkins plasma validation cohort:\nCancer vs. healthy") +
theme(plot.title = element_text(hjust = 0), legend.position = "right") +
scale_y_continuous(breaks = seq(0, 1, by = 0.1), limits = c(0,1)) +
theme(axis.text.x=element_blank(),
axis.ticks.x=element_blank(), plot.title = element_text(hjust = 0.5)) +
scale_x_discrete(labels = NULL, breaks = NULL) + labs(x = "Cancer vs. Healthy") +
rotate_x_text(0) + scale_color_aaas(name = "Dataset") + geom_hline(yintercept = 1, linetype="dashed")
ggsave("Figures/Other_Figures/hopkins_all_cancer_vs_healthy_full_WIS_fungi_4Apr22.svg",
dpi = "retina", width = 6, height = 3, units = "in")
#---------------------------------------------------------------------------------------------------------------------------#
# ML repeated CV perf --> ROC plot with 99% CIs
#---------------------------------------------------------------------------------------------------------------------------#
# The following command may take a few minutes on a MacBook pro
mlFullDB_CV <- mlCristiano(metaData = metaCristianoTxNaiveFilt,
countData = cristiano_rep200Data_Filt,
dataString = "full_rep200",
col2Predict = "cancer_status",
numResampleIter = 10,
varImpFlag = FALSE)
# The rest of the calls should be faster than the above one
mlFungiBacteriaWISIntersect_CV <- mlCristiano(metaData = metaCristianoTxNaiveFilt,
countData = cbind(cristianoRep200FungiSpeciesShared,
cristianoRep200BacteriaSpeciesShared),
dataString = "fungi_and_bacteria_intersected_with_Weizmann",
col2Predict = "cancer_status",
numResampleIter = 10,
varImpFlag = FALSE)
save(mlFungiBacteriaWISIntersect_CV, file = "Interim_data/hopkins_mlFungiBacteriaWISIntersect_CV_4Apr22.RData")
mlBacteriaWISIntersect_CV <- mlCristiano(metaData = metaCristianoTxNaiveFilt,
countData = cristianoRep200BacteriaSpeciesShared,
dataString = "bacteria_intersected_with_Weizmann",
col2Predict = "cancer_status",
numResampleIter = 10,
varImpFlag = FALSE)
mlFungiWISIntersect_CV <- mlCristiano(metaData = metaCristianoTxNaiveFilt,
countData = cristianoRep200FungiSpeciesShared,
dataString = "fungi_intersected_with_Weizmann",
col2Predict = "cancer_status",
numResampleIter = 10,
varImpFlag = FALSE)
mlFungiDecontam_CV <- mlCristiano(metaData = metaCristianoTxNaiveFilt,
countData = cristiano_rep200Data_Filt_Fungi_Decontam,
dataString = "fungi_intersected_with_Weizmann",
col2Predict = "cancer_status",
numResampleIter = 10,
varImpFlag = FALSE)
#----------Identify top X signature----------#
load("Interim_data/decontamResultsV2_25Mar22.RData")
topXNum <- 20
topXHopkinsSig <- decontamResultsV2[head(mlFungiDecontam_CV$varImp$Taxa,topXNum),c("species","reason")]
save(topXHopkinsSig, file = "Interim_data/topXHopkinsSig_13Nov21.RData")
topXHopkinsSig %>% write.csv(file = "Figures/Main_Figures/topXHopkinsSig.csv")
topXHopkinsData <- cristiano_rep200Data_Filt_Fungi_Decontam[,rownames(topXHopkinsSig)]
mlFungiDecontam_CV_topFeat <- mlCristiano(metaData = metaCristianoTxNaiveFilt,
countData = topXHopkinsData,
dataString = "fungi_intersected_with_Weizmann",
col2Predict = "cancer_status",
numResampleIter = 10,
varImpFlag = FALSE)
hopkinsFungi_topX <- mlFungiDecontam_CV_topFeat
save(hopkinsFungi_topX, file = "Interim_data/cristianoFungi_topX_ML_model_15Nov21.RData")
#--------------------------------------------#
plots_mlFullDB_CV <- plotMLWithCIs(mlFullDB_CV,
showRepCurves=TRUE,
sizeAvgCurve=0.5,
sizeRepCurves = 0.25,
ciAlpha = 0.4,
colorAvgCurve = "#BC3C29FF", # red
colorRepCurves = "darksalmon",
ciFillColor = "red",
ciLevel = 0.99)
plots_mlFungiBacteriaWISIntersect_CV <- plotMLWithCIs(mlFungiBacteriaWISIntersect_CV,
showRepCurves=TRUE,
sizeAvgCurve=0.5,
sizeRepCurves = 0.25,
ciAlpha = 0.4,
colorAvgCurve = "#0072B5FF", # blue
colorRepCurves = "lightblue",
ciFillColor = "blue",
ciLevel = 0.99)
plots_mlBacteriaWISIntersect_CV <- plotMLWithCIs(mlBacteriaWISIntersect_CV,
showRepCurves=TRUE,
sizeAvgCurve=0.5,
sizeRepCurves = 0.25,
ciAlpha = 0.4,
colorAvgCurve = "#631879", # purple
ciFillColor = "purple",
ciLevel = 0.99)
plots_mlFungiWISIntersect_CV <- plotMLWithCIs(mlFungiWISIntersect_CV,
showRepCurves=TRUE,
sizeAvgCurve=0.5,
sizeRepCurves = 0.25,
ciAlpha = 0.4,
colorAvgCurve = "#631879", # purple
ciFillColor = "purple",
ciLevel = 0.99)
plots_mlFungiDecontam_CV <- plotMLWithCIs(mlFungiDecontam_CV,
sizeAvgCurve=0.5,
showRepCurves=TRUE,
ciAlpha = 0.4,
sizeRepCurves = 0.25,
colorAvgCurve = "#E18727FF", # orange
colorRepCurves = "orange",
ciFillColor = "orange",
ciLevel = 0.99)
plots_mlFungiDecontam_CV_topFeat <- plotMLWithCIs(mlFungiDecontam_CV_topFeat,
sizeAvgCurve=0.5,
showRepCurves=TRUE,
ciAlpha = 0.4,
sizeRepCurves = 0.25,
colorAvgCurve = "#631879", # purple
ciFillColor = "purple",
ciLevel = 0.99)
save(mlFullDB_CV,
mlFungiDecontam_CV,
mlFungiBacteriaWISIntersect_CV,
plots_mlFullDB_CV,
plots_mlFungiBacteriaWISIntersect_CV,
plots_mlFungiDecontam_CV,
file = "Interim_data/cristiano_CV10_overlay_data_and_plots_4Apr22.RData")
# Combine ROC curves
rocCombined <- plots_mlFungiBacteriaWISIntersect_CV$rocPlot
for(ii in 1:10){
rocCombined <- rocCombined +
geom_path(data = plots_mlFullDB_CV$rocCurveData[[ii]],aes(x=fpr,y=tpr), color = "darksalmon", size = 0.25) +
geom_path(data = plots_mlFungiDecontam_CV$rocCurveData[[ii]],aes(x=fpr,y=tpr), color = "orange", size = 0.25)
}
rocCombinedAll <- rocCombined +
geom_ribbon(data = plots_mlFullDB_CV$interpROCYDf_CI, aes(x = xval, ymin = CI.lower, ymax = CI.upper),
fill = "red", alpha = 0.3, inherit.aes = F) +
geom_path(data = plots_mlFullDB_CV$interpROCYDf_CI, aes(x = xval, y = Estimate), color = "#BC3C29FF", size = 0.5) +
geom_ribbon(data = plots_mlFungiDecontam_CV$interpROCYDf_CI, aes(x = xval, ymin = CI.lower, ymax = CI.upper),
fill = "orange", alpha = 0.3, inherit.aes = F) + theme_bw() +
geom_path(data = plots_mlFungiDecontam_CV$interpROCYDf_CI, aes(x = xval, y = Estimate), color = "#E18727FF", size = 0.5) +
annotate("segment", x = 0.35, xend = 0.45, y = 0.2, yend = 0.2, color = "#BC3C29FF") +
annotate("text", x = 0.47, y = 0.2, color = "#BC3C29FF", label = paste0("AUROC 99% CI: [",
paste0(100*round(plots_mlFullDB_CV$aurocCI[2],4),
", ",100*round(plots_mlFullDB_CV$aurocCI[3],4)),"]"), hjust = 0) +
annotate("segment", x = 0.35, xend = 0.45, y = 0.15, yend = 0.15, color = "#0072B5FF") +
annotate("text", x = 0.47, y = 0.15, color = "#0072B5FF", label = paste0("AUROC 99% CI: [",
paste0(100*round(plots_mlFungiBacteriaWISIntersect_CV$aurocCI[2],4),
", ",100*round(plots_mlFungiBacteriaWISIntersect_CV$aurocCI[3],4)),"]"), hjust = 0) +
annotate("segment", x = 0.35, xend = 0.45, y = 0.1, yend = 0.1, color = "#E18727FF") +
annotate("text", x = 0.47, y = 0.1, color = "#E18727FF", label = paste0("AUROC 99% CI: [",
paste0(100*round(plots_mlFungiDecontam_CV$aurocCI[2],4),
", ",100*round(plots_mlFungiDecontam_CV$aurocCI[3],4)),"]"), hjust = 0)
# Combine PR curves
prCombined <- plots_mlFungiBacteriaWISIntersect_CV$prPlot
for(ii in 1:10){
prCombined <- prCombined +
geom_path(data = plots_mlFullDB_CV$prCurveData[[ii]],aes(x=recall,y=precision), color = "darksalmon", size = 0.25) +
geom_path(data = plots_mlFungiDecontam_CV$prCurveData[[ii]],aes(x=recall,y=precision), color = "orange", size = 0.25)
}
prCombinedAll <- prCombined +
geom_ribbon(data = plots_mlFullDB_CV$interpPRYDf_CI, aes(x = xval, ymin = CI.lower, ymax = CI.upper),
fill = "red", alpha = 0.3, inherit.aes = F) +
geom_path(data = plots_mlFullDB_CV$interpPRYDf_CI, aes(x = xval, y = Estimate), color = "#BC3C29FF", size = 0.5) +
geom_ribbon(data = plots_mlFungiDecontam_CV$interpPRYDf_CI, aes(x = xval, ymin = CI.lower, ymax = CI.upper),
fill = "orange", alpha = 0.3, inherit.aes = F) + theme_bw() +
geom_path(data = plots_mlFungiDecontam_CV$interpPRYDf_CI, aes(x = xval, y = Estimate), color = "#E18727FF", size = 0.5) +
annotate("segment", x = 0.15, xend = 0.25, y = 0.2, yend = 0.2, color = "#BC3C29FF") +
annotate("text", x = 0.27, y = 0.2, color = "#BC3C29FF", label = paste0("AUPR 99% CI: [",
paste0(100*round(plots_mlFullDB_CV$auprCI[2],4),
", ",100*round(plots_mlFullDB_CV$auprCI[3],4)),"]"), hjust = 0) +
annotate("segment", x = 0.15, xend = 0.25, y = 0.15, yend = 0.15, color = "#0072B5FF") +
annotate("text", x = 0.27, y = 0.15, color = "#0072B5FF", label = paste0("AUPR 99% CI: [",
paste0(100*round(plots_mlFungiBacteriaWISIntersect_CV$auprCI[2],4),
", ",100*round(plots_mlFungiBacteriaWISIntersect_CV$auprCI[3],4)),"]"), hjust = 0) +
annotate("segment", x = 0.15, xend = 0.25, y = 0.1, yend = 0.1, color = "#E18727FF") +
annotate("text", x = 0.27, y = 0.1, color = "#E18727FF", label = paste0("AUPR 99% CI: [",
paste0(100*round(plots_mlFungiDecontam_CV$auprCI[2],4),
", ",100*round(plots_mlFungiDecontam_CV$auprCI[3],4)),"]"), hjust = 0)
combinedPlotTitle <- paste0("Hopkins plasma cohort: Cancer vs Healthy (10-fold CV repeated 10 times)")
combinedOverlayPlots <- ggarrange(rocCombinedAll, prCombinedAll, ncol = 2)
combinedOverlayPlotsAnnotated <- annotate_figure(combinedOverlayPlots,
top = text_grob(combinedPlotTitle,
color = "black", face = "bold", size = 14))
print(combinedOverlayPlotsAnnotated)
ggsave(filename = "Figures/Main_Figures/roc_pr_CV_overlay_cristiano_full_WIS_fungionly.svg",
units = "in", width = 10, height = 5)
#--------------------Overlay topX model with decontaminated model--------------------#
# Combine ROC curves
rocCombinedTopX <- plots_mlFungiDecontam_CV_topFeat$rocPlot
for(ii in 1:10){
rocCombinedTopX <- rocCombinedTopX +
geom_path(data = plots_mlFungiDecontam_CV$rocCurveData[[ii]],aes(x=fpr,y=tpr), color = "lightgray", size = 0.25)
}
rocCombinedTopXAll <- rocCombinedTopX +
geom_ribbon(data = plots_mlFungiDecontam_CV$interpROCYDf_CI, aes(x = xval, ymin = CI.lower, ymax = CI.upper),
fill = "orange", alpha = 0.3, inherit.aes = F) + theme_bw() +
geom_path(data = plots_mlFungiDecontam_CV$interpROCYDf_CI, aes(x = xval, y = Estimate), color = "#E18727FF", size = 0.5) +
annotate("segment", x = 0.25, xend = 0.35, y = 0.15, yend = 0.15, color = "#631879") +
annotate("text", x = 0.37, y = 0.15, color = "#631879", label = paste0("AUROC 99% CI: [",
paste0(100*round(plots_mlFungiDecontam_CV_topFeat$aurocCI[2],4),
", ",100*round(plots_mlFungiDecontam_CV_topFeat$aurocCI[3],4)),"]"), hjust = 0) +
annotate("segment", x = 0.25, xend = 0.35, y = 0.1, yend = 0.1, color = "#E18727FF") +
annotate("text", x = 0.37, y = 0.1, color = "#E18727FF", label = paste0("AUROC 99% CI: [",
paste0(100*round(plots_mlFungiDecontam_CV$aurocCI[2],4),
", ",100*round(plots_mlFungiDecontam_CV$aurocCI[3],4)),"]"), hjust = 0)
# Combine PR curves
prCombinedTopX <- plots_mlFungiDecontam_CV_topFeat$prPlot
for(ii in 1:10){
prCombinedTopX <- prCombinedTopX +
geom_path(data = plots_mlFungiDecontam_CV$prCurveData[[ii]],aes(x=recall,y=precision), color = "orange", size = 0.25)
}
prCombinedTopXAll <- prCombinedTopX +
geom_ribbon(data = plots_mlFungiDecontam_CV$interpPRYDf_CI, aes(x = xval, ymin = CI.lower, ymax = CI.upper),
fill = "orange", alpha = 0.3, inherit.aes = F) + theme_bw() +
geom_path(data = plots_mlFungiDecontam_CV$interpPRYDf_CI, aes(x = xval, y = Estimate), color = "#E18727FF", size = 0.5) +
annotate("segment", x = 0.1, xend = 0.2, y = 0.15, yend = 0.15, color = "#631879") +
annotate("text", x = 0.22, y = 0.15, color = "#631879", label = paste0("AUPR 99% CI: [",
paste0(100*round(plots_mlFungiDecontam_CV_topFeat$auprCI[2],4),
", ",100*round(plots_mlFungiDecontam_CV_topFeat$auprCI[3],4)),"]"), hjust = 0) +
annotate("segment", x = 0.1, xend = 0.2, y = 0.1, yend = 0.1, color = "#E18727FF") +
annotate("text", x = 0.22, y = 0.1, color = "#E18727FF", label = paste0("AUPR 99% CI: [",
paste0(100*round(plots_mlFungiDecontam_CV$auprCI[2],4),
", ",100*round(plots_mlFungiDecontam_CV$auprCI[3],4)),"]"), hjust = 0)
combinedPlotTitleTopX <- paste0("Hopkins plasma cohort: Cancer vs Healthy (10-fold CV repeated 10 times)\n",
"Top ",topXNum," fungi used (purple) vs. decontaminated dataset with 209 fungi (green)")
combinedOverlayPlotsTopX <- ggarrange(rocCombinedTopXAll, prCombinedTopXAll, ncol = 2)
combinedOverlayPlotsAnnotatedTopX <- annotate_figure(combinedOverlayPlotsTopX,
top = text_grob(combinedPlotTitleTopX,
color = "black", face = "bold", size = 14))
print(combinedOverlayPlotsAnnotatedTopX)
ggsave(filename = "Figures/Supplementary_Figures/roc_pr_CV_overlay_cristiano_fungi_decontam_vs_topX.svg",
units = "in", width = 10, height = 5)
#--------------------Overlay WIS fungi, bacteria, fungi+bacteria--------------------#
synergyWISDf <- data.frame(AUROC = c(plots_mlFungiWISIntersect_CV$auroc,
plots_mlBacteriaWISIntersect_CV$auroc,
plots_mlFungiBacteriaWISIntersect_CV$auroc),
AUPR = c(plots_mlFungiWISIntersect_CV$aupr,
plots_mlBacteriaWISIntersect_CV$aupr,
plots_mlFungiBacteriaWISIntersect_CV$aupr),
Dataset = c(rep("Fungi",10),
rep("Bacteria",10),
rep("Fungi+Bacteria",10)))
source("Supporting_scripts/S00-SummarySE.R") # Contains a function that calculates std error and 95% confidence intervals
synergyWISDf %>%
reshape2::melt(id.vars = c("Dataset")) %>%
summarySE(measurevar = "value", groupvars = c("variable","Dataset")) %>%
ggplot(aes(reorder(Dataset, value, FUN=median),value, color=Dataset)) +
facet_wrap(~variable) +
geom_errorbar(aes(ymin=ifelse(value-ci<0,0,value-ci), ymax=ifelse(value+ci>1,1,value+ci)),
width=0.2,size=0.6,position = position_dodge(0.9)) +
geom_point(position = position_dodge(0.9), size=0.5) +
xlab("Cancer type") + ylab("Area Under Curve") + theme_pubr() + scale_color_nejm()
require(rstatix)
synergyWISDf %>%
wilcox_test(AUROC ~ Dataset) %>%
adjust_pvalue() %>%
add_significance() %>%
add_xy_position(group = "Dataset") -> roc.stat
synergyWISDf %>%
ggerrorplot(x = "Dataset",
y = "AUROC",
add = "jitter",
color = "Dataset",
legend = "none",
xlab = "WIS ∩ feature set",
size = 0.1,
ci = 0.99,
palette = "nejm",
add.params = list(alpha=0.4)) +
stat_pvalue_manual(data = roc.stat,
label = "Wilcoxon, q = {p.adj}") -> roc.plot
synergyWISDf %>%
filter(!grepl("Fungi$",Dataset)) %>%
ggerrorplot(x = "Dataset",
y = "AUROC",
add = "jitter",
color = "Dataset",
legend = "none",
xlab = "",
ylab = "",
ylim = c(0.945, 0.968),
size = 0.5,
ci = 0.99,
palette = c("#0072B5FF","#E18727FF"),
add.params = list(alpha=0.4)) +
stat_compare_means(method = "wilcox",
comparisons = list(c("Bacteria","Fungi+Bacteria")),
label = "p.signif") -> roc.plot.inset
print(roc.plot.inset)
ggsave(filename = "Figures/Supplementary_Figures/hopkins_synergy_CvsH_plots_roc_inset.svg",
dpi = "retina", units = "in", width = 3, height = 4)
synergyWISDf %>%
wilcox_test(AUPR ~ Dataset) %>%
adjust_pvalue() %>%
add_significance() %>%
add_xy_position(group = "Dataset") -> pr.stat
synergyWISDf %>%
ggerrorplot(x = "Dataset",
y = "AUPR",
add = "jitter",
color = "Dataset",
legend = "none",
xlab = "WIS ∩ feature set",
size = 0.1,
ci = 0.99,
palette = "nejm",
add.params = list(alpha=0.4)) +
stat_pvalue_manual(data = pr.stat,
label = "Wilcoxon, q = {p.adj}") -> pr.plot
synergyWISDf %>%
filter(!grepl("Fungi$",Dataset)) %>%
ggerrorplot(x = "Dataset",
y = "AUPR",
add = "jitter",
color = "Dataset",
legend = "none",
xlab = "",
ylab = "",
size = 0.5,
ci = 0.99,
ylim = c(0.955, 0.970),
palette = c("#0072B5FF","#E18727FF"),
add.params = list(alpha=0.4)) +
stat_compare_means(method = "wilcox",
comparisons = list(c("Bacteria","Fungi+Bacteria")),
label = "p.signif") -> pr.plot.inset
print(pr.plot.inset)
ggsave(filename = "Figures/Supplementary_Figures/hopkins_synergy_CvsH_plots_pr_inset.svg",
dpi = "retina", units = "in", width = 3, height = 4)
combinedSynergyWISPlot <- ggarrange(roc.plot, pr.plot, ncol = 2)
print(combinedSynergyWISPlot)
ggsave(filename = "Figures/Supplementary_Figures/hopkins_synergy_CvsH_plots.svg",
dpi = "retina", units = "in", width = 8, height = 6)
#---------------------------------------------------------------------------------------------------------------------------#
# ML perf each cancer vs. healthy -- all datasets
#---------------------------------------------------------------------------------------------------------------------------#
source("00-Functions.R") # for the ml1VsAllCristiano10kRep1_Iterate() function
# The following command may take a while (10-30 min) to run
cristianoPerCancerIterate <- ml1VsAllCristiano10kRep1_Iterate()
cristianoPerCancerIterate_results <- cristianoPerCancerIterate$rep_perf
cristianoPerCancerIterate_results$nullAUROC <- 0.5
cristianoPerCancerIterate_results$nullAUPR <- cristianoPerCancerIterate_results$minorityClassSize/
(cristianoPerCancerIterate_results$minorityClassSize+cristianoPerCancerIterate_results$majorityClassSize)
colnames(cristianoPerCancerIterate_results)[1:2] <- c("AUROC","AUPR")
cristianoPerCancerIterate_results$dataString[cristianoPerCancerIterate_results$dataString=="full_rep200"] <- "Full multikingdom database (rep200)"
cristianoPerCancerIterate_results$dataString[cristianoPerCancerIterate_results$dataString=="bacteria_only"] <- "Bacteria all (Species)"
cristianoPerCancerIterate_results$dataString[cristianoPerCancerIterate_results$dataString=="fungi_only"] <- "Fungi all (Species)"
cristianoPerCancerIterate_results$dataString[cristianoPerCancerIterate_results$dataString=="fungi_decontam"] <- "Fungi decontaminated (Species)"
cristianoPerCancerIterate_results$dataString[cristianoPerCancerIterate_results$dataString=="fungi_intersected_with_Weizmann"] <- "Fungi ∩ WIS (Species)"
cristianoPerCancerIterate_results$dataString[cristianoPerCancerIterate_results$dataString=="bacteria_intersected_with_Weizmann"] <- "Bacteria ∩ WIS (Species)"
cristianoPerCancerIterate_results$dataString[cristianoPerCancerIterate_results$dataString=="fungi_and_bacteria_intersected_with_Weizmann"] <- "Fungi+bacteria ∩ WIS (Species)"
cristianoPerCancerIterate_results$dataString[cristianoPerCancerIterate_results$dataString=="topX_fungi"] <- "Top 20 fungi (Species)"
cristianoPerCancerIterate_results$dataString <- factor(cristianoPerCancerIterate_results$dataString, levels = c("Full multikingdom database (rep200)",
"Fungi+bacteria ∩ WIS (Species)",
"Bacteria all (Species)",
"Fungi all (Species)",
"Fungi decontaminated (Species)",
"Fungi ∩ WIS (Species)",
"Bacteria ∩ WIS (Species)",
"Top 20 fungi (Species)"))
cristianoPerCancerIterate_results$diseaseType <- gsub(" cancer| Cancer","",cristianoPerCancerIterate_results$diseaseType)
save(cristianoPerCancerIterate_results,
file = "Interim_data/cristianoPerCancerIterate_results_13Nov21.RData")
## Overlay multiple data types on the same graph
source("Supporting_scripts/S00-SummarySE.R")
cristianoPerCancerIterate_results %>%
filter(grepl("Full|\\+|decontam|Top",dataString)) %>%
# filter(grepl("\\+|Bacteria ∩",dataString)) %>%
reshape2::melt(id.vars = c("rep","dataString","minorityClassSize","majorityClassSize","diseaseType","col2Predict","nullAUPR","nullAUROC")) %>%
summarySE(measurevar = "value", groupvars = c("variable","dataString","minorityClassSize","majorityClassSize","diseaseType","col2Predict","nullAUPR","nullAUROC")) %>%
mutate(nullAUPR = ifelse(variable=="AUROC",NA,nullAUPR), nullAUROC = ifelse(variable=="AUPR",NA,nullAUROC)) %>%
ggplot(aes(reorder(diseaseType, value, FUN=median),value, color=dataString)) +
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="solid", position = position_dodge(0.9)) +
geom_errorbar(aes(y=nullAUROC,ymin=nullAUROC,ymax=nullAUROC),color="darkgray",lty="dotted") +
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)) +
guides(color=guide_legend(nrow=2, byrow=TRUE)) +
ggtitle("Hopkins plasma validation cohort:\nPer cancer type vs. healthy performance") + 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/Main_Figures/cristiano_per_cancer_type_vs_healthy_full_WIS_fungi_topX_datasets_13Nov21.svg",
dpi = "retina", width = 8, height = 4.5, units = "in")
# #----------Testing WIS fungi+bacteria vs. WIS bacteria
# cristianoPerCancerIterate_results %>%
# filter(grepl("\\+|Bacteria ∩",dataString)) %>%
# filter(diseaseType %in% c("Breast","Gastric")) %>%
# ggboxplot(x = "dataString",
# y = "AUPR",
# fill = "dataString",
# notch = TRUE) +
# stat_compare_means(method = "wilcox", label.y = 1.1)
## Subset to decontaminated fungi
cristianoPerCancerIterate_results %>%
filter(grepl("decontam",dataString)) %>%
reshape2::melt(id.vars = c("rep","dataString","minorityClassSize","majorityClassSize","diseaseType","col2Predict","nullAUPR","nullAUROC")) %>%
summarySE(measurevar = "value", groupvars = c("variable","dataString","minorityClassSize","majorityClassSize","diseaseType","col2Predict","nullAUPR","nullAUROC")) %>%
mutate(nullAUPR = ifelse(variable=="AUROC",NA,nullAUPR), nullAUROC = ifelse(variable=="AUPR",NA,nullAUROC)) %>%
ggplot(aes(reorder(diseaseType, value, FUN=median),value, color=variable)) +
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),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)) +
# guides(color=guide_legend(nrow=2, byrow=TRUE)) +
ggtitle("Hopkins plasma validation cohort:\nPer cancer type vs. healthy performance using fungi") + 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/cristiano_per_cancer_type_vs_healthy_fungi_decontam_only_13Nov21.svg",
dpi = "retina", width = 7, height = 4.5, units = "in")
cristianoPerCancerIterate_results %>%
filter(grepl("decontam",dataString)) %>%
pull(AUROC) %>% ci()
# Estimate CI lower CI upper Std. Error
# 0.77668498 0.74385524 0.80951472 0.01645646
cristianoPerCancerIterate_results %>%
filter(grepl("decontam",dataString)) %>%
filter(grepl("Breast",diseaseType)) %>%
pull(AUROC) %>% ci()
# Estimate CI lower CI upper Std. Error
# 0.8746154 0.8139667 0.9352640 0.0268101
cristianoPerCancerIterate_results %>%
filter(grepl("Top",dataString)) %>%
pull(AUROC) %>% ci()
# Estimate CI lower CI upper Std. Error
# 0.78840659 0.75768774 0.81912545 0.01539834
## Subset to decontaminated and topX fungi
cristianoPerCancerIterate_results %>%
filter(grepl("decontam|Top",dataString)) %>%
reshape2::melt(id.vars = c("rep","dataString","minorityClassSize","majorityClassSize","diseaseType","col2Predict","nullAUPR","nullAUROC")) %>%
summarySE(measurevar = "value", groupvars = c("variable","dataString","minorityClassSize","majorityClassSize","diseaseType","col2Predict","nullAUPR","nullAUROC")) %>%
mutate(nullAUPR = ifelse(variable=="AUROC",NA,nullAUPR), nullAUROC = ifelse(variable=="AUPR",NA,nullAUROC)) %>%
ggplot(aes(reorder(diseaseType, value, FUN=median),value, color=dataString)) +
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="solid",position = position_dodge(0.9)) +
geom_errorbar(aes(y=nullAUROC,ymin=nullAUROC,ymax=nullAUROC),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)) +
# guides(color=guide_legend(nrow=2, byrow=TRUE)) +
ggtitle("Hopkins plasma validation cohort:\nPer cancer type vs. healthy performance using fungi") + 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/hopkins_per_cancer_type_vs_healthy_fungi_decontam_and_TopX_13Nov21.svg",
dpi = "retina", width = 7, height = 4.5, units = "in")
#---------------------------------------------------------------------------------------------------------------------------#
# ML perf between cancer types -- all datasets
#---------------------------------------------------------------------------------------------------------------------------#
source("00-Functions.R") # for the ml1VsAllCristiano10kRep1_Iterate() function
# NOTE: Remove healthy samples and the 1 duodenal cancer sample
metaCristianoTxNaiveFilt_CancerOnly <- metaCristianoTxNaiveFilt %>%
# filter(!(phenotype %in% c("Healthy","Duodenal Cancer"))) %>%
filter(!(phenotype %in% c("Healthy"))) %>%
droplevels()
# The following command may take a while (10-20 min) to run
cristianoBtwnCancerIterate <- ml1VsAllCristiano10kRep1_Iterate(metaData = metaCristianoTxNaiveFilt_CancerOnly,
col2Predict = "phenotype")
cristianoBtwnCancerIterate_results <- cristianoBtwnCancerIterate$rep_perf
cristianoBtwnCancerIterate_results$nullAUROC <- 0.5
cristianoBtwnCancerIterate_results$nullAUPR <- cristianoBtwnCancerIterate_results$minorityClassSize/
(cristianoBtwnCancerIterate_results$minorityClassSize+cristianoBtwnCancerIterate_results$majorityClassSize)
colnames(cristianoBtwnCancerIterate_results)[1:2] <- c("AUROC","AUPR")
cristianoBtwnCancerIterate_results$dataString[cristianoBtwnCancerIterate_results$dataString=="full_rep200"] <- "Full multikingdom database (rep200)"
cristianoBtwnCancerIterate_results$dataString[cristianoBtwnCancerIterate_results$dataString=="bacteria_only"] <- "Bacteria all (Species)"
cristianoBtwnCancerIterate_results$dataString[cristianoBtwnCancerIterate_results$dataString=="fungi_only"] <- "Fungi all (Species)"
cristianoBtwnCancerIterate_results$dataString[cristianoBtwnCancerIterate_results$dataString=="fungi_decontam"] <- "Fungi decontaminated (Species)"
cristianoBtwnCancerIterate_results$dataString[cristianoBtwnCancerIterate_results$dataString=="fungi_intersected_with_Weizmann"] <- "Fungi ∩ WIS (Species)"
cristianoBtwnCancerIterate_results$dataString[cristianoBtwnCancerIterate_results$dataString=="bacteria_intersected_with_Weizmann"] <- "Bacteria ∩ WIS (Species)"
cristianoBtwnCancerIterate_results$dataString[cristianoBtwnCancerIterate_results$dataString=="fungi_and_bacteria_intersected_with_Weizmann"] <- "Fungi+bacteria ∩ WIS (Species)"
cristianoBtwnCancerIterate_results$dataString[cristianoBtwnCancerIterate_results$dataString=="topX_fungi"] <- "Top 20 fungi (Species)"
cristianoBtwnCancerIterate_results$dataString <- factor(cristianoBtwnCancerIterate_results$dataString, levels = c("Full multikingdom database (rep200)",
"Fungi+bacteria ∩ WIS (Species)",
"Bacteria all (Species)",
"Fungi all (Species)",
"Fungi decontaminated (Species)",
"Fungi ∩ WIS (Species)",
"Bacteria ∩ WIS (Species)",
"Top 20 fungi (Species)"))
cristianoBtwnCancerIterate_results$diseaseType <- gsub(" cancer| Cancer","",cristianoBtwnCancerIterate_results$diseaseType)
save(cristianoBtwnCancerIterate_results,
file = "Interim_data/cristianoBtwnCancerIterate_results_13Nov21.RData")
## Overlay multiple data types on the same graph
# NOTE: TopX fungi were selected based on cancer vs healthy comparisons
# so they are not plotted here
source("Supporting_scripts/S00-SummarySE.R")
cristianoBtwnCancerIterate_results %>%
filter(grepl("Full|\\+|decontam",dataString)) %>%
# filter(grepl("\\+|Bacteria ∩",dataString)) %>%
reshape2::melt(id.vars = c("rep","dataString","minorityClassSize","majorityClassSize","diseaseType","col2Predict","nullAUPR","nullAUROC")) %>%
summarySE(measurevar = "value", groupvars = c("variable","dataString","minorityClassSize","majorityClassSize","diseaseType","col2Predict","nullAUPR","nullAUROC")) %>%
mutate(nullAUPR = ifelse(variable=="AUROC",NA,nullAUPR), nullAUROC = ifelse(variable=="AUPR",NA,nullAUROC)) %>%
ggplot(aes(reorder(diseaseType, value, FUN=median),value, color=dataString)) +
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="solid", position = position_dodge(0.9)) +
geom_errorbar(aes(y=nullAUROC,ymin=nullAUROC,ymax=nullAUROC),color="darkgray",lty="dotted") +
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)) +
guides(color=guide_legend(nrow=2, byrow=TRUE)) +
ggtitle("Hopkins plasma validation cohort:\nOne cancer type vs all others") + 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/Supplementary_Figures/hopkins_between_cancer_types_full_WIS_fungi_datasets_13Nov21.svg",
dpi = "retina", width = 8, height = 5, units = "in")
## Subset to decontaminated fungi
cristianoBtwnCancerIterate_results %>%
filter(grepl("decontam",dataString)) %>%
reshape2::melt(id.vars = c("rep","dataString","minorityClassSize","majorityClassSize","diseaseType","col2Predict","nullAUPR","nullAUROC")) %>%
summarySE(measurevar = "value", groupvars = c("variable","dataString","minorityClassSize","majorityClassSize","diseaseType","col2Predict","nullAUPR","nullAUROC")) %>%
mutate(nullAUPR = ifelse(variable=="AUROC",NA,nullAUPR), nullAUROC = ifelse(variable=="AUPR",NA,nullAUROC)) %>%
ggplot(aes(reorder(diseaseType, value, FUN=median),value, color=variable)) +
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),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)) +
# guides(color=guide_legend(nrow=2, byrow=TRUE)) +
ggtitle("Hopkins plasma validation cohort:\nOne cancer type vs all others") + 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/hopkins_between_cancer_types_fungi_only_13Nov21.svg",
dpi = "retina", width = 6.5, height = 4, units = "in")
cristianoBtwnCancerIterate_results %>%
filter(grepl("Full",dataString)) %>%
pull(AUROC) %>% ci()
# Estimate CI lower CI upper Std. Error
# 0.90471525 0.87310032 0.93633018 0.01584752
cristianoBtwnCancerIterate_results %>%
filter(grepl("\\+",dataString)) %>%
pull(AUROC) %>% ci()
# Estimate CI lower CI upper Std. Error
# 0.78742888 0.75300854 0.82184923 0.01725378
cristianoBtwnCancerIterate_results %>%
filter(grepl("decontam",dataString)) %>%
pull(AUROC) %>% ci()
# Estimate CI lower CI upper Std. Error
# 0.68447299 0.64259177 0.72635421 0.02099367
#---------------------------------------------------------------------------------------------------------------------------#
# Test ML perf at varying stages levels
#---------------------------------------------------------------------------------------------------------------------------#
source("00-Functions.R") # for the ml1VsAllCristiano10kRep1_Iterate_Stage() function
# The following command may take a while (10-30 min) to run
cristianoStageIterate <- ml1VsAllCristiano10kRep1_Iterate_Stage()
cristianoStageIterate_results <- cristianoStageIterate$rep_perf
colnames(cristianoStageIterate_results)[1:2] <- c("AUROC","AUPR")
cristianoStageIterate_results$nullAUROC <- 0.5
cristianoStageIterate_results$nullAUPR <- cristianoStageIterate_results$minorityClassSize/
(cristianoStageIterate_results$minorityClassSize+cristianoStageIterate_results$majorityClassSize)
cristianoStageIterate_results$dataString[cristianoStageIterate_results$dataString=="full_rep200"] <- "Full multikingdom database (rep200)"
cristianoStageIterate_results$dataString[cristianoStageIterate_results$dataString=="bacteria_only"] <- "Bacteria all (Species)"