The following article presents RTCGA.data: a family of R packages with data from The Cancer Genome Atlas Project (TCGA) study. TCGA is a comprehensive and coordinated effort to accelerate our understanding of the molecular basis of cancer through the application of genome analysis technologies, including large-scale genome sequencing [1]. We converted selected datasets from this study into few separate packages that are hosted on one GitHub repository. These R packages make selected datasets easier to access and manage. Data sets in RTCGA.data packages are large and cover complex relations between clinical outcomes and genetic background. These packages will be useful for at least three audiences: biostatisticians that work with cancer data; researchers that are working on large scale algorithms, for them RTGCA data will be a perfect blasting site; teachers that are presenting data analysis method on real data problems.

1 Motivation

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 [1].

TCGA data are available through Firehose Broad GDAC portal [1]. One can select cancer type (cohort) and data type (e.g. clinical, RNA expression, methylation, ..) and download a tar.gz file with compressed data.

When working with many cancer types we find this approach burdensome:

For these reasons we prepared selected datasets from TCGA project in an easy to handle and process way and embed them in 4 separate R packages. All packages can be installed from BioConductor by evaluating the following code:

source("https://bioconductor.org/biocLite.R")
biocLite("RTCGA.clinical") 
biocLite("RTCGA.rnaseq") 
biocLite("RTCGA.mutations") 
biocLite("RTCGA.cnv") 

2 Patient’s barcode as a key to merge data

A TCGA barcode is composed of a collection of identifiers. Each specifically identifies a TCGA data element. An illustration on what each part of the patient’s barcode can be found on   https://wiki.nci.nih.gov/display/TCGA/TCGA+barcode.

3 How to work with RTCGA.data family

RTCGA.data family contains 4 packages:

More detailed information about datasets included in RTCGA.data family are shown in Table below.

After installation, one can load any package from RTCGA.data family with commands

library(RTCGA.clinical)
library(RTCGA.rnaseq)
library(RTCGA.mutations)
library(RTCGA.cnv)

and one can check what datasets are available (or aboved Table) with commands

?clinical
?rnaseq
?mutations
?cnv

The data loading proceeds in a regular way. Simply type

data(cohort.package)

where cohort corresponds to a specific Cohort of patients and package corresponds to the one of four packages from RTCGA.data family.

4 Examples of applications

4.1 The Kaplan-Meier estimate of the survival curves with the clinical data

RTCGA.data family is excellent when one researches in a field of survival analysis and genomics. Survival times for patients are included in clinical datasets. The following example plots Kaplan-Meier [5] estimates of the survival functions for patients suffering from LUAD cancer, divided into stages of the cancer.

library(dplyr)
library(RTCGA.clinical)
#library(devtools);biocLite("mi2-warsaw/RTCGA.tools") 
library(RTCGA.tools)
library(survival)
library(survMisc)

LUAD.clinical %>%
   mutate(
      patient.vital_status = ifelse(LUAD.clinical$patient.vital_status %>% as.character() =="dead",1,0),
      barcode = patient.bcr_patient_barcode %>% as.character(),
      times = ifelse( !is.na(patient.days_to_last_followup),
                 patient.days_to_last_followup %>% as.character() %>% as.numeric(),
                 patient.days_to_death %>% as.character() %>% as.numeric() ),
      stage = RTCGA.tools::mergeStages(LUAD.clinical$patient.stage_event.pathologic_stage)
   ) %>%
   rename(
      therapy = patient.drugs.drug.therapy_types.therapy_type
   ) %>%
   filter( !is.na(times) ) -> LUAD.clinical.selected 

LUAD.clinical.selected %>%
   survfit( Surv(times, patient.vital_status) ~ stage, data = .) %>%
   survMisc:::autoplot.survfit( titleSize=12, type="CI" ) %>%
   .[[2]] -> km_plot_luad
km_plot_luad

The Kaplan-Meier estimate of the survival curve for the LUAD cancer.

4.2 The Cox proportional hazards model with the genes’ mutations data

In a simple way one can use previously selected data to merge them with genes’ mutations data and to compute Cox proportional hazards model [9]. Moreover, the goodness of fit can be checked with the plot of Martingale Residuals.

library(RTCGA.mutations)
library(ggthemes)
LUAD.clinical.selected %>%
      left_join( y = LUAD.mutations %>%
                    filter( Hugo_Symbol == "TP53") %>%
                    mutate( barcode = barcode %>% as.character %>% tolower %>% substr(1,12) ) %>%
                    select( barcode, Variant_Classification),
                 by = "barcode") %>%
                    mutate( Variant_Classification = divideTP53(Variant_Classification) ) ->
   LUAD.clinical.mutations.selected

(coxph(Surv(times, patient.vital_status)~ as.factor(stage)+Variant_Classification,
      data = LUAD.clinical.mutations.selected) -> LUAD.coxph)
qplot(predict(LUAD.coxph, type="lp"),residuals(LUAD.coxph))+
   theme_tufte(base_size=20)+
   xlab("Linear combinations")+
   ylab("Martingale residuals")+
   geom_hline(yintercept=0, col ="orange", size = 3)

Martingale residuals vs. linear combination of the independent variables for the LUAD cancer’s Cox proportional hazard model.

4.3 The Principal Components Analysis for the rnaseq data

One can also perform a Principal Components Analysis, after binding rnaseq data for few random cancer types like below. It can be seen that genes’ expressions amongs those cancers vary and samples group in view of cancer type.

rbind(ACC.rnaseq, CHOL.rnaseq, GBM.rnaseq, PCPG.rnaseq, UVM.rnaseq) -> rnaseq_sample
# which columns contain only zeros
rnaseq_sample[,-1] %>% colSums() -> rnaseq_col_sums
which(rnaseq_col_sums == 0) -> columns_with_only0
# pca
rnaseq_sample[, -c(1,columns_with_only0+1)] %>%
   prcomp( scale = TRUE ) -> PCA
# labels for pca
lapply(list(ACC.rnaseq, CHOL.rnaseq, GBM.rnaseq, PCPG.rnaseq, UVM.rnaseq), nrow) -> rnaseq_nrow
mapply(rep, 
       c("ACC.rnaseq", "CHOL.rnaseq", "GBM.rnaseq", "PCPG.rnaseq", "UVM.rnaseq"), 
       rnaseq_nrow) %>%
   unlist -> rnaseq_pca_labels
# biplot
#library(devtools);install_github("vqv/ggbiplot")
library(ggbiplot)
rownames(PCA$rotation) <- 1:nrow(PCA$rotation)
ggbiplot(PCA, obs.scale = 1, var.scale = 1,
  groups = rnaseq_pca_labels, ellipse = TRUE, circle = TRUE, var.axes=FALSE) +
  theme(legend.direction = 'horizontal', legend.position = 'top') -> biplot_rnaseq
biplot_rnaseq

The biplot for 2 main components of the principal component analysis of genes’ expressions data for 5 various cancer types

[1] http://cancergenome.nih.gov/

[2] http://gdac.broadinstitute.org/
   
[3] http://cran.r-project.org/bin/windows/Rtools/
   
[4] https://wiki.nci.nih.gov/display/TCGA/TCGA+barcode

[9] Cox D. R., (1972) \textit{Regression models and life-tables (with discussion)}, Journal of the Royal Statistical Society Series B 34:187-220.      
      
[5]  Kaplan, E. L.; Meier, P. (1958). "Nonparametric estimation from incomplete observations". J. Amer. Statist. Assn. 53 (282): 457-481. JSTOR 2281868.