--- title: "Using `RTCGA` package to download CNV data that are included in `RTCGA.CNV` package" subtitle: "Date of datasets release: 2015-11-01" author: "Przemyslaw Biecek" date: "`r Sys.Date()`" output: rmarkdown::html_vignette vignette: > %\VignetteIndexEntry{Using RTCGA to download CNV data as included in RTCGA.CNV} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- ```{r, echo=FALSE} library(knitr) opts_chunk$set(comment="", message=FALSE, warning = FALSE, tidy.opts=list(keep.blank.line=TRUE, width.cutoff=150),options(width=150), eval = FALSE) ``` # RTCGA package > The Cancer Genome Atlas (TCGA) Data Portal provides a platform for researchers to search, download, and analyze data sets generated by TCGA. It contains clinical information, genomic characterization data, and high level sequence analysis of the tumor genomes. The key is to understand genomics to improve cancer care. `RTCGA` package offers download and integration of the variety and volume of TCGA data using patient barcode key, what enables easier data possession. This may have an benefcial infuence on impact on development of science and improvement of patients' treatment. `RTCGA` is an open-source R package, available to download from Bioconductor ```{r, eval=FALSE} if (!requireNamespace("BiocManager", quietly=TRUE)) install.packages("BiocManager") BiocManager::install("RTCGA") ``` or from github ```{r, eval=FALSE} if (!require(devtools)) { install.packages("devtools") require(devtools) } BiocManager::install("RTCGA/RTCGA") ``` Furthermore, `RTCGA` package transforms TCGA data to form which is convenient to use in R statistical package. Those data transformations can be a part of statistical analysis pipeline which can be more reproducible with `RTCGA`. Use cases and examples are shown in `RTCGA` packages vignettes: ```{r, eval=FALSE} browseVignettes("RTCGA") ``` # How to download CNV data (i.e. copy number variation) to gain the same datasets as in RTCGA.CNV package? There are many available date times of TCGA data releases. To see them all just type: ```{r, eval=FALSE} library(RTCGA) checkTCGA('Dates') ``` Version 1.0 of `RTCGA.CNV` package contains clinical datasets from `2015-11-01`. There were downloaded as follows (which is mainly copied from [http://rtcga.github.io/RTCGA/](http://rtcga.github.io/RTCGA/): ## Available cohorts All cohort names can be checked using: ```{r, eval=FALSE} (cohorts <- infoTCGA() %>% rownames() %>% sub("-counts", "", x=.)) ``` For all cohorts the following code downloads the CNV data. ## Downloading files ```{r, eval=FALSE} #dir.create( "data/CNV2" ) releaseDate <- "2015-11-01" for (cohort in cohorts) { try(downloadTCGA( cancerTypes = cohort, destDir = "data/CNV2", date = releaseDate, dataSet = "Merge_snp__genome_wide_snp_6__broad_mit_edu__Level_3__segmented_scna_minus_germline_cnv_hg19__seg.Level_3" ), silent=TRUE) } ``` ## Reading downloaded CNV dataset Datasets from the folder `data/CNV2` are imported and transformed into rda files. ```{r, eval=FALSE} allCNVFiles <- list.files("data/CNV2", pattern = "cnv", recursive = TRUE, full.names = TRUE) for (CNVFile in allCNVFiles) { CNV <- read.table(CNVFile,h=T) cohortName <- strsplit(strsplit(CNVFile, split = "/")[[1]][4], "\\.")[[1]][1] name = paste0(cohortName, ".CNV") assign(name, CNV) save(list = name, file=paste0("data/CNV2/", name, ".rda"), compression_level = 9, compress = "xz") } ``` # Saving CNV data to `RTCGA.CNV` package Now you should copy all rda files into the RTCGA.CNV package data directory.