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

source("http://bioconductor.org/biocLite.R")
biocLite("RTCGA")

or from github

if (!require(devtools)) {
    install.packages("devtools")
    require(devtools)
}
biocLite("MarcinKosinski/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:

browseVignettes("RTCGA")

How to download clinical data to gain the same datasets as in RTCGA.clinical package?

There are many available date times of TCGA data releases. To see them all just type:

library(RTCGA)
checkTCGA('Dates')

Version 1.0 of RTCGA.clinical package contains clinical datasets from 2015-08-21. There were downloaded as follows (which is mainly copied from http://marcinkosinski.github.io/RTCGA/:

Available cohorts

All cohort names can be checked using:

(cohorts <- infoTCGA() %>% 
   rownames() %>% 
   sub("-counts", "", x=.))

For all cohorts the following code downloads the clinical data.

Downloading tarred files

#dir.create( "data2" )
releaseDate <- "2015-08-21"
downloadTCGA( cancerTypes = cohorts, destDir = "data2", date = releaseDate )

Reading downloaded clinical dataset

Paths to clinical data

Below is the code that automatically gives the path to *.clinical.merged.txt files for all cohorts types downloaded to data2 folder.

sapply( cohorts, function( element ){
   folder <- grep( paste0( "(_",element,"\\.", "|","_",element,"-FFPE)", ".*Clinical"), list.files("data2/"),value = TRUE)
   path <- paste0( "data2/", folder, "/", element, ".clin.merged.txt")
   assign( value = path, x = paste0(element, ".clin.path"), envir = .GlobalEnv)
}) 

Reading clinical data using readTCGA

Because of the fact that clinical data are transposed in downloaded files, there have been prepared special function readTCGA to read and transpose data automatically. Code is below

sapply( cohorts, function(element){
   tryCatch({
     readTCGA(get(paste0(element,".clin.path"),
                          envir = .GlobalEnv),
                 "clinical") -> clinical_file
     
     ## remove non-ASCII strings:
     for( i in 1:ncol(clinical_file)){
       clinical_file[, i] <- iconv(clinical_file[, i],
                                    "UTF-8", "ASCII", sub="")
     }   
   assign( value = clinical_file,
            x = paste0(element, ".clinical"),
            envir = .GlobalEnv )
    },
   error=function(cond){
   cat("Error: Maybe there weren't clinical data for ", element, " cancer.\n")
})
})

Saving clinical data to RTCGA.clinical package

grep( "clinical", ls(), value = TRUE) %>%
   cat( sep="," ) #can one to id better? as from use_data documentation:
   # ...    Unquoted names of existing objects to save
   devtools::use_data(ACC.clinical,BLCA.clinical,BRCA.clinical,
                      CESC.clinical,CHOL.clinical,COAD.clinical,
                      COADREAD.clinical,DLBC.clinical,ESCA.clinical,
                      FPPP.clinical,GBM.clinical,GBMLGG.clinical,
                      HNSC.clinical,KICH.clinical,KIPAN.clinical,
                      KIRC.clinical,KIRP.clinical,LAML.clinical,
                      LGG.clinical,LIHC.clinical,LUAD.clinical,
                      LUSC.clinical,MESO.clinical,OV.clinical,
                      PAAD.clinical,PCPG.clinical,READ.clinical,
                      SKCM.clinical,STAD.clinical,STES.clinical,
                      TGCT.clinical,THCA.clinical,THYM.clinical,
                      UCEC.clinical,UCS.clinical,UVM.clinical, overwrite = TRUE)