# 3.6 - TCGA.pipe: Running ELMER for TCGA data in a compact way

# TCGA.pipe: Running ELMER for TCGA data in a compact way

`TCGA.pipe` is a function for easily downloading TCGA data from GDC using TCGAbiolinks package (Colaprico et al. 2016) and performing all the analyses in ELMER. For illustration purpose, we skip the downloading step. The user can use the `getTCGA` function to download TCGA data or use `TCGA.pipe` by including “download” in the analysis option.

The following command will do distal DNA methylation analysis and predict putative target genes, motif analysis and identify regulatory transcription factors.

    TCGA.pipe("LUSC",
              wd = "./ELMER.example",
              cores = parallel::detectCores()/2,
              mode = "unsupervised"
              permu.size = 300,
              Pe = 0.01,
              analysis = c("distal.probes","diffMeth","pair","motif","TF.search"),
              diff.dir = "hypo",
              rm.chr = paste0("chr",c("X","Y")))

TCGA.pipe: Mode argument

In this new version we added the argument `mode` in the `TCGA.pipe` function. This will automatically set the `minSubgroupFrac` to the following values:

Modes available:

- `unsupervised`:
  - Use 20% of each group to identify differently methylated regions (`minSubgroupFrac` = 0.2 in `get.diff.meth`)
  - Use 40% of all samples to create Unmethytlated (U) and Methylated (M) groups in the other steps (the lowest quintile of samples is the U group and the highest quintile samples is the M group) (`minSubgroupFrac` = 0.4 in `get.pairs` and `get.TFs` functions)
- `supervised`:
  - Use all samples in all functions and set Unmethytlated (U) and Methylated (M) one of the group selected in the analysis.

The `unsupervised` mode should be used when want to be able to detect a specific (possibly unknown) molecular subtype among tumor; these subtypes often make up only a minority of samples, and 20% was chosen as a lower bound for the purposes of statistical power. If you are using pre-defined group labels, such as treated replicates vs. untreated replicated, use `supervised` mode (all samples),

For more information please read the analysis section of the vignette.

# Using mutation data to identify groups

We add in `TCGA.pipe` function (download step) the option to identify mutant samples to perform WT vs Mutant analysis. It will download open MAF file from GDC database (Grossman and others 2016), select a gene and identify the which are the mutant samples based on the following classification: (it can be changed using the atgument `mutant_variant_classification`).

Mutations classification

Argument | Description
--- | ---
Frame_Shift_Del | Mutant
Frame_Shift_Ins | Mutant
Missense_Mutation | Mutant
Nonsense_Mutation | Mutant
Splice_Site | Mutant
In_Frame_Del | Mutant
In_Frame_Ins | Mutant
Translation_Start_Site | Mutant
Nonstop_Mutation | Mutant
Silent | WT
3’UTR | WT
5’UTR | WT
3’Flank | WT
5’Flank | WT
IGR1 (intergenic region) | WT
Intron | WT
RNA | WT
Target_region | WT

The arguments to be used are below:

`TCGA.pipe` mutation arguments

Argument | Description
--- | ---
genes | List of genes for which mutations will be verified. A column in the MAE with the name of the gene will be created with two groups WT (tumor samples without mutation), MUT (tumor samples w/ mutation), NA (not tumor samples)
mutant_variant_classification | List of GDC variant classification from MAF files to consider a samples mutant. Only used when argument gene is set.
group.col | A column defining the groups of the sample. You can view the available columns using: colnames(MultiAssayExperiment::colData(data)).
group1 | A group from group.col. ELMER will run group1 vs group2. That means, if direction is hyper, get probes hypermethylated in group 1 compared to group 2.
group2 | A group from group.col. ELMER will run group1 vs group2. That means, if direction is hyper, get probes hypermethylated in group 1 compared to group 2.

Here is an example we TCGA-LUSC data is downloaded and we will compare TP53 Mutant vs TP53 WT samples.

    TCGA.pipe("LUSC",
              wd = "./ELMER.example",
              cores = parallel::detectCores()/2,
              mode = "supervised"
              genes = "TP53",
              group.col = "TP53",
              group1 = "Mutant",
              group2 = "WT",
              permu.size = 300,
              Pe = 0.01,
              analysis = c("download","diffMeth","pair","motif","TF.search"),
              diff.dir = "hypo",
              rm.chr = paste0("chr",c("X","Y")))

