-
Notifications
You must be signed in to change notification settings - Fork 15
/
05R-Prepare-TCGA-data-for-machine-learning.R
executable file
·5928 lines (5558 loc) · 503 KB
/
05R-Prepare-TCGA-data-for-machine-learning.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
#-----------------------------------------------------------------------------
# 05B-Prepare-TCGA-data-for-machine-learning.R
# Copyright (c) 2021--, Greg Poore
# Purposes:
# - Aggregate counts to higher taxa levels
# - Prepare TCGA data for machine learning analyses
# - Plot machine learning results
#-----------------------------------------------------------------------------
#----------------------------------------------------------#
# 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 and convert to phyloseq object
#----------------------------------------------------------#
load("Interim_data/snmDataFungi_DecontamV2_25Mar22.RData", verbose = T)
rep200TaxSplit <- read.csv("Supporting_data/rep200_lineage_map_split.csv", stringsAsFactors = FALSE, row.names = 1)
#--------------------------------------------------------------------------------------------------------------------#
# Separate raw data into seq center-experimental strategy groups (to preclude needing batch correction)
#--------------------------------------------------------------------------------------------------------------------#
metaQiitaCombined_Nonzero_DecontamV2 %>% count(data_submitting_center_label, experimental_strategy)
#--------------------Subset metadata--------------------#
# WGS (note that Broad has both WGS and RNA, so separate objects are made for both)
metaQiitaCombined_Nonzero_DecontamV2_HMS <- metaQiitaCombined_Nonzero_DecontamV2 %>% filter(data_submitting_center_label == "Harvard Medical School") %>% droplevels()
metaQiitaCombined_Nonzero_DecontamV2_BCM <- metaQiitaCombined_Nonzero_DecontamV2 %>% filter(data_submitting_center_label == "Baylor College of Medicine") %>% droplevels()
metaQiitaCombined_Nonzero_DecontamV2_MDA <- metaQiitaCombined_Nonzero_DecontamV2 %>% filter(data_submitting_center_label == "MD Anderson - Institute for Applied Cancer Science") %>% droplevels()
metaQiitaCombined_Nonzero_DecontamV2_WashU <- metaQiitaCombined_Nonzero_DecontamV2 %>% filter(data_submitting_center_label == "Washington University School of Medicine") %>% droplevels()
metaQiitaCombined_Nonzero_DecontamV2_Broad_WGS <- metaQiitaCombined_Nonzero_DecontamV2 %>%
filter(data_submitting_center_label == "Broad Institute of MIT and Harvard") %>%
filter(experimental_strategy == "WGS") %>% droplevels()
# RNA-Seq (note that Broad has both WGS and RNA-Seq, so separate objects are made for both)
metaQiitaCombined_Nonzero_DecontamV2_UNC <- metaQiitaCombined_Nonzero_DecontamV2 %>% filter(data_submitting_center_label == "University of North Carolina") %>% droplevels()
metaQiitaCombined_Nonzero_DecontamV2_CMS <- metaQiitaCombined_Nonzero_DecontamV2 %>% filter(data_submitting_center_label == "Canada's Michael Smith Genome Sciences Centre") %>% droplevels()
metaQiitaCombined_Nonzero_DecontamV2_Broad_RNA <- metaQiitaCombined_Nonzero_DecontamV2 %>%
filter(data_submitting_center_label == "Broad Institute of MIT and Harvard") %>%
filter(experimental_strategy == "RNA-Seq") %>% droplevels()
#--------------------Subset count data--------------------#
# WGS (note that Broad has both WGS and RNA, so separate objects are made for both)
rep200_HiSeq_Fungi_DecontamV2_HMS <- rep200Data_WGS_RNA_HiSeq_Fungi_DecontamV2_Nonzero[rownames(metaQiitaCombined_Nonzero_DecontamV2_HMS),]
rep200_HiSeq_Fungi_DecontamV2_BCM <- rep200Data_WGS_RNA_HiSeq_Fungi_DecontamV2_Nonzero[rownames(metaQiitaCombined_Nonzero_DecontamV2_BCM),]
rep200_HiSeq_Fungi_DecontamV2_MDA <- rep200Data_WGS_RNA_HiSeq_Fungi_DecontamV2_Nonzero[rownames(metaQiitaCombined_Nonzero_DecontamV2_MDA),]
rep200_HiSeq_Fungi_DecontamV2_WashU <- rep200Data_WGS_RNA_HiSeq_Fungi_DecontamV2_Nonzero[rownames(metaQiitaCombined_Nonzero_DecontamV2_WashU),]
rep200_HiSeq_Fungi_DecontamV2_Broad_WGS <- rep200Data_WGS_RNA_HiSeq_Fungi_DecontamV2_Nonzero[rownames(metaQiitaCombined_Nonzero_DecontamV2_Broad_WGS),]
# RNA-Seq (note that Broad has both WGS and RNA-Seq, so separate objects are made for both)
rep200_HiSeq_Fungi_DecontamV2_UNC <- rep200Data_WGS_RNA_HiSeq_Fungi_DecontamV2_Nonzero[rownames(metaQiitaCombined_Nonzero_DecontamV2_UNC),]
rep200_HiSeq_Fungi_DecontamV2_CMS <- rep200Data_WGS_RNA_HiSeq_Fungi_DecontamV2_Nonzero[rownames(metaQiitaCombined_Nonzero_DecontamV2_CMS),]
rep200_HiSeq_Fungi_DecontamV2_Broad_RNA <- rep200Data_WGS_RNA_HiSeq_Fungi_DecontamV2_Nonzero[rownames(metaQiitaCombined_Nonzero_DecontamV2_Broad_RNA),]
#--------------------Intersect with fungi with >1% aggregate genome coverage--------------------#
# metaQiitaWGS_RNA_AllSeqPlatforms_Joined_WithBamcounts,
# rep200Data_WGS_RNA_Matched,
# rep200Data_WGS_RNA_Matched_Bacteria,
# rep200Data_WGS_RNA_Matched_Fungi,
load("Interim_data/metaQiitaWGS_RNA_AllSeqPlatforms_Joined_WithBamcounts_and_Data_25Mar22.RData")
coverageFungiAllSamples <- read.csv("Input_data/fungi_filt_updated_29Sep21_coverage_all_wgs_and_rna_output.csv", stringsAsFactors = FALSE)
coverageFungiAllSamples_1Percent <- coverageFungiAllSamples %>% filter(coverage_ratio >= 0.01)
coverageFungiAllSamples_1Percent_OGUs <- coverageFungiAllSamples_1Percent$gotu
# WGS
rep200_HiSeq_Fungi_HMS_Cov <- rep200Data_WGS_RNA_Matched_Fungi[rownames(metaQiitaCombined_Nonzero_DecontamV2_HMS),colnames(rep200Data_WGS_RNA_Matched_Fungi) %in% coverageFungiAllSamples_1Percent_OGUs]
rep200_HiSeq_Fungi_BCM_Cov <- rep200Data_WGS_RNA_Matched_Fungi[rownames(metaQiitaCombined_Nonzero_DecontamV2_BCM),colnames(rep200Data_WGS_RNA_Matched_Fungi) %in% coverageFungiAllSamples_1Percent_OGUs]
rep200_HiSeq_Fungi_MDA_Cov <- rep200Data_WGS_RNA_Matched_Fungi[rownames(metaQiitaCombined_Nonzero_DecontamV2_MDA),colnames(rep200Data_WGS_RNA_Matched_Fungi) %in% coverageFungiAllSamples_1Percent_OGUs]
rep200_HiSeq_Fungi_WashU_Cov <- rep200Data_WGS_RNA_Matched_Fungi[rownames(metaQiitaCombined_Nonzero_DecontamV2_WashU),colnames(rep200Data_WGS_RNA_Matched_Fungi) %in% coverageFungiAllSamples_1Percent_OGUs]
rep200_HiSeq_Fungi_Broad_WGS_Cov <- rep200Data_WGS_RNA_Matched_Fungi[rownames(metaQiitaCombined_Nonzero_DecontamV2_Broad_WGS),colnames(rep200Data_WGS_RNA_Matched_Fungi) %in% coverageFungiAllSamples_1Percent_OGUs]
# RNA
rep200_HiSeq_Fungi_UNC_Cov <- rep200Data_WGS_RNA_Matched_Fungi[rownames(metaQiitaCombined_Nonzero_DecontamV2_UNC),colnames(rep200Data_WGS_RNA_Matched_Fungi) %in% coverageFungiAllSamples_1Percent_OGUs]
rep200_HiSeq_Fungi_CMS_Cov <- rep200Data_WGS_RNA_Matched_Fungi[rownames(metaQiitaCombined_Nonzero_DecontamV2_CMS),colnames(rep200Data_WGS_RNA_Matched_Fungi) %in% coverageFungiAllSamples_1Percent_OGUs]
rep200_HiSeq_Fungi_Broad_RNA_Cov <- rep200Data_WGS_RNA_Matched_Fungi[rownames(metaQiitaCombined_Nonzero_DecontamV2_Broad_RNA),colnames(rep200Data_WGS_RNA_Matched_Fungi) %in% coverageFungiAllSamples_1Percent_OGUs]
## Remove zero sum samples -- Broad_WGS and UNC have zero sum samples; for naming convention, all will be processed
# e.g. ummary(rowSums(rep200_HiSeq_Fungi_Broad_WGS_Cov)==0)
rep200_HiSeq_Fungi_HMS_Cov_Nonzero <- rep200_HiSeq_Fungi_HMS_Cov[!rowSums(rep200_HiSeq_Fungi_HMS_Cov)==0,]
rep200_HiSeq_Fungi_BCM_Cov_Nonzero <- rep200_HiSeq_Fungi_BCM_Cov[!rowSums(rep200_HiSeq_Fungi_BCM_Cov)==0,]
rep200_HiSeq_Fungi_MDA_Cov_Nonzero <- rep200_HiSeq_Fungi_MDA_Cov[!rowSums(rep200_HiSeq_Fungi_MDA_Cov)==0,]
rep200_HiSeq_Fungi_WashU_Cov_Nonzero <- rep200_HiSeq_Fungi_WashU_Cov[!rowSums(rep200_HiSeq_Fungi_WashU_Cov)==0,]
rep200_HiSeq_Fungi_Broad_WGS_Cov_Nonzero <- rep200_HiSeq_Fungi_Broad_WGS_Cov[!rowSums(rep200_HiSeq_Fungi_Broad_WGS_Cov)==0,]
rep200_HiSeq_Fungi_UNC_Cov_Nonzero <- rep200_HiSeq_Fungi_UNC_Cov[!rowSums(rep200_HiSeq_Fungi_UNC_Cov)==0,]
rep200_HiSeq_Fungi_CMS_Cov_Nonzero <- rep200_HiSeq_Fungi_CMS_Cov[!rowSums(rep200_HiSeq_Fungi_CMS_Cov)==0,]
rep200_HiSeq_Fungi_Broad_RNA_Cov_Nonzero <- rep200_HiSeq_Fungi_Broad_RNA_Cov[!rowSums(rep200_HiSeq_Fungi_Broad_RNA_Cov)==0,]
# Match metadata
metaQiitaCombined_Nonzero_DecontamV2_HMS_Cov_Nonzero <- droplevels(metaQiitaCombined_Nonzero_DecontamV2_HMS[rownames(rep200_HiSeq_Fungi_HMS_Cov_Nonzero),])
metaQiitaCombined_Nonzero_DecontamV2_BCM_Cov_Nonzero <- droplevels(metaQiitaCombined_Nonzero_DecontamV2_BCM[rownames(rep200_HiSeq_Fungi_BCM_Cov_Nonzero),])
metaQiitaCombined_Nonzero_DecontamV2_MDA_Cov_Nonzero <- droplevels(metaQiitaCombined_Nonzero_DecontamV2_MDA[rownames(rep200_HiSeq_Fungi_MDA_Cov_Nonzero),])
metaQiitaCombined_Nonzero_DecontamV2_WashU_Cov_Nonzero <- droplevels(metaQiitaCombined_Nonzero_DecontamV2_WashU[rownames(rep200_HiSeq_Fungi_WashU_Cov_Nonzero),])
metaQiitaCombined_Nonzero_DecontamV2_Broad_WGS_Cov_Nonzero <- droplevels(metaQiitaCombined_Nonzero_DecontamV2_Broad_WGS[rownames(rep200_HiSeq_Fungi_Broad_WGS_Cov_Nonzero),])
metaQiitaCombined_Nonzero_DecontamV2_UNC_Cov_Nonzero <- droplevels(metaQiitaCombined_Nonzero_DecontamV2_UNC[rownames(rep200_HiSeq_Fungi_UNC_Cov_Nonzero),])
metaQiitaCombined_Nonzero_DecontamV2_CMS_Cov_Nonzero <- droplevels(metaQiitaCombined_Nonzero_DecontamV2_CMS[rownames(rep200_HiSeq_Fungi_CMS_Cov_Nonzero),])
metaQiitaCombined_Nonzero_DecontamV2_Broad_RNA_Cov_Nonzero <- droplevels(metaQiitaCombined_Nonzero_DecontamV2_Broad_RNA[rownames(rep200_HiSeq_Fungi_Broad_RNA_Cov_Nonzero),])
#--------------------Save data for ML--------------------#
save(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,
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_HMS_Cov_Nonzero,
rep200_HiSeq_Fungi_BCM_Cov_Nonzero,
rep200_HiSeq_Fungi_MDA_Cov_Nonzero,
rep200_HiSeq_Fungi_WashU_Cov_Nonzero,
rep200_HiSeq_Fungi_Broad_WGS_Cov_Nonzero,
rep200_HiSeq_Fungi_UNC_Cov_Nonzero,
rep200_HiSeq_Fungi_CMS_Cov_Nonzero,
rep200_HiSeq_Fungi_Broad_RNA_Cov_Nonzero,
metaQiitaCombined_Nonzero_DecontamV2_HMS_Cov_Nonzero,
metaQiitaCombined_Nonzero_DecontamV2_BCM_Cov_Nonzero,
metaQiitaCombined_Nonzero_DecontamV2_MDA_Cov_Nonzero,
metaQiitaCombined_Nonzero_DecontamV2_WashU_Cov_Nonzero,
metaQiitaCombined_Nonzero_DecontamV2_Broad_WGS_Cov_Nonzero,
metaQiitaCombined_Nonzero_DecontamV2_UNC_Cov_Nonzero,
metaQiitaCombined_Nonzero_DecontamV2_CMS_Cov_Nonzero,
metaQiitaCombined_Nonzero_DecontamV2_Broad_RNA_Cov_Nonzero,
file = "Interim_data/data_for_ml_tcga_by_seq_center_and_experimental_strategy_with_coverage_filter_decontamV2_2Apr22.RData")
# Scripts: S03R
#--------------------Aggregate count data at taxa levels--------------------#
rep200TaxSplit_Fungi_Paired_to_Weizmann <- read.csv("Supporting_data/rep200TaxSplit_Fungi_Paired_To_Weizmann_Final.csv", stringsAsFactors = FALSE, row.names = 1)
# Build phyloseq object
psRep200_HiSeq_Fungi_DecontamV2_HMS <- phyloseq(otu_table(rep200_HiSeq_Fungi_DecontamV2_HMS, taxa_are_rows = FALSE),
tax_table(as.matrix(rep200TaxSplit_Fungi_Paired_to_Weizmann)), sample_data(metaQiitaCombined_Nonzero_DecontamV2_HMS))
psRep200_HiSeq_Fungi_DecontamV2_BCM <- phyloseq(otu_table(rep200_HiSeq_Fungi_DecontamV2_BCM, taxa_are_rows = FALSE),
tax_table(as.matrix(rep200TaxSplit_Fungi_Paired_to_Weizmann)), sample_data(metaQiitaCombined_Nonzero_DecontamV2_BCM))
psRep200_HiSeq_Fungi_DecontamV2_MDA <- phyloseq(otu_table(rep200_HiSeq_Fungi_DecontamV2_MDA, taxa_are_rows = FALSE),
tax_table(as.matrix(rep200TaxSplit_Fungi_Paired_to_Weizmann)), sample_data(metaQiitaCombined_Nonzero_DecontamV2_MDA))
psRep200_HiSeq_Fungi_DecontamV2_WashU <- phyloseq(otu_table(rep200_HiSeq_Fungi_DecontamV2_WashU, taxa_are_rows = FALSE),
tax_table(as.matrix(rep200TaxSplit_Fungi_Paired_to_Weizmann)), sample_data(metaQiitaCombined_Nonzero_DecontamV2_WashU))
psRep200_HiSeq_Fungi_DecontamV2_Broad_WGS <- phyloseq(otu_table(rep200_HiSeq_Fungi_DecontamV2_Broad_WGS, taxa_are_rows = FALSE),
tax_table(as.matrix(rep200TaxSplit_Fungi_Paired_to_Weizmann)), sample_data(metaQiitaCombined_Nonzero_DecontamV2_Broad_WGS))
psRep200_HiSeq_Fungi_DecontamV2_UNC <- phyloseq(otu_table(rep200_HiSeq_Fungi_DecontamV2_UNC, taxa_are_rows = FALSE),
tax_table(as.matrix(rep200TaxSplit_Fungi_Paired_to_Weizmann)), sample_data(metaQiitaCombined_Nonzero_DecontamV2_UNC))
psRep200_HiSeq_Fungi_DecontamV2_CMS <- phyloseq(otu_table(rep200_HiSeq_Fungi_DecontamV2_CMS, taxa_are_rows = FALSE),
tax_table(as.matrix(rep200TaxSplit_Fungi_Paired_to_Weizmann)), sample_data(metaQiitaCombined_Nonzero_DecontamV2_CMS))
psRep200_HiSeq_Fungi_DecontamV2_Broad_RNA <- phyloseq(otu_table(rep200_HiSeq_Fungi_DecontamV2_Broad_RNA, taxa_are_rows = FALSE),
tax_table(as.matrix(rep200TaxSplit_Fungi_Paired_to_Weizmann)), sample_data(metaQiitaCombined_Nonzero_DecontamV2_Broad_RNA))
## Aggregate counts - HMS
psRep200_HiSeq_Fungi_DecontamV2_HMS_phylum = aggregate_taxa(psRep200_HiSeq_Fungi_DecontamV2_HMS, "phylum")
psRep200_HiSeq_Fungi_DecontamV2_HMS_class = aggregate_taxa(psRep200_HiSeq_Fungi_DecontamV2_HMS, "class")
psRep200_HiSeq_Fungi_DecontamV2_HMS_order = aggregate_taxa(psRep200_HiSeq_Fungi_DecontamV2_HMS, "order")
psRep200_HiSeq_Fungi_DecontamV2_HMS_family = aggregate_taxa(psRep200_HiSeq_Fungi_DecontamV2_HMS, "family")
psRep200_HiSeq_Fungi_DecontamV2_HMS_genus = aggregate_taxa(psRep200_HiSeq_Fungi_DecontamV2_HMS, "genus")
psRep200_HiSeq_Fungi_DecontamV2_HMS_species = aggregate_taxa(psRep200_HiSeq_Fungi_DecontamV2_HMS, "species")
## Aggregate counts - BCM
psRep200_HiSeq_Fungi_DecontamV2_BCM_phylum = aggregate_taxa(psRep200_HiSeq_Fungi_DecontamV2_BCM, "phylum")
psRep200_HiSeq_Fungi_DecontamV2_BCM_class = aggregate_taxa(psRep200_HiSeq_Fungi_DecontamV2_BCM, "class")
psRep200_HiSeq_Fungi_DecontamV2_BCM_order = aggregate_taxa(psRep200_HiSeq_Fungi_DecontamV2_BCM, "order")
psRep200_HiSeq_Fungi_DecontamV2_BCM_family = aggregate_taxa(psRep200_HiSeq_Fungi_DecontamV2_BCM, "family")
psRep200_HiSeq_Fungi_DecontamV2_BCM_genus = aggregate_taxa(psRep200_HiSeq_Fungi_DecontamV2_BCM, "genus")
psRep200_HiSeq_Fungi_DecontamV2_BCM_species = aggregate_taxa(psRep200_HiSeq_Fungi_DecontamV2_BCM, "species")
## Aggregate counts - MDA
psRep200_HiSeq_Fungi_DecontamV2_MDA_phylum = aggregate_taxa(psRep200_HiSeq_Fungi_DecontamV2_MDA, "phylum")
psRep200_HiSeq_Fungi_DecontamV2_MDA_class = aggregate_taxa(psRep200_HiSeq_Fungi_DecontamV2_MDA, "class")
psRep200_HiSeq_Fungi_DecontamV2_MDA_order = aggregate_taxa(psRep200_HiSeq_Fungi_DecontamV2_MDA, "order")
psRep200_HiSeq_Fungi_DecontamV2_MDA_family = aggregate_taxa(psRep200_HiSeq_Fungi_DecontamV2_MDA, "family")
psRep200_HiSeq_Fungi_DecontamV2_MDA_genus = aggregate_taxa(psRep200_HiSeq_Fungi_DecontamV2_MDA, "genus")
psRep200_HiSeq_Fungi_DecontamV2_MDA_species = aggregate_taxa(psRep200_HiSeq_Fungi_DecontamV2_MDA, "species")
## Aggregate counts - WashU
psRep200_HiSeq_Fungi_DecontamV2_WashU_phylum = aggregate_taxa(psRep200_HiSeq_Fungi_DecontamV2_WashU, "phylum")
psRep200_HiSeq_Fungi_DecontamV2_WashU_class = aggregate_taxa(psRep200_HiSeq_Fungi_DecontamV2_WashU, "class")
psRep200_HiSeq_Fungi_DecontamV2_WashU_order = aggregate_taxa(psRep200_HiSeq_Fungi_DecontamV2_WashU, "order")
psRep200_HiSeq_Fungi_DecontamV2_WashU_family = aggregate_taxa(psRep200_HiSeq_Fungi_DecontamV2_WashU, "family")
psRep200_HiSeq_Fungi_DecontamV2_WashU_genus = aggregate_taxa(psRep200_HiSeq_Fungi_DecontamV2_WashU, "genus")
psRep200_HiSeq_Fungi_DecontamV2_WashU_species = aggregate_taxa(psRep200_HiSeq_Fungi_DecontamV2_WashU, "species")
## Aggregate counts - Broad_WGS
psRep200_HiSeq_Fungi_DecontamV2_Broad_WGS_phylum = aggregate_taxa(psRep200_HiSeq_Fungi_DecontamV2_Broad_WGS, "phylum")
psRep200_HiSeq_Fungi_DecontamV2_Broad_WGS_class = aggregate_taxa(psRep200_HiSeq_Fungi_DecontamV2_Broad_WGS, "class")
psRep200_HiSeq_Fungi_DecontamV2_Broad_WGS_order = aggregate_taxa(psRep200_HiSeq_Fungi_DecontamV2_Broad_WGS, "order")
psRep200_HiSeq_Fungi_DecontamV2_Broad_WGS_family = aggregate_taxa(psRep200_HiSeq_Fungi_DecontamV2_Broad_WGS, "family")
psRep200_HiSeq_Fungi_DecontamV2_Broad_WGS_genus = aggregate_taxa(psRep200_HiSeq_Fungi_DecontamV2_Broad_WGS, "genus")
psRep200_HiSeq_Fungi_DecontamV2_Broad_WGS_species = aggregate_taxa(psRep200_HiSeq_Fungi_DecontamV2_Broad_WGS, "species")
## Aggregate counts - UNC
psRep200_HiSeq_Fungi_DecontamV2_UNC_phylum = aggregate_taxa(psRep200_HiSeq_Fungi_DecontamV2_UNC, "phylum")
psRep200_HiSeq_Fungi_DecontamV2_UNC_class = aggregate_taxa(psRep200_HiSeq_Fungi_DecontamV2_UNC, "class")
psRep200_HiSeq_Fungi_DecontamV2_UNC_order = aggregate_taxa(psRep200_HiSeq_Fungi_DecontamV2_UNC, "order")
psRep200_HiSeq_Fungi_DecontamV2_UNC_family = aggregate_taxa(psRep200_HiSeq_Fungi_DecontamV2_UNC, "family")
psRep200_HiSeq_Fungi_DecontamV2_UNC_genus = aggregate_taxa(psRep200_HiSeq_Fungi_DecontamV2_UNC, "genus")
psRep200_HiSeq_Fungi_DecontamV2_UNC_species = aggregate_taxa(psRep200_HiSeq_Fungi_DecontamV2_UNC, "species")
## Aggregate counts - HMS
psRep200_HiSeq_Fungi_DecontamV2_CMS_phylum = aggregate_taxa(psRep200_HiSeq_Fungi_DecontamV2_CMS, "phylum")
psRep200_HiSeq_Fungi_DecontamV2_CMS_class = aggregate_taxa(psRep200_HiSeq_Fungi_DecontamV2_CMS, "class")
psRep200_HiSeq_Fungi_DecontamV2_CMS_order = aggregate_taxa(psRep200_HiSeq_Fungi_DecontamV2_CMS, "order")
psRep200_HiSeq_Fungi_DecontamV2_CMS_family = aggregate_taxa(psRep200_HiSeq_Fungi_DecontamV2_CMS, "family")
psRep200_HiSeq_Fungi_DecontamV2_CMS_genus = aggregate_taxa(psRep200_HiSeq_Fungi_DecontamV2_CMS, "genus")
psRep200_HiSeq_Fungi_DecontamV2_CMS_species = aggregate_taxa(psRep200_HiSeq_Fungi_DecontamV2_CMS, "species")
## Aggregate counts - Broad_RNA
psRep200_HiSeq_Fungi_DecontamV2_Broad_RNA_phylum = aggregate_taxa(psRep200_HiSeq_Fungi_DecontamV2_Broad_RNA, "phylum")
psRep200_HiSeq_Fungi_DecontamV2_Broad_RNA_class = aggregate_taxa(psRep200_HiSeq_Fungi_DecontamV2_Broad_RNA, "class")
psRep200_HiSeq_Fungi_DecontamV2_Broad_RNA_order = aggregate_taxa(psRep200_HiSeq_Fungi_DecontamV2_Broad_RNA, "order")
psRep200_HiSeq_Fungi_DecontamV2_Broad_RNA_family = aggregate_taxa(psRep200_HiSeq_Fungi_DecontamV2_Broad_RNA, "family")
psRep200_HiSeq_Fungi_DecontamV2_Broad_RNA_genus = aggregate_taxa(psRep200_HiSeq_Fungi_DecontamV2_Broad_RNA, "genus")
psRep200_HiSeq_Fungi_DecontamV2_Broad_RNA_species = aggregate_taxa(psRep200_HiSeq_Fungi_DecontamV2_Broad_RNA, "species")
#--------------------Extract data frames of aggregated counts--------------------#
## HMS
df_psRep200_HiSeq_Fungi_DecontamV2_HMS_phylum <- data.frame(t(otu_table(psRep200_HiSeq_Fungi_DecontamV2_HMS_phylum)))
df_psRep200_HiSeq_Fungi_DecontamV2_HMS_class <- data.frame(t(otu_table(psRep200_HiSeq_Fungi_DecontamV2_HMS_class)))
df_psRep200_HiSeq_Fungi_DecontamV2_HMS_order <- data.frame(t(otu_table(psRep200_HiSeq_Fungi_DecontamV2_HMS_order)))
df_psRep200_HiSeq_Fungi_DecontamV2_HMS_family <- data.frame(t(otu_table(psRep200_HiSeq_Fungi_DecontamV2_HMS_family)))
df_psRep200_HiSeq_Fungi_DecontamV2_HMS_genus <- data.frame(t(otu_table(psRep200_HiSeq_Fungi_DecontamV2_HMS_genus)))
df_psRep200_HiSeq_Fungi_DecontamV2_HMS_species <- rep200_HiSeq_Fungi_DecontamV2_HMS
colnames(df_psRep200_HiSeq_Fungi_DecontamV2_HMS_species) <- rep200TaxSplit_Fungi_Paired_to_Weizmann[colnames(df_psRep200_HiSeq_Fungi_DecontamV2_HMS_species), "species"]
## BCM
df_psRep200_HiSeq_Fungi_DecontamV2_BCM_phylum <- data.frame(t(otu_table(psRep200_HiSeq_Fungi_DecontamV2_BCM_phylum)))
df_psRep200_HiSeq_Fungi_DecontamV2_BCM_class <- data.frame(t(otu_table(psRep200_HiSeq_Fungi_DecontamV2_BCM_class)))
df_psRep200_HiSeq_Fungi_DecontamV2_BCM_order <- data.frame(t(otu_table(psRep200_HiSeq_Fungi_DecontamV2_BCM_order)))
df_psRep200_HiSeq_Fungi_DecontamV2_BCM_family <- data.frame(t(otu_table(psRep200_HiSeq_Fungi_DecontamV2_BCM_family)))
df_psRep200_HiSeq_Fungi_DecontamV2_BCM_genus <- data.frame(t(otu_table(psRep200_HiSeq_Fungi_DecontamV2_BCM_genus)))
df_psRep200_HiSeq_Fungi_DecontamV2_BCM_species <- rep200_HiSeq_Fungi_DecontamV2_BCM
colnames(df_psRep200_HiSeq_Fungi_DecontamV2_BCM_species) <- rep200TaxSplit_Fungi_Paired_to_Weizmann[colnames(df_psRep200_HiSeq_Fungi_DecontamV2_BCM_species), "species"]
## MDA
df_psRep200_HiSeq_Fungi_DecontamV2_MDA_phylum <- data.frame(t(otu_table(psRep200_HiSeq_Fungi_DecontamV2_MDA_phylum)))
df_psRep200_HiSeq_Fungi_DecontamV2_MDA_class <- data.frame(t(otu_table(psRep200_HiSeq_Fungi_DecontamV2_MDA_class)))
df_psRep200_HiSeq_Fungi_DecontamV2_MDA_order <- data.frame(t(otu_table(psRep200_HiSeq_Fungi_DecontamV2_MDA_order)))
df_psRep200_HiSeq_Fungi_DecontamV2_MDA_family <- data.frame(t(otu_table(psRep200_HiSeq_Fungi_DecontamV2_MDA_family)))
df_psRep200_HiSeq_Fungi_DecontamV2_MDA_genus <- data.frame(t(otu_table(psRep200_HiSeq_Fungi_DecontamV2_MDA_genus)))
df_psRep200_HiSeq_Fungi_DecontamV2_MDA_species <- rep200_HiSeq_Fungi_DecontamV2_MDA
colnames(df_psRep200_HiSeq_Fungi_DecontamV2_MDA_species) <- rep200TaxSplit_Fungi_Paired_to_Weizmann[colnames(df_psRep200_HiSeq_Fungi_DecontamV2_MDA_species), "species"]
## WashU
df_psRep200_HiSeq_Fungi_DecontamV2_WashU_phylum <- data.frame(t(otu_table(psRep200_HiSeq_Fungi_DecontamV2_WashU_phylum)))
df_psRep200_HiSeq_Fungi_DecontamV2_WashU_class <- data.frame(t(otu_table(psRep200_HiSeq_Fungi_DecontamV2_WashU_class)))
df_psRep200_HiSeq_Fungi_DecontamV2_WashU_order <- data.frame(t(otu_table(psRep200_HiSeq_Fungi_DecontamV2_WashU_order)))
df_psRep200_HiSeq_Fungi_DecontamV2_WashU_family <- data.frame(t(otu_table(psRep200_HiSeq_Fungi_DecontamV2_WashU_family)))
df_psRep200_HiSeq_Fungi_DecontamV2_WashU_genus <- data.frame(t(otu_table(psRep200_HiSeq_Fungi_DecontamV2_WashU_genus)))
df_psRep200_HiSeq_Fungi_DecontamV2_WashU_species <- rep200_HiSeq_Fungi_DecontamV2_WashU
colnames(df_psRep200_HiSeq_Fungi_DecontamV2_WashU_species) <- rep200TaxSplit_Fungi_Paired_to_Weizmann[colnames(df_psRep200_HiSeq_Fungi_DecontamV2_WashU_species), "species"]
## Broad_WGS
df_psRep200_HiSeq_Fungi_DecontamV2_Broad_WGS_phylum <- data.frame(t(otu_table(psRep200_HiSeq_Fungi_DecontamV2_Broad_WGS_phylum)))
df_psRep200_HiSeq_Fungi_DecontamV2_Broad_WGS_class <- data.frame(t(otu_table(psRep200_HiSeq_Fungi_DecontamV2_Broad_WGS_class)))
df_psRep200_HiSeq_Fungi_DecontamV2_Broad_WGS_order <- data.frame(t(otu_table(psRep200_HiSeq_Fungi_DecontamV2_Broad_WGS_order)))
df_psRep200_HiSeq_Fungi_DecontamV2_Broad_WGS_family <- data.frame(t(otu_table(psRep200_HiSeq_Fungi_DecontamV2_Broad_WGS_family)))
df_psRep200_HiSeq_Fungi_DecontamV2_Broad_WGS_genus <- data.frame(t(otu_table(psRep200_HiSeq_Fungi_DecontamV2_Broad_WGS_genus)))
df_psRep200_HiSeq_Fungi_DecontamV2_Broad_WGS_species <- rep200_HiSeq_Fungi_DecontamV2_Broad_WGS
colnames(df_psRep200_HiSeq_Fungi_DecontamV2_Broad_WGS_species) <- rep200TaxSplit_Fungi_Paired_to_Weizmann[colnames(df_psRep200_HiSeq_Fungi_DecontamV2_Broad_WGS_species), "species"]
## UNC
df_psRep200_HiSeq_Fungi_DecontamV2_UNC_phylum <- data.frame(t(otu_table(psRep200_HiSeq_Fungi_DecontamV2_UNC_phylum)))
df_psRep200_HiSeq_Fungi_DecontamV2_UNC_class <- data.frame(t(otu_table(psRep200_HiSeq_Fungi_DecontamV2_UNC_class)))
df_psRep200_HiSeq_Fungi_DecontamV2_UNC_order <- data.frame(t(otu_table(psRep200_HiSeq_Fungi_DecontamV2_UNC_order)))
df_psRep200_HiSeq_Fungi_DecontamV2_UNC_family <- data.frame(t(otu_table(psRep200_HiSeq_Fungi_DecontamV2_UNC_family)))
df_psRep200_HiSeq_Fungi_DecontamV2_UNC_genus <- data.frame(t(otu_table(psRep200_HiSeq_Fungi_DecontamV2_UNC_genus)))
df_psRep200_HiSeq_Fungi_DecontamV2_UNC_species <- rep200_HiSeq_Fungi_DecontamV2_UNC
colnames(df_psRep200_HiSeq_Fungi_DecontamV2_UNC_species) <- rep200TaxSplit_Fungi_Paired_to_Weizmann[colnames(df_psRep200_HiSeq_Fungi_DecontamV2_UNC_species), "species"]
## CMS
df_psRep200_HiSeq_Fungi_DecontamV2_CMS_phylum <- data.frame(t(otu_table(psRep200_HiSeq_Fungi_DecontamV2_CMS_phylum)))
df_psRep200_HiSeq_Fungi_DecontamV2_CMS_class <- data.frame(t(otu_table(psRep200_HiSeq_Fungi_DecontamV2_CMS_class)))
df_psRep200_HiSeq_Fungi_DecontamV2_CMS_order <- data.frame(t(otu_table(psRep200_HiSeq_Fungi_DecontamV2_CMS_order)))
df_psRep200_HiSeq_Fungi_DecontamV2_CMS_family <- data.frame(t(otu_table(psRep200_HiSeq_Fungi_DecontamV2_CMS_family)))
df_psRep200_HiSeq_Fungi_DecontamV2_CMS_genus <- data.frame(t(otu_table(psRep200_HiSeq_Fungi_DecontamV2_CMS_genus)))
df_psRep200_HiSeq_Fungi_DecontamV2_CMS_species <- rep200_HiSeq_Fungi_DecontamV2_CMS
colnames(df_psRep200_HiSeq_Fungi_DecontamV2_CMS_species) <- rep200TaxSplit_Fungi_Paired_to_Weizmann[colnames(df_psRep200_HiSeq_Fungi_DecontamV2_CMS_species), "species"]
## Broad_RNA
df_psRep200_HiSeq_Fungi_DecontamV2_Broad_RNA_phylum <- data.frame(t(otu_table(psRep200_HiSeq_Fungi_DecontamV2_Broad_RNA_phylum)))
df_psRep200_HiSeq_Fungi_DecontamV2_Broad_RNA_class <- data.frame(t(otu_table(psRep200_HiSeq_Fungi_DecontamV2_Broad_RNA_class)))
df_psRep200_HiSeq_Fungi_DecontamV2_Broad_RNA_order <- data.frame(t(otu_table(psRep200_HiSeq_Fungi_DecontamV2_Broad_RNA_order)))
df_psRep200_HiSeq_Fungi_DecontamV2_Broad_RNA_family <- data.frame(t(otu_table(psRep200_HiSeq_Fungi_DecontamV2_Broad_RNA_family)))
df_psRep200_HiSeq_Fungi_DecontamV2_Broad_RNA_genus <- data.frame(t(otu_table(psRep200_HiSeq_Fungi_DecontamV2_Broad_RNA_genus)))
df_psRep200_HiSeq_Fungi_DecontamV2_Broad_RNA_species <- rep200_HiSeq_Fungi_DecontamV2_Broad_RNA
colnames(df_psRep200_HiSeq_Fungi_DecontamV2_Broad_RNA_species) <- rep200TaxSplit_Fungi_Paired_to_Weizmann[colnames(df_psRep200_HiSeq_Fungi_DecontamV2_Broad_RNA_species), "species"]
#----------------------------------------------------------------------#
#--------------------Intersect with Weizmann cohort--------------------#
# DIFFERENCE FROM ABOVE IS THAT INTERSECTION IS DONE ON FULL DATA NOT DECONTAMINATED DATA
#----------------------------------------------------------------------#
## Load shared features with Weizmann
load("Interim_data/shared_fungi_features_at_each_taxa_level_29Mar22.RData")
rep200TaxSplit_Fungi_Paired_to_Weizmann <- read.csv("Supporting_data/rep200TaxSplit_Fungi_Paired_To_Weizmann_Final.csv", stringsAsFactors = FALSE, row.names = 1)
# Build phyloseq object
psRep200_HiSeq_Fungi_HMS <- phyloseq(otu_table(rep200Data_WGS_RNA_Matched_Fungi, taxa_are_rows = FALSE),
tax_table(as.matrix(rep200TaxSplit_Fungi_Paired_to_Weizmann)), sample_data(metaQiitaCombined_Nonzero_DecontamV2_HMS))
psRep200_HiSeq_Fungi_BCM <- phyloseq(otu_table(rep200Data_WGS_RNA_Matched_Fungi, taxa_are_rows = FALSE),
tax_table(as.matrix(rep200TaxSplit_Fungi_Paired_to_Weizmann)), sample_data(metaQiitaCombined_Nonzero_DecontamV2_BCM))
psRep200_HiSeq_Fungi_MDA <- phyloseq(otu_table(rep200Data_WGS_RNA_Matched_Fungi, taxa_are_rows = FALSE),
tax_table(as.matrix(rep200TaxSplit_Fungi_Paired_to_Weizmann)), sample_data(metaQiitaCombined_Nonzero_DecontamV2_MDA))
psRep200_HiSeq_Fungi_WashU <- phyloseq(otu_table(rep200Data_WGS_RNA_Matched_Fungi, taxa_are_rows = FALSE),
tax_table(as.matrix(rep200TaxSplit_Fungi_Paired_to_Weizmann)), sample_data(metaQiitaCombined_Nonzero_DecontamV2_WashU))
psRep200_HiSeq_Fungi_Broad_WGS <- phyloseq(otu_table(rep200Data_WGS_RNA_Matched_Fungi, taxa_are_rows = FALSE),
tax_table(as.matrix(rep200TaxSplit_Fungi_Paired_to_Weizmann)), sample_data(metaQiitaCombined_Nonzero_DecontamV2_Broad_WGS))
psRep200_HiSeq_Fungi_UNC <- phyloseq(otu_table(rep200Data_WGS_RNA_Matched_Fungi, taxa_are_rows = FALSE),
tax_table(as.matrix(rep200TaxSplit_Fungi_Paired_to_Weizmann)), sample_data(metaQiitaCombined_Nonzero_DecontamV2_UNC))
psRep200_HiSeq_Fungi_CMS <- phyloseq(otu_table(rep200Data_WGS_RNA_Matched_Fungi, taxa_are_rows = FALSE),
tax_table(as.matrix(rep200TaxSplit_Fungi_Paired_to_Weizmann)), sample_data(metaQiitaCombined_Nonzero_DecontamV2_CMS))
psRep200_HiSeq_Fungi_Broad_RNA <- phyloseq(otu_table(rep200Data_WGS_RNA_Matched_Fungi, taxa_are_rows = FALSE),
tax_table(as.matrix(rep200TaxSplit_Fungi_Paired_to_Weizmann)), sample_data(metaQiitaCombined_Nonzero_DecontamV2_Broad_RNA))
## Aggregate counts - HMS
psRep200_HiSeq_Fungi_HMS_phylum = aggregate_taxa(psRep200_HiSeq_Fungi_HMS, "phylum")
psRep200_HiSeq_Fungi_HMS_class = aggregate_taxa(psRep200_HiSeq_Fungi_HMS, "class")
psRep200_HiSeq_Fungi_HMS_order = aggregate_taxa(psRep200_HiSeq_Fungi_HMS, "order")
psRep200_HiSeq_Fungi_HMS_family = aggregate_taxa(psRep200_HiSeq_Fungi_HMS, "family")
psRep200_HiSeq_Fungi_HMS_genus = aggregate_taxa(psRep200_HiSeq_Fungi_HMS, "genus")
psRep200_HiSeq_Fungi_HMS_species = aggregate_taxa(psRep200_HiSeq_Fungi_HMS, "species")
## Aggregate counts - BCM
psRep200_HiSeq_Fungi_BCM_phylum = aggregate_taxa(psRep200_HiSeq_Fungi_BCM, "phylum")
psRep200_HiSeq_Fungi_BCM_class = aggregate_taxa(psRep200_HiSeq_Fungi_BCM, "class")
psRep200_HiSeq_Fungi_BCM_order = aggregate_taxa(psRep200_HiSeq_Fungi_BCM, "order")
psRep200_HiSeq_Fungi_BCM_family = aggregate_taxa(psRep200_HiSeq_Fungi_BCM, "family")
psRep200_HiSeq_Fungi_BCM_genus = aggregate_taxa(psRep200_HiSeq_Fungi_BCM, "genus")
psRep200_HiSeq_Fungi_BCM_species = aggregate_taxa(psRep200_HiSeq_Fungi_BCM, "species")
## Aggregate counts - MDA
psRep200_HiSeq_Fungi_MDA_phylum = aggregate_taxa(psRep200_HiSeq_Fungi_MDA, "phylum")
psRep200_HiSeq_Fungi_MDA_class = aggregate_taxa(psRep200_HiSeq_Fungi_MDA, "class")
psRep200_HiSeq_Fungi_MDA_order = aggregate_taxa(psRep200_HiSeq_Fungi_MDA, "order")
psRep200_HiSeq_Fungi_MDA_family = aggregate_taxa(psRep200_HiSeq_Fungi_MDA, "family")
psRep200_HiSeq_Fungi_MDA_genus = aggregate_taxa(psRep200_HiSeq_Fungi_MDA, "genus")
psRep200_HiSeq_Fungi_MDA_species = aggregate_taxa(psRep200_HiSeq_Fungi_MDA, "species")
## Aggregate counts - WashU
psRep200_HiSeq_Fungi_WashU_phylum = aggregate_taxa(psRep200_HiSeq_Fungi_WashU, "phylum")
psRep200_HiSeq_Fungi_WashU_class = aggregate_taxa(psRep200_HiSeq_Fungi_WashU, "class")
psRep200_HiSeq_Fungi_WashU_order = aggregate_taxa(psRep200_HiSeq_Fungi_WashU, "order")
psRep200_HiSeq_Fungi_WashU_family = aggregate_taxa(psRep200_HiSeq_Fungi_WashU, "family")
psRep200_HiSeq_Fungi_WashU_genus = aggregate_taxa(psRep200_HiSeq_Fungi_WashU, "genus")
psRep200_HiSeq_Fungi_WashU_species = aggregate_taxa(psRep200_HiSeq_Fungi_WashU, "species")
## Aggregate counts - Broad_WGS
psRep200_HiSeq_Fungi_Broad_WGS_phylum = aggregate_taxa(psRep200_HiSeq_Fungi_Broad_WGS, "phylum")
psRep200_HiSeq_Fungi_Broad_WGS_class = aggregate_taxa(psRep200_HiSeq_Fungi_Broad_WGS, "class")
psRep200_HiSeq_Fungi_Broad_WGS_order = aggregate_taxa(psRep200_HiSeq_Fungi_Broad_WGS, "order")
psRep200_HiSeq_Fungi_Broad_WGS_family = aggregate_taxa(psRep200_HiSeq_Fungi_Broad_WGS, "family")
psRep200_HiSeq_Fungi_Broad_WGS_genus = aggregate_taxa(psRep200_HiSeq_Fungi_Broad_WGS, "genus")
psRep200_HiSeq_Fungi_Broad_WGS_species = aggregate_taxa(psRep200_HiSeq_Fungi_Broad_WGS, "species")
## Aggregate counts - UNC
psRep200_HiSeq_Fungi_UNC_phylum = aggregate_taxa(psRep200_HiSeq_Fungi_UNC, "phylum")
psRep200_HiSeq_Fungi_UNC_class = aggregate_taxa(psRep200_HiSeq_Fungi_UNC, "class")
psRep200_HiSeq_Fungi_UNC_order = aggregate_taxa(psRep200_HiSeq_Fungi_UNC, "order")
psRep200_HiSeq_Fungi_UNC_family = aggregate_taxa(psRep200_HiSeq_Fungi_UNC, "family")
psRep200_HiSeq_Fungi_UNC_genus = aggregate_taxa(psRep200_HiSeq_Fungi_UNC, "genus")
psRep200_HiSeq_Fungi_UNC_species = aggregate_taxa(psRep200_HiSeq_Fungi_UNC, "species")
## Aggregate counts - HMS
psRep200_HiSeq_Fungi_CMS_phylum = aggregate_taxa(psRep200_HiSeq_Fungi_CMS, "phylum")
psRep200_HiSeq_Fungi_CMS_class = aggregate_taxa(psRep200_HiSeq_Fungi_CMS, "class")
psRep200_HiSeq_Fungi_CMS_order = aggregate_taxa(psRep200_HiSeq_Fungi_CMS, "order")
psRep200_HiSeq_Fungi_CMS_family = aggregate_taxa(psRep200_HiSeq_Fungi_CMS, "family")
psRep200_HiSeq_Fungi_CMS_genus = aggregate_taxa(psRep200_HiSeq_Fungi_CMS, "genus")
psRep200_HiSeq_Fungi_CMS_species = aggregate_taxa(psRep200_HiSeq_Fungi_CMS, "species")
## Aggregate counts - Broad_RNA
psRep200_HiSeq_Fungi_Broad_RNA_phylum = aggregate_taxa(psRep200_HiSeq_Fungi_Broad_RNA, "phylum")
psRep200_HiSeq_Fungi_Broad_RNA_class = aggregate_taxa(psRep200_HiSeq_Fungi_Broad_RNA, "class")
psRep200_HiSeq_Fungi_Broad_RNA_order = aggregate_taxa(psRep200_HiSeq_Fungi_Broad_RNA, "order")
psRep200_HiSeq_Fungi_Broad_RNA_family = aggregate_taxa(psRep200_HiSeq_Fungi_Broad_RNA, "family")
psRep200_HiSeq_Fungi_Broad_RNA_genus = aggregate_taxa(psRep200_HiSeq_Fungi_Broad_RNA, "genus")
psRep200_HiSeq_Fungi_Broad_RNA_species = aggregate_taxa(psRep200_HiSeq_Fungi_Broad_RNA, "species")
#--------------------Extract data frames of aggregated counts--------------------#
## HMS
df_psRep200_HiSeq_Fungi_HMS_phylum <- data.frame(t(otu_table(psRep200_HiSeq_Fungi_HMS_phylum)))
df_psRep200_HiSeq_Fungi_HMS_class <- data.frame(t(otu_table(psRep200_HiSeq_Fungi_HMS_class)))
df_psRep200_HiSeq_Fungi_HMS_order <- data.frame(t(otu_table(psRep200_HiSeq_Fungi_HMS_order)))
df_psRep200_HiSeq_Fungi_HMS_family <- data.frame(t(otu_table(psRep200_HiSeq_Fungi_HMS_family)))
df_psRep200_HiSeq_Fungi_HMS_genus <- data.frame(t(otu_table(psRep200_HiSeq_Fungi_HMS_genus)))
df_psRep200_HiSeq_Fungi_HMS_species <- rep200Data_WGS_RNA_Matched_Fungi[rownames(metaQiitaCombined_Nonzero_DecontamV2_HMS),]
colnames(df_psRep200_HiSeq_Fungi_HMS_species) <- rep200TaxSplit_Fungi_Paired_to_Weizmann[colnames(df_psRep200_HiSeq_Fungi_HMS_species), "species"]
## BCM
df_psRep200_HiSeq_Fungi_BCM_phylum <- data.frame(t(otu_table(psRep200_HiSeq_Fungi_BCM_phylum)))
df_psRep200_HiSeq_Fungi_BCM_class <- data.frame(t(otu_table(psRep200_HiSeq_Fungi_BCM_class)))
df_psRep200_HiSeq_Fungi_BCM_order <- data.frame(t(otu_table(psRep200_HiSeq_Fungi_BCM_order)))
df_psRep200_HiSeq_Fungi_BCM_family <- data.frame(t(otu_table(psRep200_HiSeq_Fungi_BCM_family)))
df_psRep200_HiSeq_Fungi_BCM_genus <- data.frame(t(otu_table(psRep200_HiSeq_Fungi_BCM_genus)))
df_psRep200_HiSeq_Fungi_BCM_species <- rep200Data_WGS_RNA_Matched_Fungi[rownames(metaQiitaCombined_Nonzero_DecontamV2_BCM),]
colnames(df_psRep200_HiSeq_Fungi_BCM_species) <- rep200TaxSplit_Fungi_Paired_to_Weizmann[colnames(df_psRep200_HiSeq_Fungi_BCM_species), "species"]
## MDA
df_psRep200_HiSeq_Fungi_MDA_phylum <- data.frame(t(otu_table(psRep200_HiSeq_Fungi_MDA_phylum)))
df_psRep200_HiSeq_Fungi_MDA_class <- data.frame(t(otu_table(psRep200_HiSeq_Fungi_MDA_class)))
df_psRep200_HiSeq_Fungi_MDA_order <- data.frame(t(otu_table(psRep200_HiSeq_Fungi_MDA_order)))
df_psRep200_HiSeq_Fungi_MDA_family <- data.frame(t(otu_table(psRep200_HiSeq_Fungi_MDA_family)))
df_psRep200_HiSeq_Fungi_MDA_genus <- data.frame(t(otu_table(psRep200_HiSeq_Fungi_MDA_genus)))
df_psRep200_HiSeq_Fungi_MDA_species <- rep200Data_WGS_RNA_Matched_Fungi[rownames(metaQiitaCombined_Nonzero_DecontamV2_MDA),]
colnames(df_psRep200_HiSeq_Fungi_MDA_species) <- rep200TaxSplit_Fungi_Paired_to_Weizmann[colnames(df_psRep200_HiSeq_Fungi_MDA_species), "species"]
## WashU
df_psRep200_HiSeq_Fungi_WashU_phylum <- data.frame(t(otu_table(psRep200_HiSeq_Fungi_WashU_phylum)))
df_psRep200_HiSeq_Fungi_WashU_class <- data.frame(t(otu_table(psRep200_HiSeq_Fungi_WashU_class)))
df_psRep200_HiSeq_Fungi_WashU_order <- data.frame(t(otu_table(psRep200_HiSeq_Fungi_WashU_order)))
df_psRep200_HiSeq_Fungi_WashU_family <- data.frame(t(otu_table(psRep200_HiSeq_Fungi_WashU_family)))
df_psRep200_HiSeq_Fungi_WashU_genus <- data.frame(t(otu_table(psRep200_HiSeq_Fungi_WashU_genus)))
df_psRep200_HiSeq_Fungi_WashU_species <- rep200Data_WGS_RNA_Matched_Fungi[rownames(metaQiitaCombined_Nonzero_DecontamV2_WashU),]
colnames(df_psRep200_HiSeq_Fungi_WashU_species) <- rep200TaxSplit_Fungi_Paired_to_Weizmann[colnames(df_psRep200_HiSeq_Fungi_WashU_species), "species"]
## Broad_WGS
df_psRep200_HiSeq_Fungi_Broad_WGS_phylum <- data.frame(t(otu_table(psRep200_HiSeq_Fungi_Broad_WGS_phylum)))
df_psRep200_HiSeq_Fungi_Broad_WGS_class <- data.frame(t(otu_table(psRep200_HiSeq_Fungi_Broad_WGS_class)))
df_psRep200_HiSeq_Fungi_Broad_WGS_order <- data.frame(t(otu_table(psRep200_HiSeq_Fungi_Broad_WGS_order)))
df_psRep200_HiSeq_Fungi_Broad_WGS_family <- data.frame(t(otu_table(psRep200_HiSeq_Fungi_Broad_WGS_family)))
df_psRep200_HiSeq_Fungi_Broad_WGS_genus <- data.frame(t(otu_table(psRep200_HiSeq_Fungi_Broad_WGS_genus)))
df_psRep200_HiSeq_Fungi_Broad_WGS_species <- rep200Data_WGS_RNA_Matched_Fungi[rownames(metaQiitaCombined_Nonzero_DecontamV2_Broad_WGS),]
colnames(df_psRep200_HiSeq_Fungi_Broad_WGS_species) <- rep200TaxSplit_Fungi_Paired_to_Weizmann[colnames(df_psRep200_HiSeq_Fungi_Broad_WGS_species), "species"]
## UNC
df_psRep200_HiSeq_Fungi_UNC_phylum <- data.frame(t(otu_table(psRep200_HiSeq_Fungi_UNC_phylum)))
df_psRep200_HiSeq_Fungi_UNC_class <- data.frame(t(otu_table(psRep200_HiSeq_Fungi_UNC_class)))
df_psRep200_HiSeq_Fungi_UNC_order <- data.frame(t(otu_table(psRep200_HiSeq_Fungi_UNC_order)))
df_psRep200_HiSeq_Fungi_UNC_family <- data.frame(t(otu_table(psRep200_HiSeq_Fungi_UNC_family)))
df_psRep200_HiSeq_Fungi_UNC_genus <- data.frame(t(otu_table(psRep200_HiSeq_Fungi_UNC_genus)))
df_psRep200_HiSeq_Fungi_UNC_species <- rep200Data_WGS_RNA_Matched_Fungi[rownames(metaQiitaCombined_Nonzero_DecontamV2_UNC),]
colnames(df_psRep200_HiSeq_Fungi_UNC_species) <- rep200TaxSplit_Fungi_Paired_to_Weizmann[colnames(df_psRep200_HiSeq_Fungi_UNC_species), "species"]
## CMS
df_psRep200_HiSeq_Fungi_CMS_phylum <- data.frame(t(otu_table(psRep200_HiSeq_Fungi_CMS_phylum)))
df_psRep200_HiSeq_Fungi_CMS_class <- data.frame(t(otu_table(psRep200_HiSeq_Fungi_CMS_class)))
df_psRep200_HiSeq_Fungi_CMS_order <- data.frame(t(otu_table(psRep200_HiSeq_Fungi_CMS_order)))
df_psRep200_HiSeq_Fungi_CMS_family <- data.frame(t(otu_table(psRep200_HiSeq_Fungi_CMS_family)))
df_psRep200_HiSeq_Fungi_CMS_genus <- data.frame(t(otu_table(psRep200_HiSeq_Fungi_CMS_genus)))
df_psRep200_HiSeq_Fungi_CMS_species <- rep200Data_WGS_RNA_Matched_Fungi[rownames(metaQiitaCombined_Nonzero_DecontamV2_CMS),]
colnames(df_psRep200_HiSeq_Fungi_CMS_species) <- rep200TaxSplit_Fungi_Paired_to_Weizmann[colnames(df_psRep200_HiSeq_Fungi_CMS_species), "species"]
## Broad_RNA
df_psRep200_HiSeq_Fungi_Broad_RNA_phylum <- data.frame(t(otu_table(psRep200_HiSeq_Fungi_Broad_RNA_phylum)))
df_psRep200_HiSeq_Fungi_Broad_RNA_class <- data.frame(t(otu_table(psRep200_HiSeq_Fungi_Broad_RNA_class)))
df_psRep200_HiSeq_Fungi_Broad_RNA_order <- data.frame(t(otu_table(psRep200_HiSeq_Fungi_Broad_RNA_order)))
df_psRep200_HiSeq_Fungi_Broad_RNA_family <- data.frame(t(otu_table(psRep200_HiSeq_Fungi_Broad_RNA_family)))
df_psRep200_HiSeq_Fungi_Broad_RNA_genus <- data.frame(t(otu_table(psRep200_HiSeq_Fungi_Broad_RNA_genus)))
df_psRep200_HiSeq_Fungi_Broad_RNA_species <- rep200Data_WGS_RNA_Matched_Fungi[rownames(metaQiitaCombined_Nonzero_DecontamV2_Broad_RNA),]
colnames(df_psRep200_HiSeq_Fungi_Broad_RNA_species) <- rep200TaxSplit_Fungi_Paired_to_Weizmann[colnames(df_psRep200_HiSeq_Fungi_Broad_RNA_species), "species"]
#---------------------------------------#
## HMS -- subset features
df_psRep200_HiSeq_Fungi_HMS_phylum_Shared <- df_psRep200_HiSeq_Fungi_HMS_phylum[,colnames(df_psRep200_HiSeq_Fungi_HMS_phylum) %in% sharedPhylum]
df_psRep200_HiSeq_Fungi_HMS_class_Shared <- df_psRep200_HiSeq_Fungi_HMS_class[,colnames(df_psRep200_HiSeq_Fungi_HMS_class) %in% sharedClass]
df_psRep200_HiSeq_Fungi_HMS_order_Shared <- df_psRep200_HiSeq_Fungi_HMS_order[,colnames(df_psRep200_HiSeq_Fungi_HMS_order) %in% sharedOrder]
df_psRep200_HiSeq_Fungi_HMS_family_Shared <- df_psRep200_HiSeq_Fungi_HMS_family[,colnames(df_psRep200_HiSeq_Fungi_HMS_family) %in% sharedFamily]
df_psRep200_HiSeq_Fungi_HMS_genus_Shared <- df_psRep200_HiSeq_Fungi_HMS_genus[,colnames(df_psRep200_HiSeq_Fungi_HMS_genus) %in% sharedGenus]
df_psRep200_HiSeq_Fungi_HMS_species_Shared <- df_psRep200_HiSeq_Fungi_HMS_species[,colnames(df_psRep200_HiSeq_Fungi_HMS_species) %in% sharedSpecies]
## HMS -- remove zero sum samples
df_psRep200_HiSeq_Fungi_HMS_phylum_Shared_Nonzero <- df_psRep200_HiSeq_Fungi_HMS_phylum_Shared[!rowSums(df_psRep200_HiSeq_Fungi_HMS_phylum_Shared)==0,]
df_psRep200_HiSeq_Fungi_HMS_class_Shared_Nonzero <- df_psRep200_HiSeq_Fungi_HMS_class_Shared[!rowSums(df_psRep200_HiSeq_Fungi_HMS_class_Shared)==0,]
df_psRep200_HiSeq_Fungi_HMS_order_Shared_Nonzero <- df_psRep200_HiSeq_Fungi_HMS_order_Shared[!rowSums(df_psRep200_HiSeq_Fungi_HMS_order_Shared)==0,]
df_psRep200_HiSeq_Fungi_HMS_family_Shared_Nonzero <- df_psRep200_HiSeq_Fungi_HMS_family_Shared[!rowSums(df_psRep200_HiSeq_Fungi_HMS_family_Shared)==0,]
df_psRep200_HiSeq_Fungi_HMS_genus_Shared_Nonzero <- df_psRep200_HiSeq_Fungi_HMS_genus_Shared[!rowSums(df_psRep200_HiSeq_Fungi_HMS_genus_Shared)==0,]
df_psRep200_HiSeq_Fungi_HMS_species_Shared_Nonzero <- df_psRep200_HiSeq_Fungi_HMS_species_Shared[!rowSums(df_psRep200_HiSeq_Fungi_HMS_species_Shared)==0,]
## HMS - metadata
metaQiitaCombined_Nonzero_DecontamV2_HMS_phylum_Shared_Nonzero <- droplevels(metaQiitaCombined_Nonzero_DecontamV2_HMS[rownames(df_psRep200_HiSeq_Fungi_HMS_phylum_Shared_Nonzero),])
metaQiitaCombined_Nonzero_DecontamV2_HMS_class_Shared_Nonzero <- droplevels(metaQiitaCombined_Nonzero_DecontamV2_HMS[rownames(df_psRep200_HiSeq_Fungi_HMS_class_Shared_Nonzero),])
metaQiitaCombined_Nonzero_DecontamV2_HMS_order_Shared_Nonzero <- droplevels(metaQiitaCombined_Nonzero_DecontamV2_HMS[rownames(df_psRep200_HiSeq_Fungi_HMS_order_Shared_Nonzero),])
metaQiitaCombined_Nonzero_DecontamV2_HMS_family_Shared_Nonzero <- droplevels(metaQiitaCombined_Nonzero_DecontamV2_HMS[rownames(df_psRep200_HiSeq_Fungi_HMS_family_Shared_Nonzero),])
metaQiitaCombined_Nonzero_DecontamV2_HMS_genus_Shared_Nonzero <- droplevels(metaQiitaCombined_Nonzero_DecontamV2_HMS[rownames(df_psRep200_HiSeq_Fungi_HMS_genus_Shared_Nonzero),])
metaQiitaCombined_Nonzero_DecontamV2_HMS_species_Shared_Nonzero <- droplevels(metaQiitaCombined_Nonzero_DecontamV2_HMS[rownames(df_psRep200_HiSeq_Fungi_HMS_species_Shared_Nonzero),])
## BCM -- subset features
df_psRep200_HiSeq_Fungi_BCM_phylum_Shared <- df_psRep200_HiSeq_Fungi_BCM_phylum[,colnames(df_psRep200_HiSeq_Fungi_BCM_phylum) %in% sharedPhylum]
df_psRep200_HiSeq_Fungi_BCM_class_Shared <- df_psRep200_HiSeq_Fungi_BCM_class[,colnames(df_psRep200_HiSeq_Fungi_BCM_class) %in% sharedClass]
df_psRep200_HiSeq_Fungi_BCM_order_Shared <- df_psRep200_HiSeq_Fungi_BCM_order[,colnames(df_psRep200_HiSeq_Fungi_BCM_order) %in% sharedOrder]
df_psRep200_HiSeq_Fungi_BCM_family_Shared <- df_psRep200_HiSeq_Fungi_BCM_family[,colnames(df_psRep200_HiSeq_Fungi_BCM_family) %in% sharedFamily]
df_psRep200_HiSeq_Fungi_BCM_genus_Shared <- df_psRep200_HiSeq_Fungi_BCM_genus[,colnames(df_psRep200_HiSeq_Fungi_BCM_genus) %in% sharedGenus]
df_psRep200_HiSeq_Fungi_BCM_species_Shared <- df_psRep200_HiSeq_Fungi_BCM_species[,colnames(df_psRep200_HiSeq_Fungi_BCM_species) %in% sharedSpecies]
## BCM -- remove zero sum samples
df_psRep200_HiSeq_Fungi_BCM_phylum_Shared_Nonzero <- df_psRep200_HiSeq_Fungi_BCM_phylum_Shared[!rowSums(df_psRep200_HiSeq_Fungi_BCM_phylum_Shared)==0,]
df_psRep200_HiSeq_Fungi_BCM_class_Shared_Nonzero <- df_psRep200_HiSeq_Fungi_BCM_class_Shared[!rowSums(df_psRep200_HiSeq_Fungi_BCM_class_Shared)==0,]
df_psRep200_HiSeq_Fungi_BCM_order_Shared_Nonzero <- df_psRep200_HiSeq_Fungi_BCM_order_Shared[!rowSums(df_psRep200_HiSeq_Fungi_BCM_order_Shared)==0,]
df_psRep200_HiSeq_Fungi_BCM_family_Shared_Nonzero <- df_psRep200_HiSeq_Fungi_BCM_family_Shared[!rowSums(df_psRep200_HiSeq_Fungi_BCM_family_Shared)==0,]
df_psRep200_HiSeq_Fungi_BCM_genus_Shared_Nonzero <- df_psRep200_HiSeq_Fungi_BCM_genus_Shared[!rowSums(df_psRep200_HiSeq_Fungi_BCM_genus_Shared)==0,]
df_psRep200_HiSeq_Fungi_BCM_species_Shared_Nonzero <- df_psRep200_HiSeq_Fungi_BCM_species_Shared[!rowSums(df_psRep200_HiSeq_Fungi_BCM_species_Shared)==0,]
## BCM - metadata
metaQiitaCombined_Nonzero_DecontamV2_BCM_phylum_Shared_Nonzero <- droplevels(metaQiitaCombined_Nonzero_DecontamV2_BCM[rownames(df_psRep200_HiSeq_Fungi_BCM_phylum_Shared_Nonzero),])
metaQiitaCombined_Nonzero_DecontamV2_BCM_class_Shared_Nonzero <- droplevels(metaQiitaCombined_Nonzero_DecontamV2_BCM[rownames(df_psRep200_HiSeq_Fungi_BCM_class_Shared_Nonzero),])
metaQiitaCombined_Nonzero_DecontamV2_BCM_order_Shared_Nonzero <- droplevels(metaQiitaCombined_Nonzero_DecontamV2_BCM[rownames(df_psRep200_HiSeq_Fungi_BCM_order_Shared_Nonzero),])
metaQiitaCombined_Nonzero_DecontamV2_BCM_family_Shared_Nonzero <- droplevels(metaQiitaCombined_Nonzero_DecontamV2_BCM[rownames(df_psRep200_HiSeq_Fungi_BCM_family_Shared_Nonzero),])
metaQiitaCombined_Nonzero_DecontamV2_BCM_genus_Shared_Nonzero <- droplevels(metaQiitaCombined_Nonzero_DecontamV2_BCM[rownames(df_psRep200_HiSeq_Fungi_BCM_genus_Shared_Nonzero),])
metaQiitaCombined_Nonzero_DecontamV2_BCM_species_Shared_Nonzero <- droplevels(metaQiitaCombined_Nonzero_DecontamV2_BCM[rownames(df_psRep200_HiSeq_Fungi_BCM_species_Shared_Nonzero),])
## MDA -- subset features
df_psRep200_HiSeq_Fungi_MDA_phylum_Shared <- df_psRep200_HiSeq_Fungi_MDA_phylum[,colnames(df_psRep200_HiSeq_Fungi_MDA_phylum) %in% sharedPhylum]
df_psRep200_HiSeq_Fungi_MDA_class_Shared <- df_psRep200_HiSeq_Fungi_MDA_class[,colnames(df_psRep200_HiSeq_Fungi_MDA_class) %in% sharedClass]
df_psRep200_HiSeq_Fungi_MDA_order_Shared <- df_psRep200_HiSeq_Fungi_MDA_order[,colnames(df_psRep200_HiSeq_Fungi_MDA_order) %in% sharedOrder]
df_psRep200_HiSeq_Fungi_MDA_family_Shared <- df_psRep200_HiSeq_Fungi_MDA_family[,colnames(df_psRep200_HiSeq_Fungi_MDA_family) %in% sharedFamily]
df_psRep200_HiSeq_Fungi_MDA_genus_Shared <- df_psRep200_HiSeq_Fungi_MDA_genus[,colnames(df_psRep200_HiSeq_Fungi_MDA_genus) %in% sharedGenus]
df_psRep200_HiSeq_Fungi_MDA_species_Shared <- df_psRep200_HiSeq_Fungi_MDA_species[,colnames(df_psRep200_HiSeq_Fungi_MDA_species) %in% sharedSpecies]
## MDA -- remove zero sum samples
df_psRep200_HiSeq_Fungi_MDA_phylum_Shared_Nonzero <- df_psRep200_HiSeq_Fungi_MDA_phylum_Shared[!rowSums(df_psRep200_HiSeq_Fungi_MDA_phylum_Shared)==0,]
df_psRep200_HiSeq_Fungi_MDA_class_Shared_Nonzero <- df_psRep200_HiSeq_Fungi_MDA_class_Shared[!rowSums(df_psRep200_HiSeq_Fungi_MDA_class_Shared)==0,]
df_psRep200_HiSeq_Fungi_MDA_order_Shared_Nonzero <- df_psRep200_HiSeq_Fungi_MDA_order_Shared[!rowSums(df_psRep200_HiSeq_Fungi_MDA_order_Shared)==0,]
df_psRep200_HiSeq_Fungi_MDA_family_Shared_Nonzero <- df_psRep200_HiSeq_Fungi_MDA_family_Shared[!rowSums(df_psRep200_HiSeq_Fungi_MDA_family_Shared)==0,]
df_psRep200_HiSeq_Fungi_MDA_genus_Shared_Nonzero <- df_psRep200_HiSeq_Fungi_MDA_genus_Shared[!rowSums(df_psRep200_HiSeq_Fungi_MDA_genus_Shared)==0,]
df_psRep200_HiSeq_Fungi_MDA_species_Shared_Nonzero <- df_psRep200_HiSeq_Fungi_MDA_species_Shared[!rowSums(df_psRep200_HiSeq_Fungi_MDA_species_Shared)==0,]
## MDA - metadata
metaQiitaCombined_Nonzero_DecontamV2_MDA_phylum_Shared_Nonzero <- droplevels(metaQiitaCombined_Nonzero_DecontamV2_MDA[rownames(df_psRep200_HiSeq_Fungi_MDA_phylum_Shared_Nonzero),])
metaQiitaCombined_Nonzero_DecontamV2_MDA_class_Shared_Nonzero <- droplevels(metaQiitaCombined_Nonzero_DecontamV2_MDA[rownames(df_psRep200_HiSeq_Fungi_MDA_class_Shared_Nonzero),])
metaQiitaCombined_Nonzero_DecontamV2_MDA_order_Shared_Nonzero <- droplevels(metaQiitaCombined_Nonzero_DecontamV2_MDA[rownames(df_psRep200_HiSeq_Fungi_MDA_order_Shared_Nonzero),])
metaQiitaCombined_Nonzero_DecontamV2_MDA_family_Shared_Nonzero <- droplevels(metaQiitaCombined_Nonzero_DecontamV2_MDA[rownames(df_psRep200_HiSeq_Fungi_MDA_family_Shared_Nonzero),])
metaQiitaCombined_Nonzero_DecontamV2_MDA_genus_Shared_Nonzero <- droplevels(metaQiitaCombined_Nonzero_DecontamV2_MDA[rownames(df_psRep200_HiSeq_Fungi_MDA_genus_Shared_Nonzero),])
metaQiitaCombined_Nonzero_DecontamV2_MDA_species_Shared_Nonzero <- droplevels(metaQiitaCombined_Nonzero_DecontamV2_MDA[rownames(df_psRep200_HiSeq_Fungi_MDA_species_Shared_Nonzero),])
## WashU -- subset features
df_psRep200_HiSeq_Fungi_WashU_phylum_Shared <- df_psRep200_HiSeq_Fungi_WashU_phylum[,colnames(df_psRep200_HiSeq_Fungi_WashU_phylum) %in% sharedPhylum]
df_psRep200_HiSeq_Fungi_WashU_class_Shared <- df_psRep200_HiSeq_Fungi_WashU_class[,colnames(df_psRep200_HiSeq_Fungi_WashU_class) %in% sharedClass]
df_psRep200_HiSeq_Fungi_WashU_order_Shared <- df_psRep200_HiSeq_Fungi_WashU_order[,colnames(df_psRep200_HiSeq_Fungi_WashU_order) %in% sharedOrder]
df_psRep200_HiSeq_Fungi_WashU_family_Shared <- df_psRep200_HiSeq_Fungi_WashU_family[,colnames(df_psRep200_HiSeq_Fungi_WashU_family) %in% sharedFamily]
df_psRep200_HiSeq_Fungi_WashU_genus_Shared <- df_psRep200_HiSeq_Fungi_WashU_genus[,colnames(df_psRep200_HiSeq_Fungi_WashU_genus) %in% sharedGenus]
df_psRep200_HiSeq_Fungi_WashU_species_Shared <- df_psRep200_HiSeq_Fungi_WashU_species[,colnames(df_psRep200_HiSeq_Fungi_WashU_species) %in% sharedSpecies]
## WashU -- remove zero sum samples
df_psRep200_HiSeq_Fungi_WashU_phylum_Shared_Nonzero <- df_psRep200_HiSeq_Fungi_WashU_phylum_Shared[!rowSums(df_psRep200_HiSeq_Fungi_WashU_phylum_Shared)==0,]
df_psRep200_HiSeq_Fungi_WashU_class_Shared_Nonzero <- df_psRep200_HiSeq_Fungi_WashU_class_Shared[!rowSums(df_psRep200_HiSeq_Fungi_WashU_class_Shared)==0,]
df_psRep200_HiSeq_Fungi_WashU_order_Shared_Nonzero <- df_psRep200_HiSeq_Fungi_WashU_order_Shared[!rowSums(df_psRep200_HiSeq_Fungi_WashU_order_Shared)==0,]
df_psRep200_HiSeq_Fungi_WashU_family_Shared_Nonzero <- df_psRep200_HiSeq_Fungi_WashU_family_Shared[!rowSums(df_psRep200_HiSeq_Fungi_WashU_family_Shared)==0,]
df_psRep200_HiSeq_Fungi_WashU_genus_Shared_Nonzero <- df_psRep200_HiSeq_Fungi_WashU_genus_Shared[!rowSums(df_psRep200_HiSeq_Fungi_WashU_genus_Shared)==0,]
df_psRep200_HiSeq_Fungi_WashU_species_Shared_Nonzero <- df_psRep200_HiSeq_Fungi_WashU_species_Shared[!rowSums(df_psRep200_HiSeq_Fungi_WashU_species_Shared)==0,]
## WashU - metadata
metaQiitaCombined_Nonzero_DecontamV2_WashU_phylum_Shared_Nonzero <- droplevels(metaQiitaCombined_Nonzero_DecontamV2_WashU[rownames(df_psRep200_HiSeq_Fungi_WashU_phylum_Shared_Nonzero),])
metaQiitaCombined_Nonzero_DecontamV2_WashU_class_Shared_Nonzero <- droplevels(metaQiitaCombined_Nonzero_DecontamV2_WashU[rownames(df_psRep200_HiSeq_Fungi_WashU_class_Shared_Nonzero),])
metaQiitaCombined_Nonzero_DecontamV2_WashU_order_Shared_Nonzero <- droplevels(metaQiitaCombined_Nonzero_DecontamV2_WashU[rownames(df_psRep200_HiSeq_Fungi_WashU_order_Shared_Nonzero),])
metaQiitaCombined_Nonzero_DecontamV2_WashU_family_Shared_Nonzero <- droplevels(metaQiitaCombined_Nonzero_DecontamV2_WashU[rownames(df_psRep200_HiSeq_Fungi_WashU_family_Shared_Nonzero),])
metaQiitaCombined_Nonzero_DecontamV2_WashU_genus_Shared_Nonzero <- droplevels(metaQiitaCombined_Nonzero_DecontamV2_WashU[rownames(df_psRep200_HiSeq_Fungi_WashU_genus_Shared_Nonzero),])
metaQiitaCombined_Nonzero_DecontamV2_WashU_species_Shared_Nonzero <- droplevels(metaQiitaCombined_Nonzero_DecontamV2_WashU[rownames(df_psRep200_HiSeq_Fungi_WashU_species_Shared_Nonzero),])
## Broad_WGS -- subset features
df_psRep200_HiSeq_Fungi_Broad_WGS_phylum_Shared <- df_psRep200_HiSeq_Fungi_Broad_WGS_phylum[,colnames(df_psRep200_HiSeq_Fungi_Broad_WGS_phylum) %in% sharedPhylum]
df_psRep200_HiSeq_Fungi_Broad_WGS_class_Shared <- df_psRep200_HiSeq_Fungi_Broad_WGS_class[,colnames(df_psRep200_HiSeq_Fungi_Broad_WGS_class) %in% sharedClass]
df_psRep200_HiSeq_Fungi_Broad_WGS_order_Shared <- df_psRep200_HiSeq_Fungi_Broad_WGS_order[,colnames(df_psRep200_HiSeq_Fungi_Broad_WGS_order) %in% sharedOrder]
df_psRep200_HiSeq_Fungi_Broad_WGS_family_Shared <- df_psRep200_HiSeq_Fungi_Broad_WGS_family[,colnames(df_psRep200_HiSeq_Fungi_Broad_WGS_family) %in% sharedFamily]
df_psRep200_HiSeq_Fungi_Broad_WGS_genus_Shared <- df_psRep200_HiSeq_Fungi_Broad_WGS_genus[,colnames(df_psRep200_HiSeq_Fungi_Broad_WGS_genus) %in% sharedGenus]
df_psRep200_HiSeq_Fungi_Broad_WGS_species_Shared <- df_psRep200_HiSeq_Fungi_Broad_WGS_species[,colnames(df_psRep200_HiSeq_Fungi_Broad_WGS_species) %in% sharedSpecies]
## Broad_WGS -- remove zero sum samples
df_psRep200_HiSeq_Fungi_Broad_WGS_phylum_Shared_Nonzero <- df_psRep200_HiSeq_Fungi_Broad_WGS_phylum_Shared[!rowSums(df_psRep200_HiSeq_Fungi_Broad_WGS_phylum_Shared)==0,]
df_psRep200_HiSeq_Fungi_Broad_WGS_class_Shared_Nonzero <- df_psRep200_HiSeq_Fungi_Broad_WGS_class_Shared[!rowSums(df_psRep200_HiSeq_Fungi_Broad_WGS_class_Shared)==0,]
df_psRep200_HiSeq_Fungi_Broad_WGS_order_Shared_Nonzero <- df_psRep200_HiSeq_Fungi_Broad_WGS_order_Shared[!rowSums(df_psRep200_HiSeq_Fungi_Broad_WGS_order_Shared)==0,]
df_psRep200_HiSeq_Fungi_Broad_WGS_family_Shared_Nonzero <- df_psRep200_HiSeq_Fungi_Broad_WGS_family_Shared[!rowSums(df_psRep200_HiSeq_Fungi_Broad_WGS_family_Shared)==0,]
df_psRep200_HiSeq_Fungi_Broad_WGS_genus_Shared_Nonzero <- df_psRep200_HiSeq_Fungi_Broad_WGS_genus_Shared[!rowSums(df_psRep200_HiSeq_Fungi_Broad_WGS_genus_Shared)==0,]
df_psRep200_HiSeq_Fungi_Broad_WGS_species_Shared_Nonzero <- df_psRep200_HiSeq_Fungi_Broad_WGS_species_Shared[!rowSums(df_psRep200_HiSeq_Fungi_Broad_WGS_species_Shared)==0,]
## Broad_WGS - metadata
metaQiitaCombined_Nonzero_DecontamV2_Broad_WGS_phylum_Shared_Nonzero <- droplevels(metaQiitaCombined_Nonzero_DecontamV2_Broad_WGS[rownames(df_psRep200_HiSeq_Fungi_Broad_WGS_phylum_Shared_Nonzero),])
metaQiitaCombined_Nonzero_DecontamV2_Broad_WGS_class_Shared_Nonzero <- droplevels(metaQiitaCombined_Nonzero_DecontamV2_Broad_WGS[rownames(df_psRep200_HiSeq_Fungi_Broad_WGS_class_Shared_Nonzero),])
metaQiitaCombined_Nonzero_DecontamV2_Broad_WGS_order_Shared_Nonzero <- droplevels(metaQiitaCombined_Nonzero_DecontamV2_Broad_WGS[rownames(df_psRep200_HiSeq_Fungi_Broad_WGS_order_Shared_Nonzero),])
metaQiitaCombined_Nonzero_DecontamV2_Broad_WGS_family_Shared_Nonzero <- droplevels(metaQiitaCombined_Nonzero_DecontamV2_Broad_WGS[rownames(df_psRep200_HiSeq_Fungi_Broad_WGS_family_Shared_Nonzero),])
metaQiitaCombined_Nonzero_DecontamV2_Broad_WGS_genus_Shared_Nonzero <- droplevels(metaQiitaCombined_Nonzero_DecontamV2_Broad_WGS[rownames(df_psRep200_HiSeq_Fungi_Broad_WGS_genus_Shared_Nonzero),])
metaQiitaCombined_Nonzero_DecontamV2_Broad_WGS_species_Shared_Nonzero <- droplevels(metaQiitaCombined_Nonzero_DecontamV2_Broad_WGS[rownames(df_psRep200_HiSeq_Fungi_Broad_WGS_species_Shared_Nonzero),])
## UNC -- subset features
df_psRep200_HiSeq_Fungi_UNC_phylum_Shared <- df_psRep200_HiSeq_Fungi_UNC_phylum[,colnames(df_psRep200_HiSeq_Fungi_UNC_phylum) %in% sharedPhylum]
df_psRep200_HiSeq_Fungi_UNC_class_Shared <- df_psRep200_HiSeq_Fungi_UNC_class[,colnames(df_psRep200_HiSeq_Fungi_UNC_class) %in% sharedClass]
df_psRep200_HiSeq_Fungi_UNC_order_Shared <- df_psRep200_HiSeq_Fungi_UNC_order[,colnames(df_psRep200_HiSeq_Fungi_UNC_order) %in% sharedOrder]
df_psRep200_HiSeq_Fungi_UNC_family_Shared <- df_psRep200_HiSeq_Fungi_UNC_family[,colnames(df_psRep200_HiSeq_Fungi_UNC_family) %in% sharedFamily]
df_psRep200_HiSeq_Fungi_UNC_genus_Shared <- df_psRep200_HiSeq_Fungi_UNC_genus[,colnames(df_psRep200_HiSeq_Fungi_UNC_genus) %in% sharedGenus]
df_psRep200_HiSeq_Fungi_UNC_species_Shared <- df_psRep200_HiSeq_Fungi_UNC_species[,colnames(df_psRep200_HiSeq_Fungi_UNC_species) %in% sharedSpecies]
## UNC -- remove zero sum samples
df_psRep200_HiSeq_Fungi_UNC_phylum_Shared_Nonzero <- df_psRep200_HiSeq_Fungi_UNC_phylum_Shared[!rowSums(df_psRep200_HiSeq_Fungi_UNC_phylum_Shared)==0,]
df_psRep200_HiSeq_Fungi_UNC_class_Shared_Nonzero <- df_psRep200_HiSeq_Fungi_UNC_class_Shared[!rowSums(df_psRep200_HiSeq_Fungi_UNC_class_Shared)==0,]
df_psRep200_HiSeq_Fungi_UNC_order_Shared_Nonzero <- df_psRep200_HiSeq_Fungi_UNC_order_Shared[!rowSums(df_psRep200_HiSeq_Fungi_UNC_order_Shared)==0,]
df_psRep200_HiSeq_Fungi_UNC_family_Shared_Nonzero <- df_psRep200_HiSeq_Fungi_UNC_family_Shared[!rowSums(df_psRep200_HiSeq_Fungi_UNC_family_Shared)==0,]
df_psRep200_HiSeq_Fungi_UNC_genus_Shared_Nonzero <- df_psRep200_HiSeq_Fungi_UNC_genus_Shared[!rowSums(df_psRep200_HiSeq_Fungi_UNC_genus_Shared)==0,]
df_psRep200_HiSeq_Fungi_UNC_species_Shared_Nonzero <- df_psRep200_HiSeq_Fungi_UNC_species_Shared[!rowSums(df_psRep200_HiSeq_Fungi_UNC_species_Shared)==0,]
## UNC - metadata
metaQiitaCombined_Nonzero_DecontamV2_UNC_phylum_Shared_Nonzero <- droplevels(metaQiitaCombined_Nonzero_DecontamV2_UNC[rownames(df_psRep200_HiSeq_Fungi_UNC_phylum_Shared_Nonzero),])
metaQiitaCombined_Nonzero_DecontamV2_UNC_class_Shared_Nonzero <- droplevels(metaQiitaCombined_Nonzero_DecontamV2_UNC[rownames(df_psRep200_HiSeq_Fungi_UNC_class_Shared_Nonzero),])
metaQiitaCombined_Nonzero_DecontamV2_UNC_order_Shared_Nonzero <- droplevels(metaQiitaCombined_Nonzero_DecontamV2_UNC[rownames(df_psRep200_HiSeq_Fungi_UNC_order_Shared_Nonzero),])
metaQiitaCombined_Nonzero_DecontamV2_UNC_family_Shared_Nonzero <- droplevels(metaQiitaCombined_Nonzero_DecontamV2_UNC[rownames(df_psRep200_HiSeq_Fungi_UNC_family_Shared_Nonzero),])
metaQiitaCombined_Nonzero_DecontamV2_UNC_genus_Shared_Nonzero <- droplevels(metaQiitaCombined_Nonzero_DecontamV2_UNC[rownames(df_psRep200_HiSeq_Fungi_UNC_genus_Shared_Nonzero),])
metaQiitaCombined_Nonzero_DecontamV2_UNC_species_Shared_Nonzero <- droplevels(metaQiitaCombined_Nonzero_DecontamV2_UNC[rownames(df_psRep200_HiSeq_Fungi_UNC_species_Shared_Nonzero),])
## CMS -- subset features
df_psRep200_HiSeq_Fungi_CMS_phylum_Shared <- df_psRep200_HiSeq_Fungi_CMS_phylum[,colnames(df_psRep200_HiSeq_Fungi_CMS_phylum) %in% sharedPhylum]
df_psRep200_HiSeq_Fungi_CMS_class_Shared <- df_psRep200_HiSeq_Fungi_CMS_class[,colnames(df_psRep200_HiSeq_Fungi_CMS_class) %in% sharedClass]
df_psRep200_HiSeq_Fungi_CMS_order_Shared <- df_psRep200_HiSeq_Fungi_CMS_order[,colnames(df_psRep200_HiSeq_Fungi_CMS_order) %in% sharedOrder]
df_psRep200_HiSeq_Fungi_CMS_family_Shared <- df_psRep200_HiSeq_Fungi_CMS_family[,colnames(df_psRep200_HiSeq_Fungi_CMS_family) %in% sharedFamily]
df_psRep200_HiSeq_Fungi_CMS_genus_Shared <- df_psRep200_HiSeq_Fungi_CMS_genus[,colnames(df_psRep200_HiSeq_Fungi_CMS_genus) %in% sharedGenus]
df_psRep200_HiSeq_Fungi_CMS_species_Shared <- df_psRep200_HiSeq_Fungi_CMS_species[,colnames(df_psRep200_HiSeq_Fungi_CMS_species) %in% sharedSpecies]
## CMS -- remove zero sum samples
df_psRep200_HiSeq_Fungi_CMS_phylum_Shared_Nonzero <- df_psRep200_HiSeq_Fungi_CMS_phylum_Shared[!rowSums(df_psRep200_HiSeq_Fungi_CMS_phylum_Shared)==0,]
df_psRep200_HiSeq_Fungi_CMS_class_Shared_Nonzero <- df_psRep200_HiSeq_Fungi_CMS_class_Shared[!rowSums(df_psRep200_HiSeq_Fungi_CMS_class_Shared)==0,]
df_psRep200_HiSeq_Fungi_CMS_order_Shared_Nonzero <- df_psRep200_HiSeq_Fungi_CMS_order_Shared[!rowSums(df_psRep200_HiSeq_Fungi_CMS_order_Shared)==0,]
df_psRep200_HiSeq_Fungi_CMS_family_Shared_Nonzero <- df_psRep200_HiSeq_Fungi_CMS_family_Shared[!rowSums(df_psRep200_HiSeq_Fungi_CMS_family_Shared)==0,]
df_psRep200_HiSeq_Fungi_CMS_genus_Shared_Nonzero <- df_psRep200_HiSeq_Fungi_CMS_genus_Shared[!rowSums(df_psRep200_HiSeq_Fungi_CMS_genus_Shared)==0,]
df_psRep200_HiSeq_Fungi_CMS_species_Shared_Nonzero <- df_psRep200_HiSeq_Fungi_CMS_species_Shared[!rowSums(df_psRep200_HiSeq_Fungi_CMS_species_Shared)==0,]
## CMS - metadata
metaQiitaCombined_Nonzero_DecontamV2_CMS_phylum_Shared_Nonzero <- droplevels(metaQiitaCombined_Nonzero_DecontamV2_CMS[rownames(df_psRep200_HiSeq_Fungi_CMS_phylum_Shared_Nonzero),])
metaQiitaCombined_Nonzero_DecontamV2_CMS_class_Shared_Nonzero <- droplevels(metaQiitaCombined_Nonzero_DecontamV2_CMS[rownames(df_psRep200_HiSeq_Fungi_CMS_class_Shared_Nonzero),])
metaQiitaCombined_Nonzero_DecontamV2_CMS_order_Shared_Nonzero <- droplevels(metaQiitaCombined_Nonzero_DecontamV2_CMS[rownames(df_psRep200_HiSeq_Fungi_CMS_order_Shared_Nonzero),])
metaQiitaCombined_Nonzero_DecontamV2_CMS_family_Shared_Nonzero <- droplevels(metaQiitaCombined_Nonzero_DecontamV2_CMS[rownames(df_psRep200_HiSeq_Fungi_CMS_family_Shared_Nonzero),])
metaQiitaCombined_Nonzero_DecontamV2_CMS_genus_Shared_Nonzero <- droplevels(metaQiitaCombined_Nonzero_DecontamV2_CMS[rownames(df_psRep200_HiSeq_Fungi_CMS_genus_Shared_Nonzero),])
metaQiitaCombined_Nonzero_DecontamV2_CMS_species_Shared_Nonzero <- droplevels(metaQiitaCombined_Nonzero_DecontamV2_CMS[rownames(df_psRep200_HiSeq_Fungi_CMS_species_Shared_Nonzero),])
## Broad_RNA -- subset features
df_psRep200_HiSeq_Fungi_Broad_RNA_phylum_Shared <- df_psRep200_HiSeq_Fungi_Broad_RNA_phylum[,colnames(df_psRep200_HiSeq_Fungi_Broad_RNA_phylum) %in% sharedPhylum]
df_psRep200_HiSeq_Fungi_Broad_RNA_class_Shared <- df_psRep200_HiSeq_Fungi_Broad_RNA_class[,colnames(df_psRep200_HiSeq_Fungi_Broad_RNA_class) %in% sharedClass]
df_psRep200_HiSeq_Fungi_Broad_RNA_order_Shared <- df_psRep200_HiSeq_Fungi_Broad_RNA_order[,colnames(df_psRep200_HiSeq_Fungi_Broad_RNA_order) %in% sharedOrder]
df_psRep200_HiSeq_Fungi_Broad_RNA_family_Shared <- df_psRep200_HiSeq_Fungi_Broad_RNA_family[,colnames(df_psRep200_HiSeq_Fungi_Broad_RNA_family) %in% sharedFamily]
df_psRep200_HiSeq_Fungi_Broad_RNA_genus_Shared <- df_psRep200_HiSeq_Fungi_Broad_RNA_genus[,colnames(df_psRep200_HiSeq_Fungi_Broad_RNA_genus) %in% sharedGenus]
df_psRep200_HiSeq_Fungi_Broad_RNA_species_Shared <- df_psRep200_HiSeq_Fungi_Broad_RNA_species[,colnames(df_psRep200_HiSeq_Fungi_Broad_RNA_species) %in% sharedSpecies]
## Broad_RNA -- remove zero sum samples
df_psRep200_HiSeq_Fungi_Broad_RNA_phylum_Shared_Nonzero <- df_psRep200_HiSeq_Fungi_Broad_RNA_phylum_Shared[!rowSums(df_psRep200_HiSeq_Fungi_Broad_RNA_phylum_Shared)==0,]
df_psRep200_HiSeq_Fungi_Broad_RNA_class_Shared_Nonzero <- df_psRep200_HiSeq_Fungi_Broad_RNA_class_Shared[!rowSums(df_psRep200_HiSeq_Fungi_Broad_RNA_class_Shared)==0,]
df_psRep200_HiSeq_Fungi_Broad_RNA_order_Shared_Nonzero <- df_psRep200_HiSeq_Fungi_Broad_RNA_order_Shared[!rowSums(df_psRep200_HiSeq_Fungi_Broad_RNA_order_Shared)==0,]
df_psRep200_HiSeq_Fungi_Broad_RNA_family_Shared_Nonzero <- df_psRep200_HiSeq_Fungi_Broad_RNA_family_Shared[!rowSums(df_psRep200_HiSeq_Fungi_Broad_RNA_family_Shared)==0,]
df_psRep200_HiSeq_Fungi_Broad_RNA_genus_Shared_Nonzero <- df_psRep200_HiSeq_Fungi_Broad_RNA_genus_Shared[!rowSums(df_psRep200_HiSeq_Fungi_Broad_RNA_genus_Shared)==0,]
df_psRep200_HiSeq_Fungi_Broad_RNA_species_Shared_Nonzero <- df_psRep200_HiSeq_Fungi_Broad_RNA_species_Shared[!rowSums(df_psRep200_HiSeq_Fungi_Broad_RNA_species_Shared)==0,]
## Broad_RNA - metadata
metaQiitaCombined_Nonzero_DecontamV2_Broad_RNA_phylum_Shared_Nonzero <- droplevels(metaQiitaCombined_Nonzero_DecontamV2_Broad_RNA[rownames(df_psRep200_HiSeq_Fungi_Broad_RNA_phylum_Shared_Nonzero),])
metaQiitaCombined_Nonzero_DecontamV2_Broad_RNA_class_Shared_Nonzero <- droplevels(metaQiitaCombined_Nonzero_DecontamV2_Broad_RNA[rownames(df_psRep200_HiSeq_Fungi_Broad_RNA_class_Shared_Nonzero),])
metaQiitaCombined_Nonzero_DecontamV2_Broad_RNA_order_Shared_Nonzero <- droplevels(metaQiitaCombined_Nonzero_DecontamV2_Broad_RNA[rownames(df_psRep200_HiSeq_Fungi_Broad_RNA_order_Shared_Nonzero),])
metaQiitaCombined_Nonzero_DecontamV2_Broad_RNA_family_Shared_Nonzero <- droplevels(metaQiitaCombined_Nonzero_DecontamV2_Broad_RNA[rownames(df_psRep200_HiSeq_Fungi_Broad_RNA_family_Shared_Nonzero),])
metaQiitaCombined_Nonzero_DecontamV2_Broad_RNA_genus_Shared_Nonzero <- droplevels(metaQiitaCombined_Nonzero_DecontamV2_Broad_RNA[rownames(df_psRep200_HiSeq_Fungi_Broad_RNA_genus_Shared_Nonzero),])
metaQiitaCombined_Nonzero_DecontamV2_Broad_RNA_species_Shared_Nonzero <- droplevels(metaQiitaCombined_Nonzero_DecontamV2_Broad_RNA[rownames(df_psRep200_HiSeq_Fungi_Broad_RNA_species_Shared_Nonzero),])
#--------------------Save data for ML--------------------#
save(df_psRep200_HiSeq_Fungi_DecontamV2_HMS_phylum,
df_psRep200_HiSeq_Fungi_DecontamV2_HMS_class,
df_psRep200_HiSeq_Fungi_DecontamV2_HMS_order,
df_psRep200_HiSeq_Fungi_DecontamV2_HMS_family,
df_psRep200_HiSeq_Fungi_DecontamV2_HMS_genus,
df_psRep200_HiSeq_Fungi_DecontamV2_HMS_species,
df_psRep200_HiSeq_Fungi_HMS_phylum_Shared_Nonzero,
df_psRep200_HiSeq_Fungi_HMS_class_Shared_Nonzero,
df_psRep200_HiSeq_Fungi_HMS_order_Shared_Nonzero,
df_psRep200_HiSeq_Fungi_HMS_family_Shared_Nonzero,
df_psRep200_HiSeq_Fungi_HMS_genus_Shared_Nonzero,
df_psRep200_HiSeq_Fungi_HMS_species_Shared_Nonzero,
# BCM
df_psRep200_HiSeq_Fungi_DecontamV2_BCM_phylum,
df_psRep200_HiSeq_Fungi_DecontamV2_BCM_class,
df_psRep200_HiSeq_Fungi_DecontamV2_BCM_order,
df_psRep200_HiSeq_Fungi_DecontamV2_BCM_family,
df_psRep200_HiSeq_Fungi_DecontamV2_BCM_genus,
df_psRep200_HiSeq_Fungi_DecontamV2_BCM_species,
df_psRep200_HiSeq_Fungi_BCM_phylum_Shared_Nonzero,
df_psRep200_HiSeq_Fungi_BCM_class_Shared_Nonzero,
df_psRep200_HiSeq_Fungi_BCM_order_Shared_Nonzero,
df_psRep200_HiSeq_Fungi_BCM_family_Shared_Nonzero,
df_psRep200_HiSeq_Fungi_BCM_genus_Shared_Nonzero,
df_psRep200_HiSeq_Fungi_BCM_species_Shared_Nonzero,
# MDA
df_psRep200_HiSeq_Fungi_DecontamV2_MDA_phylum,
df_psRep200_HiSeq_Fungi_DecontamV2_MDA_class,
df_psRep200_HiSeq_Fungi_DecontamV2_MDA_order,
df_psRep200_HiSeq_Fungi_DecontamV2_MDA_family,
df_psRep200_HiSeq_Fungi_DecontamV2_MDA_genus,
df_psRep200_HiSeq_Fungi_DecontamV2_MDA_species,
df_psRep200_HiSeq_Fungi_MDA_phylum_Shared_Nonzero,
df_psRep200_HiSeq_Fungi_MDA_class_Shared_Nonzero,
df_psRep200_HiSeq_Fungi_MDA_order_Shared_Nonzero,
df_psRep200_HiSeq_Fungi_MDA_family_Shared_Nonzero,
df_psRep200_HiSeq_Fungi_MDA_genus_Shared_Nonzero,
df_psRep200_HiSeq_Fungi_MDA_species_Shared_Nonzero,
# WashU
df_psRep200_HiSeq_Fungi_DecontamV2_WashU_phylum,
df_psRep200_HiSeq_Fungi_DecontamV2_WashU_class,
df_psRep200_HiSeq_Fungi_DecontamV2_WashU_order,
df_psRep200_HiSeq_Fungi_DecontamV2_WashU_family,
df_psRep200_HiSeq_Fungi_DecontamV2_WashU_genus,
df_psRep200_HiSeq_Fungi_DecontamV2_WashU_species,
df_psRep200_HiSeq_Fungi_WashU_phylum_Shared_Nonzero,
df_psRep200_HiSeq_Fungi_WashU_class_Shared_Nonzero,
df_psRep200_HiSeq_Fungi_WashU_order_Shared_Nonzero,
df_psRep200_HiSeq_Fungi_WashU_family_Shared_Nonzero,
df_psRep200_HiSeq_Fungi_WashU_genus_Shared_Nonzero,
df_psRep200_HiSeq_Fungi_WashU_species_Shared_Nonzero,
# Broad_WGS
df_psRep200_HiSeq_Fungi_DecontamV2_Broad_WGS_phylum,
df_psRep200_HiSeq_Fungi_DecontamV2_Broad_WGS_class,
df_psRep200_HiSeq_Fungi_DecontamV2_Broad_WGS_order,
df_psRep200_HiSeq_Fungi_DecontamV2_Broad_WGS_family,
df_psRep200_HiSeq_Fungi_DecontamV2_Broad_WGS_genus,
df_psRep200_HiSeq_Fungi_DecontamV2_Broad_WGS_species,
df_psRep200_HiSeq_Fungi_Broad_WGS_phylum_Shared_Nonzero,
df_psRep200_HiSeq_Fungi_Broad_WGS_class_Shared_Nonzero,
df_psRep200_HiSeq_Fungi_Broad_WGS_order_Shared_Nonzero,
df_psRep200_HiSeq_Fungi_Broad_WGS_family_Shared_Nonzero,
df_psRep200_HiSeq_Fungi_Broad_WGS_genus_Shared_Nonzero,
df_psRep200_HiSeq_Fungi_Broad_WGS_species_Shared_Nonzero,
# UNC
df_psRep200_HiSeq_Fungi_DecontamV2_UNC_phylum,
df_psRep200_HiSeq_Fungi_DecontamV2_UNC_class,
df_psRep200_HiSeq_Fungi_DecontamV2_UNC_order,
df_psRep200_HiSeq_Fungi_DecontamV2_UNC_family,
df_psRep200_HiSeq_Fungi_DecontamV2_UNC_genus,
df_psRep200_HiSeq_Fungi_DecontamV2_UNC_species,
df_psRep200_HiSeq_Fungi_UNC_phylum_Shared_Nonzero,
df_psRep200_HiSeq_Fungi_UNC_class_Shared_Nonzero,
df_psRep200_HiSeq_Fungi_UNC_order_Shared_Nonzero,
df_psRep200_HiSeq_Fungi_UNC_family_Shared_Nonzero,
df_psRep200_HiSeq_Fungi_UNC_genus_Shared_Nonzero,
df_psRep200_HiSeq_Fungi_UNC_species_Shared_Nonzero,
# CMS
df_psRep200_HiSeq_Fungi_DecontamV2_CMS_phylum,
df_psRep200_HiSeq_Fungi_DecontamV2_CMS_class,
df_psRep200_HiSeq_Fungi_DecontamV2_CMS_order,
df_psRep200_HiSeq_Fungi_DecontamV2_CMS_family,
df_psRep200_HiSeq_Fungi_DecontamV2_CMS_genus,
df_psRep200_HiSeq_Fungi_DecontamV2_CMS_species,
df_psRep200_HiSeq_Fungi_CMS_phylum_Shared_Nonzero,
df_psRep200_HiSeq_Fungi_CMS_class_Shared_Nonzero,
df_psRep200_HiSeq_Fungi_CMS_order_Shared_Nonzero,
df_psRep200_HiSeq_Fungi_CMS_family_Shared_Nonzero,
df_psRep200_HiSeq_Fungi_CMS_genus_Shared_Nonzero,
df_psRep200_HiSeq_Fungi_CMS_species_Shared_Nonzero,
# Broad_RNA
df_psRep200_HiSeq_Fungi_DecontamV2_Broad_RNA_phylum,
df_psRep200_HiSeq_Fungi_DecontamV2_Broad_RNA_class,
df_psRep200_HiSeq_Fungi_DecontamV2_Broad_RNA_order,
df_psRep200_HiSeq_Fungi_DecontamV2_Broad_RNA_family,
df_psRep200_HiSeq_Fungi_DecontamV2_Broad_RNA_genus,
df_psRep200_HiSeq_Fungi_DecontamV2_Broad_RNA_species,
df_psRep200_HiSeq_Fungi_Broad_RNA_phylum_Shared_Nonzero,
df_psRep200_HiSeq_Fungi_Broad_RNA_class_Shared_Nonzero,
df_psRep200_HiSeq_Fungi_Broad_RNA_order_Shared_Nonzero,
df_psRep200_HiSeq_Fungi_Broad_RNA_family_Shared_Nonzero,
df_psRep200_HiSeq_Fungi_Broad_RNA_genus_Shared_Nonzero,
df_psRep200_HiSeq_Fungi_Broad_RNA_species_Shared_Nonzero,
# Metadata - HMS
metaQiitaCombined_Nonzero_DecontamV2_HMS,
metaQiitaCombined_Nonzero_DecontamV2_HMS_phylum_Shared_Nonzero,
metaQiitaCombined_Nonzero_DecontamV2_HMS_class_Shared_Nonzero,
metaQiitaCombined_Nonzero_DecontamV2_HMS_order_Shared_Nonzero,
metaQiitaCombined_Nonzero_DecontamV2_HMS_family_Shared_Nonzero,
metaQiitaCombined_Nonzero_DecontamV2_HMS_genus_Shared_Nonzero,
metaQiitaCombined_Nonzero_DecontamV2_HMS_species_Shared_Nonzero,
# Metadata - BCM
metaQiitaCombined_Nonzero_DecontamV2_BCM,
metaQiitaCombined_Nonzero_DecontamV2_BCM_phylum_Shared_Nonzero,
metaQiitaCombined_Nonzero_DecontamV2_BCM_class_Shared_Nonzero,
metaQiitaCombined_Nonzero_DecontamV2_BCM_order_Shared_Nonzero,
metaQiitaCombined_Nonzero_DecontamV2_BCM_family_Shared_Nonzero,
metaQiitaCombined_Nonzero_DecontamV2_BCM_genus_Shared_Nonzero,
metaQiitaCombined_Nonzero_DecontamV2_BCM_species_Shared_Nonzero,
# Metadata - MDA
metaQiitaCombined_Nonzero_DecontamV2_MDA,
metaQiitaCombined_Nonzero_DecontamV2_MDA_phylum_Shared_Nonzero,
metaQiitaCombined_Nonzero_DecontamV2_MDA_class_Shared_Nonzero,
metaQiitaCombined_Nonzero_DecontamV2_MDA_order_Shared_Nonzero,
metaQiitaCombined_Nonzero_DecontamV2_MDA_family_Shared_Nonzero,
metaQiitaCombined_Nonzero_DecontamV2_MDA_genus_Shared_Nonzero,
metaQiitaCombined_Nonzero_DecontamV2_MDA_species_Shared_Nonzero,
# Metadata - WashU
metaQiitaCombined_Nonzero_DecontamV2_WashU,
metaQiitaCombined_Nonzero_DecontamV2_WashU_phylum_Shared_Nonzero,
metaQiitaCombined_Nonzero_DecontamV2_WashU_class_Shared_Nonzero,
metaQiitaCombined_Nonzero_DecontamV2_WashU_order_Shared_Nonzero,
metaQiitaCombined_Nonzero_DecontamV2_WashU_family_Shared_Nonzero,
metaQiitaCombined_Nonzero_DecontamV2_WashU_genus_Shared_Nonzero,
metaQiitaCombined_Nonzero_DecontamV2_WashU_species_Shared_Nonzero,
# Metadata - Broad_WGS
metaQiitaCombined_Nonzero_DecontamV2_Broad_WGS,
metaQiitaCombined_Nonzero_DecontamV2_Broad_WGS_phylum_Shared_Nonzero,
metaQiitaCombined_Nonzero_DecontamV2_Broad_WGS_class_Shared_Nonzero,
metaQiitaCombined_Nonzero_DecontamV2_Broad_WGS_order_Shared_Nonzero,
metaQiitaCombined_Nonzero_DecontamV2_Broad_WGS_family_Shared_Nonzero,
metaQiitaCombined_Nonzero_DecontamV2_Broad_WGS_genus_Shared_Nonzero,
metaQiitaCombined_Nonzero_DecontamV2_Broad_WGS_species_Shared_Nonzero,
# Metadata - UNC
metaQiitaCombined_Nonzero_DecontamV2_UNC,
metaQiitaCombined_Nonzero_DecontamV2_UNC_phylum_Shared_Nonzero,
metaQiitaCombined_Nonzero_DecontamV2_UNC_class_Shared_Nonzero,
metaQiitaCombined_Nonzero_DecontamV2_UNC_order_Shared_Nonzero,
metaQiitaCombined_Nonzero_DecontamV2_UNC_family_Shared_Nonzero,
metaQiitaCombined_Nonzero_DecontamV2_UNC_genus_Shared_Nonzero,
metaQiitaCombined_Nonzero_DecontamV2_UNC_species_Shared_Nonzero,
# Metadata - CMS
metaQiitaCombined_Nonzero_DecontamV2_CMS,
metaQiitaCombined_Nonzero_DecontamV2_CMS_phylum_Shared_Nonzero,
metaQiitaCombined_Nonzero_DecontamV2_CMS_class_Shared_Nonzero,
metaQiitaCombined_Nonzero_DecontamV2_CMS_order_Shared_Nonzero,
metaQiitaCombined_Nonzero_DecontamV2_CMS_family_Shared_Nonzero,
metaQiitaCombined_Nonzero_DecontamV2_CMS_genus_Shared_Nonzero,
metaQiitaCombined_Nonzero_DecontamV2_CMS_species_Shared_Nonzero,
# Metadata - Broad_RNA
metaQiitaCombined_Nonzero_DecontamV2_Broad_RNA,
metaQiitaCombined_Nonzero_DecontamV2_Broad_RNA_phylum_Shared_Nonzero,
metaQiitaCombined_Nonzero_DecontamV2_Broad_RNA_class_Shared_Nonzero,
metaQiitaCombined_Nonzero_DecontamV2_Broad_RNA_order_Shared_Nonzero,
metaQiitaCombined_Nonzero_DecontamV2_Broad_RNA_family_Shared_Nonzero,
metaQiitaCombined_Nonzero_DecontamV2_Broad_RNA_genus_Shared_Nonzero,
metaQiitaCombined_Nonzero_DecontamV2_Broad_RNA_species_Shared_Nonzero,
file = "Interim_data/data_for_ml_tcga_by_seq_center_and_experimental_strategy_taxa_levels_and_wz_intersect_decontamV2_2Apr22.RData")
# Scripts: S04R
#--------------------------------------------------------------------------------------------------------------------#
# Separate WGS and RNA-Seq data for ML (to compare performance between them after batch correcting)
# Using CT Voom-SNM data
#--------------------------------------------------------------------------------------------------------------------#
metaQiitaCombined_Nonzero_DecontamV2_WGS <- metaQiitaCombined_Nonzero_DecontamV2 %>% filter(experimental_strategy == "WGS") %>% droplevels()
metaQiitaCombined_Nonzero_DecontamV2_RNA <- metaQiitaCombined_Nonzero_DecontamV2 %>% filter(experimental_strategy == "RNA-Seq") %>% droplevels()
snmDataOGUFungiDecontamV2_WGS <- snmDataOGUFungiDecontamV2[rownames(metaQiitaCombined_Nonzero_DecontamV2_WGS),]
snmDataOGUFungiDecontamV2_RNA <- snmDataOGUFungiDecontamV2[rownames(metaQiitaCombined_Nonzero_DecontamV2_RNA),]
save(metaQiitaCombined_Nonzero_DecontamV2,
metaQiitaCombined_Nonzero_DecontamV2_WGS,
metaQiitaCombined_Nonzero_DecontamV2_RNA,
snmDataOGUFungiDecontamV2,
snmDataOGUFungiDecontamV2_WGS,
snmDataOGUFungiDecontamV2_RNA,
file = "Interim_data/data_for_ml_tcga_wgs_vs_rna_decontamV2_2Apr22.RData")
# Scripts: S05R
#----------------------------------------------------------#
# Create phyloseq objects and aggregate counts at various taxa levels
#----------------------------------------------------------#
rep200TaxSplit_Fungi_Paired_to_Weizmann <- read.csv("Supporting_data/rep200TaxSplit_Fungi_Paired_To_Weizmann_Final.csv", stringsAsFactors = FALSE, row.names = 1)
psFungiHiSeqFungi_DecontamV2 <- phyloseq(otu_table(rep200Data_WGS_RNA_HiSeq_Fungi_DecontamV2_Nonzero, taxa_are_rows = FALSE),
tax_table(as.matrix(rep200TaxSplit_Fungi_Paired_to_Weizmann)), sample_data(metaQiitaCombined_Nonzero_DecontamV2))
## Aggregate counts
psFungiHiSeqFungi_DecontamV2_phylum = aggregate_taxa(psFungiHiSeqFungi_DecontamV2, "phylum")
psFungiHiSeqFungi_DecontamV2_class = aggregate_taxa(psFungiHiSeqFungi_DecontamV2, "class")
psFungiHiSeqFungi_DecontamV2_order = aggregate_taxa(psFungiHiSeqFungi_DecontamV2, "order")
psFungiHiSeqFungi_DecontamV2_family = aggregate_taxa(psFungiHiSeqFungi_DecontamV2, "family")
psFungiHiSeqFungi_DecontamV2_genus = aggregate_taxa(psFungiHiSeqFungi_DecontamV2, "genus")
psFungiHiSeqFungi_DecontamV2_species = aggregate_taxa(psFungiHiSeqFungi_DecontamV2, "species")
#----------------------------------------------------------#
# Extract aggregated and subset feature matrices
#----------------------------------------------------------#
rep200FungiDecontamV2Phylum <- data.frame(t(otu_table(psFungiHiSeqFungi_DecontamV2_phylum)))
rep200FungiDecontamV2Class <- data.frame(t(otu_table(psFungiHiSeqFungi_DecontamV2_class)))
rep200FungiDecontamV2Order <- data.frame(t(otu_table(psFungiHiSeqFungi_DecontamV2_order)))
rep200FungiDecontamV2Family <- data.frame(t(otu_table(psFungiHiSeqFungi_DecontamV2_family)))
rep200FungiDecontamV2Genus <- data.frame(t(otu_table(psFungiHiSeqFungi_DecontamV2_genus)))
rep200FungiDecontamV2Species <- rep200Data_WGS_RNA_HiSeq_Fungi_DecontamV2_Nonzero
colnames(rep200FungiDecontamV2Species) <- rep200TaxSplit_Fungi_Paired_to_Weizmann[colnames(rep200FungiDecontamV2Species), "species"]
rep200FungiDecontamV2Species[1:3,1:3]
save(metaQiitaCombined_Nonzero_DecontamV2,
rep200FungiDecontamV2Phylum,
rep200FungiDecontamV2Class,
rep200FungiDecontamV2Order,
rep200FungiDecontamV2Family,
rep200FungiDecontamV2Genus,
rep200FungiDecontamV2Species,
file = "Interim_data/raw_data_tcga_all_cancers_decontamV2_2Apr22.RData")
#-----------------------------------------#
# Extract 8 cancer types to directly compare with Weizmann cancers
#-----------------------------------------#
# Cancer types to include: breast, lung, melanoma, colon, GBM, pancreas, ovary, bone
# Combine: LUAD and LUSC into LC, COAD and READ into CRC
metaQiitaCombined_Nonzero_DecontamV2_8cancer <- metaQiitaCombined_Nonzero_DecontamV2 %>%
filter(investigation %in% c("TCGA-BRCA","TCGA-LUAD","TCGA-LUSC","TCGA-SKCM","TCGA-COAD",
"TCGA-READ","TCGA-GBM","TCGA-PAAD","TCGA-OV","TCGA-SARC")) %>% droplevels()
dim(metaQiitaCombined_Nonzero_DecontamV2_8cancer) # 5875 41
metaQiitaCombined_Nonzero_DecontamV2_8cancer$disease_type <- as.character(metaQiitaCombined_Nonzero_DecontamV2_8cancer$disease_type)
metaQiitaCombined_Nonzero_DecontamV2_8cancer$disease_type[metaQiitaCombined_Nonzero_DecontamV2_8cancer$disease_type == "Lung Squamous Cell Carcinoma"] <- "Lung Cancer"
metaQiitaCombined_Nonzero_DecontamV2_8cancer$disease_type[metaQiitaCombined_Nonzero_DecontamV2_8cancer$disease_type == "Lung Adenocarcinoma"] <- "Lung Cancer"
metaQiitaCombined_Nonzero_DecontamV2_8cancer$disease_type[metaQiitaCombined_Nonzero_DecontamV2_8cancer$disease_type == "Colon Adenocarcinoma"] <- "Colorectal Cancer"
metaQiitaCombined_Nonzero_DecontamV2_8cancer$disease_type[metaQiitaCombined_Nonzero_DecontamV2_8cancer$disease_type == "Rectum Adenocarcinoma"] <- "Colorectal Cancer"
metaQiitaCombined_Nonzero_DecontamV2_8cancer$disease_type[metaQiitaCombined_Nonzero_DecontamV2_8cancer$disease_type == "Breast Invasive Carcinoma"] <- "Breast Cancer"
metaQiitaCombined_Nonzero_DecontamV2_8cancer$disease_type[metaQiitaCombined_Nonzero_DecontamV2_8cancer$disease_type == "Glioblastoma Multiforme"] <- "Glioblastoma"
metaQiitaCombined_Nonzero_DecontamV2_8cancer$disease_type[metaQiitaCombined_Nonzero_DecontamV2_8cancer$disease_type == "Pancreatic Adenocarcinoma"] <- "Pancreatic Cancer"
metaQiitaCombined_Nonzero_DecontamV2_8cancer$disease_type[metaQiitaCombined_Nonzero_DecontamV2_8cancer$disease_type == "Ovarian Serous Cystadenocarcinoma"] <- "Ovarian Cancer"
metaQiitaCombined_Nonzero_DecontamV2_8cancer$disease_type[metaQiitaCombined_Nonzero_DecontamV2_8cancer$disease_type == "Skin Cutaneous Melanoma"] <- "Melanoma"
metaQiitaCombined_Nonzero_DecontamV2_8cancer$disease_type[metaQiitaCombined_Nonzero_DecontamV2_8cancer$disease_type == "Sarcoma"] <- "Bone Cancer"
table(metaQiitaCombined_Nonzero_DecontamV2_8cancer$disease_type)
rep200FungiDecontamV2Phylum_8cancer <- rep200FungiDecontamV2Phylum[rownames(metaQiitaCombined_Nonzero_DecontamV2_8cancer),]
rep200FungiDecontamV2Class_8cancer <- rep200FungiDecontamV2Class[rownames(metaQiitaCombined_Nonzero_DecontamV2_8cancer),]
rep200FungiDecontamV2Order_8cancer <- rep200FungiDecontamV2Order[rownames(metaQiitaCombined_Nonzero_DecontamV2_8cancer),]
rep200FungiDecontamV2Family_8cancer <- rep200FungiDecontamV2Family[rownames(metaQiitaCombined_Nonzero_DecontamV2_8cancer),]
rep200FungiDecontamV2Genus_8cancer <- rep200FungiDecontamV2Genus[rownames(metaQiitaCombined_Nonzero_DecontamV2_8cancer),]
rep200FungiDecontamV2Species_8cancer <- rep200FungiDecontamV2Species[rownames(metaQiitaCombined_Nonzero_DecontamV2_8cancer),]
save(metaQiitaCombined_Nonzero_DecontamV2_8cancer,
rep200FungiDecontamV2Phylum_8cancer,
rep200FungiDecontamV2Class_8cancer,
rep200FungiDecontamV2Order_8cancer,
rep200FungiDecontamV2Family_8cancer,
rep200FungiDecontamV2Genus_8cancer,
rep200FungiDecontamV2Species_8cancer,
file = "Interim_data/raw_data_tcga_8_cancers_decontamV2_2Apr22.RData")
#----------------------------------------------------------#
# Run VSNM for each taxa level
#----------------------------------------------------------#
source("00-Functions.R") # for vsnmFunctionTCGA() function
# NOTE: The Voom-SNM batch effect correction can utilize multiple
# "biological" and "technical" variables. It operates to iteratively
# remove variance due to "technical" variables while maintaining variance
# attributed to "biological" factors. It does NOT artificially increase variance
# attributed to "biological" factors. Rather, by removing the noise from "technical"
# factors in a supervised manner, the goal is to allow the underlying signal to be observed.
# Also note that the adding more variables in the Voom-SNM normalization can sometimes preclude
# convergence of the algorithm, particularly when fewer features are available. This lack of convergence
# was observed for some higher taxa levels when adding "disease_type" as a "biological" variable. Thus,
# all possible options are shown below. Including "disease_type" as a "biological" variable in addition to
# "sample_type" improves the overall modelling and downstream machine learning, but it is not necessary to
# show that the mycobiome varies between cancer types and sample types.
## TCGA full data - biological variable: sample_type | technical variables: data_submitting_center_label + experimental_strategy
# NOTE: Phylum and Class levels were attempted but did not converge, so they are not shown here
rep200FungiDecontamV2OrderVSNM_Obj <- vsnmFunctionTCGA(rep200FungiDecontamV2Order) # converges
rep200FungiDecontamV2OrderVSNM <- rep200FungiDecontamV2OrderVSNM_Obj$snmData
rep200FungiDecontamV2FamilyVSNM_Obj <- vsnmFunctionTCGA(rep200FungiDecontamV2Family) # converges
rep200FungiDecontamV2FamilyVSNM <- rep200FungiDecontamV2FamilyVSNM_Obj$snmData
rep200FungiDecontamV2GenusVSNM_Obj <- vsnmFunctionTCGA(rep200FungiDecontamV2Genus) # converges
rep200FungiDecontamV2GenusVSNM <- rep200FungiDecontamV2GenusVSNM_Obj$snmData
rep200FungiDecontamV2SpeciesVSNM_Obj <- vsnmFunctionTCGA(rep200FungiDecontamV2Species) # converges
rep200FungiDecontamV2SpeciesVSNM <- rep200FungiDecontamV2SpeciesVSNM_Obj$snmData
## Summarized 8 cancer types - biological variable: sample_type | technical variables: data_submitting_center_label + experimental_strategy
# NOTE: Phylum and Class levels were attempted but did not converge, so they are not shown here
rep200FungiDecontamV2Order_8cancer_VSNM_Obj <- vsnmFunctionTCGA(rep200FungiDecontamV2Order_8cancer, qcMetadata = metaQiitaCombined_Nonzero_DecontamV2_8cancer) # converges
rep200FungiDecontamV2Order_8cancer_VSNM <- rep200FungiDecontamV2Order_8cancer_VSNM_Obj$snmData
rep200FungiDecontamV2Family_8cancer_VSNM_Obj <- vsnmFunctionTCGA(rep200FungiDecontamV2Family_8cancer, qcMetadata = metaQiitaCombined_Nonzero_DecontamV2_8cancer) # converges
rep200FungiDecontamV2Family_8cancer_VSNM <- rep200FungiDecontamV2Family_8cancer_VSNM_Obj$snmData
rep200FungiDecontamV2Genus_8cancer_VSNM_Obj <- vsnmFunctionTCGA(rep200FungiDecontamV2Genus_8cancer, qcMetadata = metaQiitaCombined_Nonzero_DecontamV2_8cancer) # converges
rep200FungiDecontamV2Genus_8cancer_VSNM <- rep200FungiDecontamV2Genus_8cancer_VSNM_Obj$snmData
rep200FungiDecontamV2Species_8cancer_VSNM_Obj <- vsnmFunctionTCGA(rep200FungiDecontamV2Species_8cancer, qcMetadata = metaQiitaCombined_Nonzero_DecontamV2_8cancer) # converges
rep200FungiDecontamV2Species_8cancer_VSNM <- rep200FungiDecontamV2Species_8cancer_VSNM_Obj$snmData
# NOT CURRENTLY RUN:
## Summarized 8 cancer types - biological variables: disease_type + sample_type | technical variables: data_submitting_center_label + experimental_strategy
# NOTE: Phylum, Class, Order, and Family levels were attempted but did not converge, so they are not shown here
# rep200FungiDecontamV2Genus_8cancer_VSNM_Obj_CT <- vsnmFunctionTCGA(rep200FungiDecontamV2Genus_8cancer, qcMetadata = metaQiitaCombined_Nonzero_DecontamV2_8cancer, cancerTypeFlag = TRUE) # converges
# rep200FungiDecontamV2Genus_8cancer_VSNM_CT <- rep200FungiDecontamV2Genus_8cancer_VSNM_Obj_CT$snmData
# rep200FungiDecontamV2Species_8cancer_VSNM_Obj_CT <- vsnmFunctionTCGA(rep200FungiDecontamV2Species_8cancer, qcMetadata = metaQiitaCombined_Nonzero_DecontamV2_8cancer, cancerTypeFlag = TRUE) # converges
# rep200FungiDecontamV2Species_8cancer_VSNM_CT <- rep200FungiDecontamV2Species_8cancer_VSNM_Obj_CT$snmData
#----------------------------------------------------------#
# Save data for running PVCA on each subsetted data to examine batch correction quality
#----------------------------------------------------------#
save(metaQiitaCombined_Nonzero_DecontamV2,
rep200FungiDecontamV2OrderVSNM_Obj,
rep200FungiDecontamV2FamilyVSNM_Obj,
rep200FungiDecontamV2GenusVSNM_Obj,
rep200FungiDecontamV2SpeciesVSNM_Obj,
# Full TCGA above, Weizmann matched cancers below
metaQiitaCombined_Nonzero_DecontamV2_8cancer,
rep200FungiDecontamV2Order_8cancer_VSNM_Obj,
rep200FungiDecontamV2Family_8cancer_VSNM_Obj,
rep200FungiDecontamV2Genus_8cancer_VSNM_Obj,
rep200FungiDecontamV2Species_8cancer_VSNM_Obj,
file = "Interim_data/data_for_pvca_tcga_taxa_levels_decontamV2_2Apr22.RData")
#--------------------------------------------------------------------------------------------------------------------#
# Separate WGS and RNA-Seq data for ML (to compare performance between them after batch correcting)
#--------------------------------------------------------------------------------------------------------------------#
load("Interim_data/data_for_pvca_tcga_taxa_levels_decontamV2_2Apr22.RData")
metaQiitaCombined_Nonzero_DecontamV2_WGS <- metaQiitaCombined_Nonzero_DecontamV2 %>% filter(experimental_strategy == "WGS") %>% droplevels()
metaQiitaCombined_Nonzero_DecontamV2_RNA <- metaQiitaCombined_Nonzero_DecontamV2 %>% filter(experimental_strategy == "RNA-Seq") %>% droplevels()
rep200FungiDecontamV2SpeciesVSNM <- rep200FungiDecontamV2SpeciesVSNM_Obj$snmData
rep200FungiDecontamV2SpeciesVSNM_WGS <- rep200FungiDecontamV2SpeciesVSNM[rownames(metaQiitaCombined_Nonzero_DecontamV2_WGS),]
rep200FungiDecontamV2SpeciesVSNM_RNA <- rep200FungiDecontamV2SpeciesVSNM[rownames(metaQiitaCombined_Nonzero_DecontamV2_RNA),]
save(metaQiitaCombined_Nonzero_DecontamV2,
metaQiitaCombined_Nonzero_DecontamV2_WGS,
metaQiitaCombined_Nonzero_DecontamV2_RNA,
rep200FungiDecontamV2SpeciesVSNM,
rep200FungiDecontamV2SpeciesVSNM_WGS,
rep200FungiDecontamV2SpeciesVSNM_RNA,
file = "Interim_data/data_for_ml_tcga_wgs_vs_rna_sample_type_VSNM_decontamV2_2Apr22.RData")
# Scripts: S06R
#--------------------Format data and regression plot--------------------#
source("Supporting_scripts/S00-SummarySE.R") # Contains a function that calculates std error and 95% confidence intervals
mlPerfAll10k_full_WGS_RNA_v2 <- read.csv("Interim_data/rep_perfFungi_10k_rep1_tcga_full_wgs_rna_vsnm_STonly_ALL_DecontamV2_2Apr22.csv", stringsAsFactors = FALSE)
abbreviationsTCGA_Allcancer <- read.csv("Supporting_data/tcga_abbreviations.csv", stringsAsFactors = FALSE, row.names = 1)
mlPerfAll10k_full_WGS_RNA_v2$abbrev <- abbreviationsTCGA_Allcancer[mlPerfAll10k_full_WGS_RNA_v2$diseaseType,"abbrev"]
mlPerfAll10k_full_WGS_RNA_v2 <- mlPerfAll10k_full_WGS_RNA_v2[,!(colnames(mlPerfAll10k_full_WGS_RNA_v2) == "X")]
colnames(mlPerfAll10k_full_WGS_RNA_v2)[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_full_WGS_RNA_v2$nullAUPR <- ifelse(mlPerfAll10k_full_WGS_RNA_v2$minorityClassName == "SolidTissueNormal",
yes=mlPerfAll10k_full_WGS_RNA_v2$majorityClassSize/(mlPerfAll10k_full_WGS_RNA_v2$minorityClassSize+mlPerfAll10k_full_WGS_RNA_v2$majorityClassSize),
no=mlPerfAll10k_full_WGS_RNA_v2$minorityClassSize/(mlPerfAll10k_full_WGS_RNA_v2$minorityClassSize+mlPerfAll10k_full_WGS_RNA_v2$majorityClassSize))
mlPerfAll10k_full_WGS_RNA_v2$nullAUROC <- 0.5