TCGAbiolinks has provided a few functions to search, download and parse clinical data. This section starts by explaining the different sources for clinical information in GDC, followed by the necessary function to access these sources.


Useful information

Different sources

In GDC database the clinical data can be retrieved from different sources:

  • indexed clinical: a refined clinical data that is created using the XML files.
  • XML files: original source of the data
  • BCR Biotab: tsv files parsed from XML files

There are two main differences between the indexed clinical and XML files:

  • XML has more information: radiation, drugs information, follow-ups, biospecimen, etc. So the indexed one is only a subset of the XML files
  • The indexed data contains the updated data with the follow up information. For example: if the patient is alive in the first time clinical data was collect and the in the next follow-up he is dead, the indexed data will show dead. The XML will have two fields, one for the first time saying he is alive (in the clinical part) and the follow-up saying he is dead.

Other useful clinical information available are:

  • Tissue slide image
  • Pathology report - Slide image

BCR Biotab

Clinical

In this example we will fetch clinical data from BCR Biotab files.

In this example we will fetch all BRCA BCR Biotab files, and look for the ER status.

## [1] "clinical_follow_up_v2.1_brca"     "clinical_drug_brca"              
## [3] "clinical_nte_brca"                "clinical_follow_up_v4.0_brca"    
## [5] "clinical_patient_brca"            "clinical_follow_up_v4.0_nte_brca"
## [7] "clinical_follow_up_v1.5_brca"     "clinical_omf_v4.0_brca"          
## [9] "clinical_radiation_brca"

Biospecimen

##  [1] "biospecimen_aliquot_brca"           "biospecimen_analyte_brca"          
##  [3] "biospecimen_diagnostic_slides_brca" "biospecimen_shipment_portion_brca" 
##  [5] "biospecimen_sample_brca"            "ssf_normal_controls_brca"          
##  [7] "ssf_tumor_samples_brca"             "biospecimen_portion_brca"          
##  [9] "biospecimen_slide_brca"             "biospecimen_protocol_brca"

Clinical indexed data

In this example we will fetch clinical indexed data (same as showed in the data portal).

XML clinical data

The process to get data directly from the XML are: 1. Use GDCquery and GDCDownload functions to search/download either biospecimen or clinical XML files 2. Use GDCprepare_clinic function to parse the XML files.

The relation between one patient and other clinical information are 1:n, one patient could have several radiation treatments. For that reason, we only give the option to parse individual tables (only drug information, only radiation information,…) The selection of the table is done by the argument clinical.info.

clinical.info options to parse information for each data category
data.category clinical.info
Clinical drug
Clinical admin
Clinical follow_up
Clinical radiation
Clinical patient
Clinical stage_event
Clinical new_tumor_event
Biospecimen sample
Biospecimen bio_patient
Biospecimen analyte
Biospecimen aliquot
Biospecimen protocol
Biospecimen portion
Biospecimen slide
Other msi

Below are several examples fetching clinical data directly from the clinical XML files.

Microsatellite data

MSI-Mono-Dinucleotide Assay is performed to test a panel of four mononucleotide repeat loci (polyadenine tracts BAT25, BAT26, BAT40, and transforming growth factor receptor type II) and three dinucleotide repeat loci (CA repeats in D2S123, D5S346, and D17S250). Two additional pentanucleotide loci (Penta D and Penta E) are included in this assay to evaluate sample identity. Multiplex fluorescent-labeled PCR and capillary electrophoresis were used to identify MSI if a variation in the number of microsatellite repeats was detected between tumor and matched non-neoplastic tissue or mononuclear blood cells. Equivocal or failed markers were re-evaluated by singleplex PCR.

classifications: microsatellite-stable (MSS), low level MSI (MSI-L) if less than 40% of markers were altered and high level MSI (MSI-H) if greater than 40% of markers were altered.

Reference: TCGA wiki

Level 3 data is included in BCR clinical-based submissions and can be downloaded as follows:

Tissue slide image (SVS format)

Diagnostic Slide (SVS format)

Legacy archive files