# Session Info

    sessionInfo()

    ## R version 4.0.0 (2020-04-24)
    ## Platform: x86_64-w64-mingw32/x64 (64-bit)
    ## Running under: Windows Server 2012 R2 x64 (build 9600)
    ##
    ## Matrix products: default
    ##
    ## locale:
    ## [1] LC_COLLATE=C
    ## [2] LC_CTYPE=English_United States.1252
    ## [3] LC_MONETARY=English_United States.1252
    ## [4] LC_NUMERIC=C
    ## [5] LC_TIME=English_United States.1252
    ##
    ## attached base packages:
    ## [1] parallel  stats4    stats     graphics  grDevices utils     datasets
    ## [8] methods   base
    ##
    ## other attached packages:
    ##  [1] MultiAssayExperiment_1.14.0 SummarizedExperiment_1.18.0
    ##  [3] DelayedArray_0.14.0         matrixStats_0.56.0
    ##  [5] Biobase_2.48.0              GenomicRanges_1.40.0
    ##  [7] GenomeInfoDb_1.24.0         IRanges_2.22.0
    ##  [9] S4Vectors_0.26.0            BiocGenerics_0.34.0
    ## [11] BiocStyle_2.16.0            dplyr_0.8.5
    ## [13] DT_0.13                     ELMER_2.12.0
    ## [15] ELMER.data_2.11.0
    ##
    ## loaded via a namespace (and not attached):
    ##   [1] R.utils_2.9.2            tidyselect_1.0.0         RSQLite_2.2.0
    ##   [4] AnnotationDbi_1.50.0     htmlwidgets_1.5.1        grid_4.0.0
    ##   [7] BiocParallel_1.22.0      DESeq_1.40.0             munsell_0.5.0
    ##  [10] codetools_0.2-16         colorspace_1.4-1         knitr_1.28
    ##  [13] rstudioapi_0.11          ggsignif_0.6.0           labeling_0.3
    ##  [16] GenomeInfoDbData_1.2.3   hwriter_1.3.2            KMsurv_0.1-5
    ##  [19] parsetools_0.1.3         farver_2.0.3             bit64_0.9-7
    ##  [22] downloader_0.4           vctrs_0.2.4              generics_0.0.2
    ##  [25] xfun_0.13                biovizBase_1.36.0        ggthemes_4.2.0
    ##  [28] BiocFileCache_1.12.0     EDASeq_2.22.0            R6_2.4.1
    ##  [31] doParallel_1.0.15        clue_0.3-57              locfit_1.5-9.4
    ##  [34] AnnotationFilter_1.12.0  bitops_1.0-6             reshape_0.8.8
    ##  [37] assertthat_0.2.1         scales_1.1.0             nnet_7.3-14
    ##  [40] gtable_0.3.0             sva_3.36.0               ensembldb_2.12.0
    ##  [43] rlang_0.4.5              pkgcond_0.1.0            genefilter_1.70.0
    ##  [46] GlobalOptions_0.1.1      splines_4.0.0            rtracklayer_1.48.0
    ##  [49] lazyeval_0.2.2           acepack_1.4.1            dichromat_2.0-0
    ##  [52] selectr_0.4-2            broom_0.5.6              checkmate_2.0.0
    ##  [55] BiocManager_1.30.10      yaml_2.2.1               reshape2_1.4.4
    ##  [58] crosstalk_1.1.0.1        GenomicFeatures_1.40.0   backports_1.1.6
    ##  [61] Hmisc_4.4-0              purrrogress_0.1.1        tools_4.0.0
    ##  [64] ggplot2_3.3.0            ellipsis_0.3.0           RColorBrewer_1.1-2
    ##  [67] Rcpp_1.0.4.6             plyr_1.8.6               base64enc_0.1-3
    ##  [70] progress_1.2.2           zlibbioc_1.34.0          purrr_0.3.4
    ##  [73] RCurl_1.98-1.2           prettyunits_1.1.1        ggpubr_0.2.5
    ##  [76] rpart_4.1-15             openssl_1.4.1            GetoptLong_0.1.8
    ##  [79] zoo_1.8-7                ggrepel_0.8.2            cluster_2.1.0
    ##  [82] magrittr_1.5             data.table_1.12.8        circlize_0.4.8
    ##  [85] survminer_0.4.6          ProtGenerics_1.20.0      aroma.light_3.18.0
    ##  [88] hms_0.5.3                evaluate_0.14            xtable_1.8-4
    ##  [91] XML_3.99-0.3             jpeg_0.1-8.1             gridExtra_2.3
    ##  [94] shape_1.4.4              testthat_2.3.2           compiler_4.0.0
    ##  [97] biomaRt_2.44.0           tibble_3.0.1             crayon_1.3.4
    ## [100] R.oo_1.23.0              htmltools_0.4.0          mgcv_1.8-31
    ## [103] Formula_1.2-3            tidyr_1.0.2              geneplotter_1.66.0
    ## [106] postlogic_0.1.0.1        DBI_1.1.0                dbplyr_1.4.3
    ## [109] ComplexHeatmap_2.4.0     rappdirs_0.3.1           ShortRead_1.46.0
    ## [112] Matrix_1.2-18            readr_1.3.1              R.methodsS3_1.8.0
    ## [115] Gviz_1.32.0              pkgconfig_2.0.3          km.ci_0.5-2
    ## [118] GenomicAlignments_1.24.0 foreign_0.8-79           testextra_0.1.0.1
    ## [121] plotly_4.9.2.1           xml2_1.3.2               foreach_1.5.0
    ## [124] annotate_1.66.0          XVector_0.28.0           rvest_0.3.5
    ## [127] stringr_1.4.0            VariantAnnotation_1.34.0 digest_0.6.25
    ## [130] Biostrings_2.56.0        rmarkdown_2.1            TCGAbiolinks_2.16.0
    ## [133] survMisc_0.5.5           htmlTable_1.13.3         edgeR_3.30.0
    ## [136] curl_4.3                 Rsamtools_2.4.0          rjson_0.2.20
    ## [139] lifecycle_0.2.0          nlme_3.1-147             jsonlite_1.6.1
    ## [142] viridisLite_0.3.0        askpass_1.1              limma_3.44.0
    ## [145] BSgenome_1.56.0          pillar_1.4.3             lattice_0.20-41
    ## [148] httr_1.4.1               survival_3.1-12          glue_1.4.0
    ## [151] png_0.1-7                iterators_1.0.12         bit_1.1-15.2
    ## [154] stringi_1.4.6            blob_1.2.1               latticeExtra_0.6-29
    ## [157] memoise_1.1.0

# Bibliography

Colaprico, Antonio, Tiago C. Silva, Catharina Olsen, Luciano Garofano, Claudia Cava, Davide Garolini, Thais S. Sabedot, et al. 2016. “TCGAbiolinks: An R/Bioconductor Package for Integrative Analysis of Tcga Data.” Nucleic Acids Research 44 (8): e71. https://doi.org/10.1093/nar/gkv1507.

Grossman, Robert L, and others. 2016. “Toward a Shared Vision for Cancer Genomic Data.” New England Journal of Medicine 375 (12): 1109–12.