# 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 et al. 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 3.4.3 (2017-11-30)
    ## 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] SummarizedExperiment_1.8.1 DelayedArray_0.4.1
    ##  [3] matrixStats_0.52.2         Biobase_2.38.0
    ##  [5] GenomicRanges_1.30.1       GenomeInfoDb_1.14.0
    ##  [7] IRanges_2.12.0             S4Vectors_0.16.0
    ##  [9] BiocGenerics_0.24.0        bindrcpp_0.2
    ## [11] ELMER_2.2.7                MultiAssayExperiment_1.4.4
    ## [13] BiocStyle_2.6.1            dplyr_0.7.4
    ## [15] DT_0.2                     ELMER.data_2.2.2
    ##
    ## loaded via a namespace (and not attached):
    ##   [1] shinydashboard_0.6.1          R.utils_2.6.0
    ##   [3] RSQLite_2.0                   AnnotationDbi_1.40.0
    ##   [5] htmlwidgets_0.9               grid_3.4.3
    ##   [7] BiocParallel_1.12.0           devtools_1.13.4
    ##   [9] DESeq_1.30.0                  munsell_0.4.3
    ##  [11] codetools_0.2-15              withr_2.1.1
    ##  [13] colorspace_1.3-2              BiocInstaller_1.28.0
    ##  [15] knitr_1.17                    rstudioapi_0.7
    ##  [17] labeling_0.3                  GenomeInfoDbData_1.0.0
    ##  [19] mnormt_1.5-5                  hwriter_1.3.2
    ##  [21] KMsurv_0.1-5                  bit64_0.9-7
    ##  [23] rprojroot_1.3-1               downloader_0.4
    ##  [25] biovizBase_1.26.0             ggthemes_3.4.0
    ##  [27] EDASeq_2.12.0                 R6_2.2.2
    ##  [29] doParallel_1.0.11             locfit_1.5-9.1
    ##  [31] AnnotationFilter_1.2.0        bitops_1.0-6
    ##  [33] reshape_0.8.7                 assertthat_0.2.0
    ##  [35] scales_0.5.0                  nnet_7.3-12
    ##  [37] gtable_0.2.0                  sva_3.26.0
    ##  [39] ensembldb_2.2.0               rlang_0.1.6
    ##  [41] genefilter_1.60.0             cmprsk_2.2-7
    ##  [43] GlobalOptions_0.0.12          splines_3.4.3
    ##  [45] rtracklayer_1.38.2            lazyeval_0.2.1
    ##  [47] acepack_1.4.1                 dichromat_2.0-0
    ##  [49] selectr_0.3-1                 broom_0.4.3
    ##  [51] checkmate_1.8.5               yaml_2.1.16
    ##  [53] reshape2_1.4.3                GenomicFeatures_1.30.0
    ##  [55] backports_1.1.2               httpuv_1.3.5
    ##  [57] Hmisc_4.1-0                   RMySQL_0.10.13
    ##  [59] tools_3.4.3                   psych_1.7.8
    ##  [61] ggplot2_2.2.1                 RColorBrewer_1.1-2
    ##  [63] Rcpp_0.12.14                  plyr_1.8.4
    ##  [65] base64enc_0.1-3               progress_1.1.2
    ##  [67] zlibbioc_1.24.0               purrr_0.2.4
    ##  [69] RCurl_1.95-4.8                prettyunits_1.0.2
    ##  [71] ggpubr_0.1.6                  rpart_4.1-11
    ##  [73] GetoptLong_0.1.6              zoo_1.8-0
    ##  [75] ggrepel_0.7.0                 cluster_2.0.6
    ##  [77] magrittr_1.5                  data.table_1.10.4-3
    ##  [79] circlize_0.4.3                survminer_0.4.1
    ##  [81] ProtGenerics_1.10.0           aroma.light_3.8.0
    ##  [83] hms_0.4.0                     mime_0.5
    ##  [85] evaluate_0.10.1               xtable_1.8-2
    ##  [87] XML_3.98-1.9                  gridExtra_2.3
    ##  [89] shape_1.4.3                   testthat_2.0.0
    ##  [91] compiler_3.4.3                biomaRt_2.34.1
    ##  [93] tibble_1.4.1                  R.oo_1.21.0
    ##  [95] htmltools_0.3.6               mgcv_1.8-22
    ##  [97] Formula_1.2-2                 tidyr_0.7.2
    ##  [99] geneplotter_1.56.0            DBI_0.7
    ## [101] matlab_1.0.2                  ComplexHeatmap_1.17.1
    ## [103] ShortRead_1.36.0              Matrix_1.2-12
    ## [105] readr_1.1.1                   R.methodsS3_1.7.1
    ## [107] Gviz_1.22.2                   bindr_0.1
    ## [109] pkgconfig_2.0.1               km.ci_0.5-2
    ## [111] GenomicAlignments_1.14.1      foreign_0.8-69
    ## [113] plotly_4.7.1                  xml2_1.1.1
    ## [115] roxygen2_6.0.1                foreach_1.4.4
    ## [117] annotate_1.56.1               XVector_0.18.0
    ## [119] rvest_0.3.2                   stringr_1.2.0
    ## [121] VariantAnnotation_1.24.4      digest_0.6.13
    ## [123] ConsensusClusterPlus_1.42.0   Biostrings_2.46.0
    ## [125] rmarkdown_1.8                 TCGAbiolinks_2.6.7
    ## [127] survMisc_0.5.4                htmlTable_1.11.0
    ## [129] edgeR_3.20.3                  curl_3.1
    ## [131] shiny_1.0.5                   Rsamtools_1.30.0
    ## [133] commonmark_1.4                rjson_0.2.15
    ## [135] nlme_3.1-131                  jsonlite_1.5
    ## [137] viridisLite_0.2.0             limma_3.34.5
    ## [139] BSgenome_1.46.0               pillar_1.0.1
    ## [141] lattice_0.20-35               httr_1.3.1
    ## [143] survival_2.41-3               interactiveDisplayBase_1.16.0
    ## [145] glue_1.2.0                    iterators_1.0.9
    ## [147] bit_1.1-12                    stringi_1.1.6
    ## [149] blob_1.1.0                    AnnotationHub_2.10.1
    ## [151] latticeExtra_0.6-28           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. doi:10.1093/nar/gkv1507.

Grossman, Robert L, Allison P Heath, Vincent Ferretti, Harold E Varmus, Douglas R Lowy, Warren A Kibbe, and Louis M Staudt. 2016. “Toward a Shared Vision for Cancer Genomic Data.” New England Journal of Medicine 375 (12). Mass Medical Soc: 1109–12.