The clinical data types available in legacy database are:

  • Biospecimen data (Biotab format)
  • Tissue slide image (SVS format)
  • Clinical Supplement (XML format)
  • Pathology report (PDF)
  • Clinical data (Biotab format)

Pathology report (PDF)

Tissue slide image (SVS format)

Clinical Supplement (XML format)

Clinical data (Biotab format)

## [1] "clinical_radiation_coad"          "clinical_nte_coad"               
## [3] "clinical_patient_coad"            "clinical_drug_coad"              
## [5] "clinical_follow_up_v1.0_nte_coad" "clinical_omf_v4.0_coad"          
## [7] "clinical_follow_up_v1.0_coad"

Filter functions

Also, some functions to work with clinical data are provided.

For example the function TCGAquery_SampleTypes will filter barcodes based on a type the argument typesample.

Argument Description
barcode is a list of samples as TCGA barcodes
typesample a character vector indicating tissue type to query. Example:
TP PRIMARY TUMOR
TR RECURRENT TUMOR
TB Primary Blood Derived Cancer-Peripheral Blood
TRBM Recurrent Blood Derived Cancer-Bone Marrow
TAP Additional-New Primary
TM Metastatic
TAM Additional Metastatic
THOC Human Tumor Original Cells
TBM Primary Blood Derived Cancer-Bone Marrow
NB Blood Derived Normal
NT Solid Tissue Normal
NBC Buccal Cell Normal
NEBV EBV Immortalized Normal
NBM Bone Marrow Normal

The function TCGAquery_MatchedCoupledSampleTypes will filter the samples that have all the typesample provided as argument. For example, if TP and TR are set as typesample, the function will return the barcodes of a patient if it has both types. So, if it has a TP, but not a TR, no barcode will be returned. If it has a TP and a TR both barcodes are returned.

An example of the function is below:

Other useful code

To get all the information for TGCA samples you can use the script below:

# This code will get all clinical indexed data from TCGA
library(data.table)
library(dplyr)
library(regexPipes)
clinical <- TCGAbiolinks:::getGDCprojects()$project_id %>% 
  regexPipes::grep("TCGA",value=T) %>% 
  sort %>% 
  plyr::alply(1,GDCquery_clinic, .progress = "text") %>% 
  rbindlist
readr::write_csv(clinical,path = paste0("all_clin_indexed.csv"))

# This code will get all clinical XML data from TCGA
getclinical <- function(proj){
  message(proj)
  while(1){
    result = tryCatch({
      query <- GDCquery(project = proj, data.category = "Clinical",file.type = "xml")
      GDCdownload(query)
      clinical <- GDCprepare_clinic(query, clinical.info = "patient")
      for(i in c("admin","radiation","follow_up","drug","new_tumor_event")){
        message(i)
        aux <- GDCprepare_clinic(query, clinical.info = i)
        if(is.null(aux) || nrow(aux) == 0) next
        # add suffix manually if it already exists
        replicated <- which(grep("bcr_patient_barcode",colnames(aux), value = T,invert = T) %in% colnames(clinical))
        colnames(aux)[replicated] <- paste0(colnames(aux)[replicated],".",i)
        if(!is.null(aux)) clinical <- merge(clinical,aux,by = "bcr_patient_barcode", all = TRUE)
      }
      readr::write_csv(clinical,path = paste0(proj,"_clinical_from_XML.csv")) # Save the clinical data into a csv file
      return(clinical)
    }, error = function(e) {
      message(paste0("Error clinical: ", proj))
    })
  }
}
clinical <- TCGAbiolinks:::getGDCprojects()$project_id %>% 
  regexPipes::grep("TCGA",value=T) %>% sort %>% 
  plyr::alply(1,getclinical, .progress = "text") %>% 
  rbindlist(fill = TRUE) %>% setDF %>% subset(!duplicated(clinical))

readr::write_csv(clinical,path = "all_clin_XML.csv")
# result: https://drive.google.com/open?id=0B0-8N2fjttG-WWxSVE5MSGpva1U
# Obs: this table has multiple lines for each patient, as the patient might have several followups, drug treatments,
# new tumor events etc...