[0bdad5]: / R / simplify.R

Download this file

872 lines (792 with data), 32.8 kB

  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
# simplify TCGA data download workflow
## ------------------------------------
# Typical Cohorts Structure
# Given GBM as an example: <https://xenabrowser.net/datapages/?cohort=TCGA%20Glioblastoma%20(GBM)>
# Cohorts
# Copy Number
# gistic2
# gistic2 thresholded
# Copy Number Segments
# After remove germline cnv
# Before remove germline cnv
# DNA Methylation
# Methylation27k
# Methylation450k
# Exon Expression RNASeq
# IlluminaHiSeq
# Gene Expression Array
# AffyU133a (always change)
# Gene Expression RNASeq
# IlluminaHiSeq
# IlluminaHiSeq pancan normalized
# IlluminaHiSeq percentile
# miRNA Mature Strand Expression RNASeq
# IlluminaHiseq
# PARADIGM Pathway Activity
# expression
# expression (array) + CNV
# expression + CNV
# exprssion (array)
# Phenotype
# Phenotypes
# Protein Expression RPPA
# RPPA
# RPPA (replicate-base normalization)
# Somatic Mutation (SNPs and small INDELs)
# broad
# ucsc automated
# Somatic non-silent mutation (gene-level)
# broad
# PANCAN AWG
# ucsc automated
# Transcription factor regulatory impact
# Agilent, by RABIT
# HiSeqV2, by RABIT
# U133A, by RABIT
# compiler::setCompilerOptions(suppressAll = TRUE)
# suppress Binding Notes
# suppressBindingNotes <- function(variablesMentionedInNotes) {
# for(variable in variablesMentionedInNotes) {
# assign(variable, NULL, envir = .GlobalEnv)
# }
# }
# suppressBindingNotes(c("XenaHostNames","XenaCohorts", "ProjectID", "DataType", "FileType"))
##' @title Get TCGA Common Data Sets by Project ID and Property
##' @description This is the most useful function for user to download common
##' TCGA datasets, it is similar to `getFirehoseData` function in `RTCGAToolbox`
##' package.
##' @details TCGA Common Data Sets are frequently used for biological analysis.
##' To make easier to achieve these data, this function provide really easy
##' options to choose datasets and behavior. All availble information about
##' datasets of TCGA can access vis `availTCGA()` and check with `showTCGA()`.
##' @author Shixiang Wang <w_shixiang@163.com>
##' @inheritParams downloadTCGA
##' @param clinical logical. if `TRUE`, download clinical information. Default is `TRUE`.
##' @param download logical. if `TRUE`, download data, otherwise return a result list include data
##' information. Default is `FALSE`. You can set this to `FALSE` if you want to check what you will download or
##' use other function provided by `UCSCXenaTools` to filter result datasets you want to download.
##' @param forceDownload logical. if `TRUE`, force to download files no matter if exist. Default is `FALSE`.
##' @param mRNASeq logical. if `TRUE`, download mRNASeq data. Default is `FALSE`.
##' @param mRNAArray logical. if `TRUE`, download mRNA microarray data. Default is `FALSE`.
##' @param mRNASeqType character vector. Can be one, two or three
##' in `c("normalized", "pancan normalized", "percentile")`.
##' @param miRNASeq logical. if `TRUE`, download miRNASeq data. Default is `FALSE`.
##' @param exonRNASeq logical. if `TRUE`, download exon RNASeq data. Default is `FALSE`.
##' @param RPPAArray logical. if `TRUE`, download RPPA data. Default is `FALSE`.
##' @param ReplicateBaseNormalization logical. if `TRUE`, download RPPA data by Replicate Base
##' Normalization (RBN). Default is `FALSE`.
##' @param Methylation logical. if `TRUE`, download DNA Methylation data. Default is `FALSE`.
##' @param MethylationType character vector. Can be one or two in `c("27K", "450K")`.
##' @param GeneMutation logical. if `TRUE`, download gene mutation data. Default is `FALSE`.
##' @param SomaticMutation logical. if `TRUE`, download somatic mutation data. Default is `FALSE`.
##' @param GisticCopyNumber logical. if `TRUE`, download Gistic2 Copy Number data. Default is `FALSE`.
##' @param Gistic2Threshold logical. if `TRUE`, download Threshold Gistic2 data. Default is `TRUE`.
##' @param CopyNumberSegment logical. if `TRUE`, download Copy Number Segment data. Default is `FALSE`.
##' @param RemoveGermlineCNV logical. if `TRUE`, download Copy Number Segment data which has removed
##' germline copy number variation. Default is `TRUE`.
##' @return if `download=TRUE`, return `data.frame` from `XenaDownload`,
##' otherwise return a list including `XenaHub` object and datasets information
##' @export
##' @examples
##' ###### get data, but not download
##'
##' # 1 choose project and data types you wanna download
##' getTCGAdata(project = "LUAD", mRNASeq = TRUE, mRNAArray = TRUE,
##' mRNASeqType = "normalized", miRNASeq = TRUE, exonRNASeq = TRUE,
##' RPPAArray = TRUE, Methylation = TRUE, MethylationType = "450K",
##' GeneMutation = TRUE, SomaticMutation = TRUE)
##'
##' # 2 only choose 'LUAD' and its clinical data
##' getTCGAdata(project = "LUAD")
##' \dontrun{
##' ###### download datasets
##'
##' # 3 download clinical datasets of LUAD and LUSC
##' getTCGAdata(project = c("LUAD", "LUSC"), clinical = TRUE, download = TRUE)
##'
##' # 4 download clinical, RPPA and gene mutation datasets of LUAD and LUSC
##' # getTCGAdata(project = c("LUAD", "LUSC"), clinical = TRUE, RPPAArray = TRUE, GeneMutation = TRUE)
##' }
getTCGAdata <- function(project = NULL,
clinical = TRUE,
download = FALSE,
forceDownload = FALSE,
destdir = tempdir(),
mRNASeq = FALSE,
mRNAArray = FALSE,
mRNASeqType = "normalized",
miRNASeq = FALSE,
exonRNASeq = FALSE,
RPPAArray = FALSE,
ReplicateBaseNormalization = FALSE,
Methylation = FALSE,
MethylationType = c("27K", "450K"),
GeneMutation = FALSE,
SomaticMutation = FALSE,
GisticCopyNumber = FALSE,
Gistic2Threshold = TRUE,
CopyNumberSegment = FALSE,
RemoveGermlineCNV = TRUE,
...) {
#----- check data type of input
stopifnot(!is.null(project))
stopifnot(is.logical(
c(
clinical,
mRNASeq,
mRNAArray,
miRNASeq,
RPPAArray,
ReplicateBaseNormalization,
Methylation,
GeneMutation,
SomaticMutation,
GisticCopyNumber,
Gistic2Threshold,
CopyNumberSegment,
RemoveGermlineCNV,
download,
forceDownload
)
))
projects <- c(
"LAML",
"ACC",
"CHOL",
"BLCA",
"BRCA",
"CESC",
"COADREAD",
"COAD",
"UCEC",
"ESCA",
"FPPP",
"GBM",
"HNSC",
"KICH",
"KIRC",
"KIRP",
"DLBC",
"LIHC",
"LGG",
"GBMLGG",
"LUAD",
"LUNG",
"LUSC",
"SKCM",
"MESO",
"UVM",
"OV",
"PANCAN",
"PAAD",
"PCPG",
"PRAD",
"READ",
"SARC",
"STAD",
"TGCT",
"THYM",
"THCA",
"UCS"
)
if (!all(project %in% projects)) {
message("Only following Project valid:")
print(project[project %in% projects])
stop("Invaild Input!")
}
tcga_all <- .decodeDataType(Target = "tcgaHub")
# tcga_all %>%
# filter(ProjectID %in% project) %>% # select project
# filter()
res <- subset(tcga_all, ProjectID %in% project)
res %>%
filter(
DataType != "Transcription Factor Regulatory Impact",
DataType != "Signatures",
DataType != "PARADIGM Pathway Activity",
DataType != "iCluster"
) -> res
if (clinical) {
quo_cli <- dplyr::quo((FileType == "Clinical Information"))
} else {
quo_cli <- dplyr::quo((FALSE))
}
if (mRNASeq) {
if (!all(mRNASeqType %in% c("normalized", "pancan normalized", "percentile"))) {
message("Available mRNASeqType values are:")
print(c("normalized", "pancan normalized", "percentile"))
stop("Not Vaild Input!")
}
RNA <- c(
"IlluminaHiSeq RNASeqV2",
"IlluminaHiSeq RNASeqV2 pancan normalized",
"IlluminaHiSeq RNASeqV2 in percentile rank"
)
names(RNA) <- c("normalized", "pancan normalized", "percentile")
RNA_select <- c(RNA[mRNASeqType], "Batch effects normalized")
quo_RNA <- dplyr::quo((
DataType == "Gene Expression RNASeq" & FileType %in% RNA_select
))
} else {
quo_RNA <- dplyr::quo((FALSE))
}
if (mRNAArray) {
quo_RNAa <- dplyr::quo((DataType == "Gene Expression Array"))
} else {
quo_RNAa <- dplyr::quo((FALSE))
}
if (miRNASeq) {
miRNA_select <- c("IlluminaHiSeq RNASeq", "Batch effects normalized")
quo_miRNA <- dplyr::quo((
DataType == "miRNA Mature Strand Expression RNASeq" &
FileType %in% miRNA_select
))
} else {
quo_miRNA <- dplyr::quo((FALSE))
}
if (exonRNASeq) {
quo_exon <- dplyr::quo((
DataType == "Exon Expression RNASeq" &
FileType == "IlluminaHiSeq RNASeqV2"
))
} else {
quo_exon <- dplyr::quo((FALSE))
}
# Have no miRNA Array? Need Check
# if(miRNAArray){
#
# }
if (RPPAArray) {
if (ReplicateBaseNormalization) {
RPPA_select <- "RPPA normalized by RBN"
} else {
RPPA_select <- "RPPA"
}
quo_RPPA <- dplyr::quo((
DataType == "Protein Expression RPPA" &
FileType %in% c(RPPA_select, "RPPA pancan normalized")
))
} else {
quo_RPPA <- dplyr::quo((FALSE))
}
if (Methylation) {
if (!all(MethylationType %in% c("27K", "450K"))) {
message("Available MethylationType values are:")
print(c("27K", "450K"))
stop("Not Vaild Input!")
}
Methy <- c("Methylation27K", "Methylation450K")
names(Methy) <- c("27K", "450K")
Methy_select <- Methy[MethylationType]
quo_Methy <- dplyr::quo((
DataType == "DNA Methylation" & FileType %in% Methy_select
))
} else {
quo_Methy <- dplyr::quo((FALSE))
}
if (GeneMutation) {
quo_genMutation <- dplyr::quo((
DataType == "Gene Somatic Non-silent Mutation" &
FileType %in% c("broad automated", "MC3 Public Version")
))
} else {
quo_genMutation <- dplyr::quo((FALSE))
}
if (SomaticMutation) {
quo_somaticMutation <- dplyr::quo((
DataType == "Somatic Mutation" &
FileType %in% c("broad automated", "MC3 Public Version")
))
} else {
quo_somaticMutation <- dplyr::quo((FALSE))
}
if (GisticCopyNumber) {
if (Gistic2Threshold) {
gistic_select <- "Gistic2 thresholded"
} else {
gistic_select <- "Gistic2"
}
quo_gistic <- dplyr::quo((
DataType == "Gene Level Copy Number" & FileType == gistic_select
))
} else {
quo_gistic <- dplyr::quo((FALSE))
}
if (CopyNumberSegment) {
if (RemoveGermlineCNV) {
cns_select <- "After remove germline cnv"
} else {
cns_select <- "Before remove germline cnv"
}
quo_cns <- dplyr::quo((
DataType == "Copy Number Segments" & FileType == cns_select
))
} else {
quo_cns <- dplyr::quo((FALSE))
}
cond_select <- dplyr::quo(
!!quo_cli |
!!quo_RNA |
!!quo_RNAa |
!!quo_miRNA |
!!quo_exon |
!!quo_RPPA |
!!quo_Methy |
!!quo_genMutation |
!!quo_somaticMutation | !!quo_gistic | !!quo_cns
)
res <- filter(res, !!cond_select)
if (download) {
res %>%
XenaGenerate() %>%
XenaQuery() %>%
XenaDownload(destdir = destdir, force = forceDownload, ...)
} else {
xe <- res %>% XenaGenerate()
list(Xena = xe, DataInfo = res)
}
}
##' @title Easily Download TCGA Data by Several Options
##' @description TCGA is a very useful database and here we provide this function to
##' download TCGA (include TCGA Pancan) datasets in human-friendly way. Users who are not
##' familiar with R operation will benefit from this.
##' @details All availble information about datasets of TCGA can access vis `availTCGA()` and
##' check with `showTCGA()`.
##' @author Shixiang Wang <w_shixiang@163.com>
##' @param project default is `NULL`. Should be one or more of TCGA project id (character vector) provided by Xena.
##' See all available project id, please use `availTCGA("ProjectID")`.
##' @param data_type default is `NULL`. Should be a character vector specify data type.
##' See all available data types by `availTCGA("DataType")`.
##' @param file_type default is `NULL`. Should be a character vector specify file type.
##' See all available file types by `availTCGA("FileType")`.
##' @inheritParams XenaDownload
##' @return same as `XenaDownload()` function result.
##' @export
##' @examples
##' \dontrun{
##' # download RNASeq data (use UVM as example)
##' downloadTCGA(project = "UVM",
##' data_type = "Gene Expression RNASeq",
##' file_type = "IlluminaHiSeq RNASeqV2")
##' }
##' @seealso [UCSCXenaTools::XenaQuery()],
##' [UCSCXenaTools::XenaFilter()],
##' [UCSCXenaTools::XenaDownload()],
##' [UCSCXenaTools::XenaPrepare()],
##' [UCSCXenaTools::availTCGA()],
##' [UCSCXenaTools::showTCGA()]
downloadTCGA <- function(project = NULL,
data_type = NULL,
file_type = NULL,
destdir = tempdir(),
force = FALSE,
...) {
stopifnot(
!is.null(project),
!is.null(data_type),
!is.null(file_type)
)
tcga_all <- .decodeDataType(Target = "tcgaHub")
tcga_projects <- unique(tcga_all$ProjectID)
# suppress binding notes
ProjectID <- DataType <- FileType <- NULL
if (!all(project %in% tcga_projects)) {
message(
project,
" are not (all) valid, please select one or more of following valid project ID:"
)
print(tcga_projects, quote = FALSE)
return(invisible(NULL))
}
res <- tcga_all %>%
filter(
ProjectID %in% project,
DataType %in% data_type,
FileType %in% file_type
)
if (nrow(res) == 0) { # nocov start
message("Find nothing about your input, please check it.")
message("availTCGA and showTCGA function may help you.")
return(invisible(NULL))
} # nocov end
res %>%
XenaGenerate() %>%
XenaQuery() %>%
XenaDownload(destdir = destdir, force = force, ...)
}
##' @title Get or Check TCGA Available ProjectID, DataType and FileType
##' @param which a character of `c("All", "ProjectID", "DataType", "FileType")`
##' @author Shixiang Wang <w_shixiang@163.com>
##' @export
##' @examples
##' \donttest{
##' availTCGA("all")
##' }
availTCGA <- function(which = c("all", "ProjectID", "DataType", "FileType")) {
which <- match.arg(which)
tcga_all <- .decodeDataType(Target = "tcgaHub")
tcga_projects <- unique(tcga_all$ProjectID)
tcga_datatype <- unique(tcga_all$DataType)
tcga_filetype <- unique(tcga_all$FileType)
if (which == "all") {
message(
"Note not all projects have listed data types and file types, you can use showTCGA function to check if exist"
)
return(
list(
ProjectID = tcga_projects,
DataType = tcga_datatype,
FileType = tcga_filetype
)
)
}
if (which == "ProjectID") {
return(tcga_projects)
}
if (which == "DataType") {
return(tcga_datatype)
}
if (which == "FileType") {
return(tcga_filetype)
}
}
##' @title Show TCGA data structure by Project ID or ALL
##' @description This can used to check if data type or file type exist in one or more projects by hand.
##' @param project a character vector. Can be "all" or one or more of TCGA Project IDs.
##' @return a `data.frame` including project data structure information.
##' @author Shixiang Wang <w_shixiang@163.com>
##' @export
##' @examples
##' \donttest{
##' showTCGA("all")
##' }
##' @seealso [UCSCXenaTools::availTCGA()]
showTCGA <- function(project = "all") {
# suppress binding notes
ProjectID <- DataType <- FileType <- NULL
tcga_all <- .decodeDataType(Target = "tcgaHub")
if (project == "all") {
# res = data.table::data.table(tcga_all)
# res = res[, .(ProjectID, DataType, FileType)]
res <- tcga_all %>% select(ProjectID, DataType, FileType)
} else {
res <- tcga_all %>%
filter(ProjectID %in% project) %>%
select(ProjectID, DataType, FileType)
# res = data.table::data.table(tcga_all)
# res = res[ProjectID %in% project, .(ProjectID, DataType, FileType)]
}
if (nrow(res) == 0) { # nocov start
message("Something is wrong in your input, NULL will be returned, please check.")
return(NULL)
} # nocov end
return(res)
}
# Only works for TCGA
.decodeDataType <- function(XenaData = UCSCXenaTools::XenaData,
Target = "tcgaHub") {
# This TCGA include TCGA PANCAN dataset
if ("tcgaHub" %in% Target) {
Target <- c(Target, "pancanAtlasHub")
}
# supress binding notes
XenaHostNames <- XenaCohorts <- NULL
ob <- XenaData %>% filter(XenaHostNames %in% Target)
if ("tcgaHub" %in% Target) {
# decode project id
ob %>% mutate(ProjectID = sub(".*\\((.*)\\)", "\\1", XenaCohorts)) -> ob
# decode DataType
ob %>%
mutate(
DataType = dplyr::case_when(
grepl("Gistic2_CopyNumber_Gistic2", XenaDatasets) ~ "Gene Level Copy Number",
grepl(
"PANCAN_Genome_Wide_SNP_6_whitelisted.gene.xena",
XenaDatasets
) ~ "Gene Level Copy Number",
# pancan
grepl("SNP6", XenaDatasets) ~ "Copy Number Segments",
grepl(
"PANCAN_Genome_Wide_SNP_6_whitelisted.xena",
XenaDatasets
) ~ "Copy Number Segments",
# pancan
grepl("HumanMethylation", XenaDatasets) ~ "DNA Methylation",
grepl("MethylMix", XenaDatasets) ~ "DNA Methylation",
grepl("HiSeq.*_exon", XenaDatasets) ~ "Exon Expression RNASeq",
grepl("GA_exon", XenaDatasets) ~ "Exon Expression RNASeq",
grepl("GAV2_exon", XenaDatasets) ~ "Exon Expression RNASeq",
grepl("AgilentG", XenaDatasets) ~ "Gene Expression Array",
grepl("HT_HG-U133A", XenaDatasets) ~ "Gene Expression Array",
grepl("GA$", XenaDatasets) &
!grepl("RABIT", XenaDatasets) ~ "Gene Expression RNASeq",
grepl("GAV2$", XenaDatasets) &
!grepl("RABIT", XenaDatasets) ~ "Gene Expression RNASeq",
grepl("HiSeq$", XenaDatasets) &
!grepl("RABIT", XenaDatasets) ~ "Gene Expression RNASeq",
grepl("HiSeqV2$", XenaDatasets) &
!grepl("RABIT", XenaDatasets) ~ "Gene Expression RNASeq",
grepl("HiSeqV2_PANCAN$", XenaDatasets) ~ "Gene Expression RNASeq",
grepl("HiSeqV2_percentile$", XenaDatasets) ~ "Gene Expression RNASeq",
grepl(
"EB\\+\\+AdjustPANCAN_IlluminaHiSeq_RNASeqV2.geneExp.xena",
XenaDatasets
) ~ "Gene Expression RNASeq",
# pancan
grepl("miRNA", XenaDatasets) ~ "miRNA Mature Strand Expression RNASeq",
grepl(
"pancanMiRs_EBadjOnProtocolPlatformWithoutRepsWithUnCorrectMiRs",
XenaDatasets
) ~ "miRNA Mature Strand Expression RNASeq",
# pancan
grepl("Pathway_Paradigm", XenaDatasets) ~ "PARADIGM Pathway Activity",
grepl("erge_merged_reals", XenaDatasets) ~ "PARADIGM Pathway Activity",
# pancan
grepl("clinicalMatrix", XenaDatasets) ~ "Phenotype",
grepl(
"Survival_SupplementalTable_S1_20171025_xena_sp",
XenaDatasets
) ~ "Phenotype",
# pancan
grepl("Subtype_Immune_Model_Based.txt", XenaDatasets) ~ "Phenotype",
# pancan
grepl("TCGASubtype.20170308.tsv", XenaDatasets) ~ "Phenotype",
# pancan
grepl(
"TCGA_phenotype_denseDataOnlyDownload.tsv",
XenaDatasets
) ~ "Phenotype",
# pancan
grepl("gene_expression_subtype", XenaDatasets) ~ "Phenotype",
# OV
grepl("RPPA", XenaDatasets) ~ "Protein Expression RPPA",
grepl("mutation_", XenaDatasets) &
!endsWith(XenaDatasets, "gene") ~ "Somatic Mutation",
grepl("mc3.v0.2.8.PUBLIC.xena", XenaDatasets) ~ "Somatic Mutation",
# pancan
grepl("mutation($|(.*_gene$))", XenaDatasets) ~ "Gene Somatic Non-silent Mutation",
grepl(
"mc3.v0.2.8.PUBLIC.nonsilentGene.xena",
XenaDatasets
) ~ "Gene Somatic Non-silent Mutation",
# pancan
grepl("RABIT", XenaDatasets) ~ "Transcription Factor Regulatory Impact",
grepl("iCluster", XenaDatasets) ~ "iCluster",
grepl(
"Pancan12_GenePrograms_drugTargetCanon_in_Pancan33.tsv",
XenaDatasets
) ~ "Signatures",
# pancan
grepl("TCGA.HRD_withSampleID.txt", XenaDatasets) ~ "Signatures",
# pancan
grepl(
"TCGA_pancancer_10852whitelistsamples_68ImmuneSigs.xena",
XenaDatasets
) ~ "Signatures",
# pancan
grepl("StemnessScores_DNAmeth_20170210.tsv", XenaDatasets) ~ "Signatures",
# pancan
grepl(
"StemnessScores_RNAexp_20170127.2.tsv",
XenaDatasets
) ~ "Signatures" # pancan
)
) -> ob
# decode file type
ob %>%
mutate(
FileType = dplyr::case_when(
DataType == "Gene Level Copy Number" &
grepl("Gistic2_all_data_by_genes", XenaDatasets) ~ "Gistic2",
DataType == "Gene Level Copy Number" &
grepl("Gistic2_all_thresholded.by_genes", XenaDatasets) ~ "Gistic2 thresholded",
DataType == "Gene Level Copy Number" &
grepl(
"PANCAN_Genome_Wide_SNP_6_whitelisted.gene.xena",
XenaDatasets
) ~ "Tumor copy number",
DataType == "Copy Number Segments" &
grepl("SNP6_genomicSegment", XenaDatasets) ~ "Before remove germline cnv",
DataType == "Copy Number Segments" &
grepl("SNP6_nocnv_genomicSegment", XenaDatasets) ~ "After remove germline cnv",
DataType == "Copy Number Segments" &
grepl(
"PANCAN_Genome_Wide_SNP_6_whitelisted.xena",
XenaDatasets
) ~ "After remove germline cnv",
DataType == "DNA Methylation" &
grepl("HumanMethylation27", XenaDatasets) ~ "Methylation27K",
DataType == "DNA Methylation" &
grepl("HumanMethylation450", XenaDatasets) ~ "Methylation450K",
DataType == "DNA Methylation" &
grepl("oneoff_TCGA_LGG_MethylMix", XenaDatasets) ~ "MethylMix",
DataType == "Exon Expression RNASeq" &
grepl("GA_exon", XenaDatasets) ~ "IlluminaGA RNASeq",
DataType == "Exon Expression RNASeq" &
grepl("GAV2_exon", XenaDatasets) ~ "IlluminaGA RNASeqV2",
DataType == "Exon Expression RNASeq" &
grepl("HiSeq_exon", XenaDatasets) ~ "IlluminaHiSeq RNASeq",
DataType == "Exon Expression RNASeq" &
grepl("HiSeqV2_exon", XenaDatasets) ~ "IlluminaHiSeq RNASeqV2",
DataType == "Gene Expression Array" &
grepl("AgilentG4502A", XenaDatasets) ~ "Agilent 244K Microarray",
DataType == "Gene Expression Array" &
grepl("HT_HG-U133A", XenaDatasets) ~ "Affymetrix U133A Microarray",
DataType == "Gene Expression RNASeq" &
endsWith(XenaDatasets, "GA") ~ "IlluminaGA RNASeq",
DataType == "Gene Expression RNASeq" &
endsWith(XenaDatasets, "GAV2") ~ "IlluminaGA RNASeqV2",
DataType == "Gene Expression RNASeq" &
endsWith(XenaDatasets, "HiSeq") ~ "IlluminaHiSeq RNASeq",
DataType == "Gene Expression RNASeq" &
endsWith(XenaDatasets, "HiSeqV2") ~ "IlluminaHiSeq RNASeqV2",
DataType == "Gene Expression RNASeq" &
endsWith(XenaDatasets, "HiSeqV2_PANCAN") ~ "IlluminaHiSeq RNASeqV2 pancan normalized",
DataType == "Gene Expression RNASeq" &
endsWith(XenaDatasets, "HiSeqV2_percentile") ~ "IlluminaHiSeq RNASeqV2 in percentile rank",
DataType == "Gene Expression RNASeq" &
grepl("AdjustPANCAN_IlluminaHiSeq_RNASeqV2", XenaDatasets) ~ "Batch effects normalized",
DataType == "miRNA Mature Strand Expression RNASeq" &
endsWith(XenaDatasets, "miRNA_GA_gene") ~ "IlluminaGA RNASeq",
DataType == "miRNA Mature Strand Expression RNASeq" &
endsWith(XenaDatasets, "miRNA_HiSeq_gene") ~ "IlluminaHiSeq RNASeq",
DataType == "miRNA Mature Strand Expression RNASeq" &
grepl(
"pancanMiRs_EBadjOnProtocolPlatformWithoutRepsWithU",
XenaDatasets
) ~ "Batch effects normalized",
DataType == "PARADIGM Pathway Activity" &
grepl("merge_merged_reals", XenaDatasets) ~ "Platform-corrected PANCAN12 dataset",
DataType == "PARADIGM Pathway Activity" &
endsWith(XenaDatasets, "Pathway_Paradigm_mRNA") ~ "Use only Microarray",
DataType == "PARADIGM Pathway Activity" &
endsWith(
XenaDatasets,
"Pathway_Paradigm_mRNA_And_Copy_Number"
) ~ "Use Microarray plus Copy Number",
DataType == "PARADIGM Pathway Activity" &
endsWith(XenaDatasets, "Pathway_Paradigm_RNASeq") ~ "Use only RNASeq",
DataType == "PARADIGM Pathway Activity" &
endsWith(
XenaDatasets,
"Pathway_Paradigm_RNASeq_And_Copy_Number"
) ~ "Use RNASeq plus Copy Number",
DataType == "Phenotype" &
endsWith(XenaDatasets, "clinicalMatrix") ~ "Clinical Information",
DataType == "Phenotype" &
grepl(
"Survival_SupplementalTable_S1_20171025_xena_sp",
XenaDatasets
) ~ "Clinical Information",
DataType == "Phenotype" &
grepl("gene_expression_subtype", XenaDatasets) ~ "Gene Expression Subtype",
DataType == "Phenotype" &
grepl("Subtype_Immune_Model_Based", XenaDatasets) ~ "Immune Model Based Subtype",
DataType == "Phenotype" &
grepl("TCGASubtype", XenaDatasets) ~ "TCGA Molecular Subtype",
DataType == "Phenotype" &
grepl(
"TCGA_phenotype_denseDataOnlyDownload",
XenaDatasets
) ~ "TCGA Sample Type and Primary Disease",
DataType == "Protein Expression RPPA" &
endsWith(XenaDatasets, "RPPA") ~ "RPPA",
DataType == "Protein Expression RPPA" &
endsWith(XenaDatasets, "RPPA_RBN") ~ "RPPA normalized by RBN",
DataType == "Protein Expression RPPA" &
grepl("TCGA-RPPA-pancan-clean", XenaDatasets) ~ "RPPA pancan normalized",
DataType == "Somatic Mutation" &
grepl("mc3.v0.2.8.PUBLIC.xena", XenaDatasets) ~ "MC3 Public Version",
DataType == "Somatic Mutation" &
endsWith(XenaDatasets, "mutation_bcgsc") ~ "bcgsc automated",
DataType == "Somatic Mutation" &
endsWith(XenaDatasets, "mutation_bcm") ~ "bcm automated",
DataType == "Somatic Mutation" &
endsWith(XenaDatasets, "mutation_bcm_solid") ~ "bcm SOLiD",
DataType == "Somatic Mutation" &
endsWith(XenaDatasets, "mutation_broad") ~ "broad automated",
DataType == "Somatic Mutation" &
endsWith(XenaDatasets, "mutation_curated_bcm") ~ "bcm curated",
DataType == "Somatic Mutation" &
endsWith(XenaDatasets, "mutation_curated_bcm_solid") ~ "bcm SOLiD curated",
DataType == "Somatic Mutation" &
endsWith(XenaDatasets, "mutation_curated_broad") ~ "broad curated",
DataType == "Somatic Mutation" &
endsWith(XenaDatasets, "mutation_curated_wustl") ~ "wustl curated",
DataType == "Somatic Mutation" &
endsWith(XenaDatasets, "mutation_ucsc_maf") ~ "ucsc automated",
DataType == "Somatic Mutation" &
endsWith(XenaDatasets, "mutation_wustl") ~ "wustl automated",
DataType == "Somatic Mutation" &
endsWith(XenaDatasets, "mutation_wustl_hiseq") ~ "wustl hiseq automated",
DataType == "Gene Somatic Non-silent Mutation" &
grepl(
"mc3.v0.2.8.PUBLIC.nonsilentGene.xena",
XenaDatasets
) ~ "MC3 Public Version",
DataType == "Gene Somatic Non-silent Mutation" &
endsWith(XenaDatasets, "mutation") ~ "PANCAN AWG analyzed",
DataType == "Gene Somatic Non-silent Mutation" &
endsWith(XenaDatasets, "mutation_bcgsc_gene") ~ "bsgsc automated",
DataType == "Gene Somatic Non-silent Mutation" &
endsWith(XenaDatasets, "mutation_bcm_gene") ~ "bcm automated",
DataType == "Gene Somatic Non-silent Mutation" &
endsWith(XenaDatasets, "mutation_bcm_solid_gene") ~ "bcm SOLiD",
DataType == "Gene Somatic Non-silent Mutation" &
endsWith(XenaDatasets, "mutation_broad_gene") ~ "broad automated",
DataType == "Gene Somatic Non-silent Mutation" &
endsWith(XenaDatasets, "mutation_curated_bcm_gene") ~ "bcm curated",
DataType == "Gene Somatic Non-silent Mutation" &
endsWith(XenaDatasets, "mutation_curated_bcm_solid_gene") ~ "bcm SOLiD curated",
DataType == "Gene Somatic Non-silent Mutation" &
endsWith(XenaDatasets, "mutation_curated_broad_gene") ~ "broad curated",
DataType == "Gene Somatic Non-silent Mutation" &
endsWith(XenaDatasets, "mutation_curated_wustl_gene") ~ "wustl curated",
DataType == "Gene Somatic Non-silent Mutation" &
endsWith(XenaDatasets, "mutation_ucsc_maf_gene") ~ "ucsc automated",
DataType == "Gene Somatic Non-silent Mutation" &
endsWith(XenaDatasets, "mutation_wustl_gene") ~ "wustl automated",
DataType == "Gene Somatic Non-silent Mutation" &
endsWith(XenaDatasets, "mutation_wustl_hiseq_gene") ~ "wustl hiseq automated",
DataType == "Transcription Factor Regulatory Impact" &
grepl("HiSeq.V2$", XenaDatasets) ~ "RABIT Use IlluminaHiSeq RNASeqV2",
DataType == "Transcription Factor Regulatory Impact" &
grepl("HiSeq$", XenaDatasets) ~ "RABIT Use IlluminaHiSeq RNASeq",
DataType == "Transcription Factor Regulatory Impact" &
grepl("GA.V2$", XenaDatasets) ~ "RABIT Use IlluminaGA RNASeqV2",
DataType == "Transcription Factor Regulatory Impact" &
grepl("GA$", XenaDatasets) ~ "RABIT Use IlluminaGA RNASeq",
DataType == "Transcription Factor Regulatory Impact" &
grepl("Agilent$", XenaDatasets) ~ "RABIT Use Agilent 244K Microarray",
DataType == "Transcription Factor Regulatory Impact" &
grepl("U133A$", XenaDatasets) ~ "RABIT Use Affymetrix U133A Microarray",
DataType == "iCluster" &
grepl("TCGA_PanCan33_iCluster_k28_tumor", XenaDatasets) ~ "iCluster cluster assignments",
DataType == "iCluster" &
grepl("lat.vars.iCluster.redo.tumor", XenaDatasets) ~ "iCluster latent variables",
DataType == "Signatures" &
grepl(
"Pancan12_GenePrograms_drugTargetCanon",
XenaDatasets
) ~ "Pancan Gene Programs",
DataType == "Signatures" &
grepl("StemnessScores_DNAmeth_", XenaDatasets) ~ "DNA methylation based StemnessScore",
DataType == "Signatures" &
grepl("StemnessScores_RNAexp", XenaDatasets) ~ "RNA based StemnessScore",
DataType == "Signatures" &
grepl(
"TCGA_pancancer_10852whitelistsamples_68ImmuneSigs",
XenaDatasets
) ~ "Immune Signature Scores",
DataType == "Signatures" &
grepl("TCGA.HRD_withSampleID.txt", XenaDatasets) ~ "Genome-wide DNA Damage Footprint HRD Score"
)
) -> ob_tcga
}
ob_tcga
}
# grep unique pattern
# ob1 = sub("TCGA.*/(.*)", "\\1", ob$XenaDatasets) %>% table() %>% names() -> uniqueDatasets
# ob1 = tibble(XenaDatasets = uniqueDatasets)
# grep("gene_expression_subtype", ob$XenaDatasets, value = TRUE)
utils::globalVariables(c("DataType", "FileType", "ProjectID"))