TCGAbiolinks has provided a few functions to download and prepare data from GDC for analysis. This section starts by explaning the different downloads methods and the SummarizedExperiment object, which is the default data structure used in TCGAbiolinks, followed by some examples.


Downloading and preparing data for analysis

Data download: Methods differences

There are two methods to download GDC data using TCGAbiolinks:

  • client: this method creates a MANIFEST file and download the data using GDC Data Transfer Tool this method is more reliable but it might be slower compared to the api method.
  • api: this methods used the GDC Application Programming Interface (API) to downlaod the data. This will create a MANIFEST file and the data downloaded will be compressed into a tar.gz file. If the size and the number of the files are too big this tar.gz will be too big whicih might have a high probability of download failure. To solve that we created the files.per.chunk argument which will split the files into small chunks, for example, if chunks.per.download is equal to 10 we will download only 10 files inside each tar.gz.
Data prepared: SummarizedExperiment object

A SummarizedExperiment object has three main matrices that can be accessed using the SummarizedExperiment package):

  • Sample matrix information is accessed via colData(data): stores sample information. TCGAbiolinks will add indexed clinical data and subtype information from marker TCGA papers.
  • Assay matrix information is accessed via assay(data): stores molecular data
  • Feature matrix information (gene information) is accessed via rowRanges(data): stores metadata about the features, including their genomic ranges
Summarized Experiment: annotation information

When using the funciton GDCprepare there is an argument called SummarizedExperiment which defines the output type a Summarized Experiment (default option) or a data frame. To create a summarized Experiment object we annotate the data with genomic positions with last patch release version of the genome available. For legacy data (data aligned to hg19) TCGAbiolinks is using GRCh37.p13 and for harmonized data (data aligned to hg38) now it is using GRCh38.p7 (May 2017).

Unfortunately, some of the updates changes/remove gene symbols, change coordinates, etc. Which might introduce some loss of data. For example, if the gene was removed we cannot map it anymore and that information will be lost in the SummarizedExperiment.

If you set SummarizedExperiment to FALSE, you will get the data unmofied just as they are in the files and ad your own annotation.

Also, there are no updated for DNA methylation data. But the last metadata available can be found here: http://zwdzwd.github.io/InfiniumAnnotation

Related discussions: issue 91, issue 50

Search and download data from legacy database using GDC api method

In this example we will download gene expression data from legacy database (data aligned against genome of reference hg19) using GDC api method and we will show object data and metadata.

query <- GDCquery(project = "TCGA-GBM",
                           data.category = "Gene expression",
                           data.type = "Gene expression quantification",
                           platform = "Illumina HiSeq", 
                           file.type  = "normalized_results",
                           experimental.strategy = "RNA-Seq",
                           barcode = c("TCGA-14-0736-02A-01R-2005-01", "TCGA-06-0211-02A-02R-2005-01"),
                           legacy = TRUE)
GDCdownload(query, method = "api", files.per.chunk = 10)
data <- GDCprepare(query)
# Gene expression aligned against hg19.
datatable(as.data.frame(colData(data)), 
              options = list(scrollX = TRUE, keys = TRUE, pageLength = 5), 
              rownames = FALSE)
# Only first 100 to make render faster
datatable(assay(data)[1:100,], 
              options = list(scrollX = TRUE, keys = TRUE, pageLength = 5), 
              rownames = TRUE)
rowRanges(data)
## GRanges object with 21022 ranges and 3 metadata columns:
##                seqnames                 ranges strand |      gene_id
##                   <Rle>              <IRanges>  <Rle> |  <character>
##           A1BG    chr19   [58856544, 58864865]      - |         A1BG
##            A2M    chr12   [ 9220260,  9268825]      - |          A2M
##           NAT1     chr8   [18027986, 18081198]      + |         NAT1
##           NAT2     chr8   [18248755, 18258728]      + |         NAT2
##   RP11-986E7.7    chr14   [95058395, 95090983]      + | RP11-986E7.7
##            ...      ...                    ...    ... .          ...
##            FTX     chrX [ 73183790,  73513409]      - |          FTX
##   TMED7-TICAM2     chr5 [114914339, 114961858]      - | TMED7-TICAM2
##          TMED7     chr5 [114949205, 114968689]      - |        TMED7
##         TICAM2     chr5 [114914339, 114961876]      - |       TICAM2
##    SLC25A5-AS1     chrX [118599997, 118603061]      - |  SLC25A5-AS1
##                entrezgene ensembl_gene_id
##                 <numeric>     <character>
##           A1BG          1 ENSG00000121410
##            A2M          2 ENSG00000175899
##           NAT1          9 ENSG00000171428
##           NAT2         10 ENSG00000156006
##   RP11-986E7.7         12 ENSG00000273259
##            ...        ...             ...
##            FTX  100302692 ENSG00000230590
##   TMED7-TICAM2  100302736 ENSG00000251201
##          TMED7  100302736 ENSG00000134970
##         TICAM2  100302736 ENSG00000243414
##    SLC25A5-AS1  100303728 ENSG00000224281
##   -------
##   seqinfo: 24 sequences from an unspecified genome; no seqlengths

Search and download data for two samples from database

In this example we will download gene expression quantification from harmonized database (data aligned against genome of reference hg38). Also, it shows the object data and metadata.

# Gene expression aligned against hg38
query <- GDCquery(project = "TCGA-GBM",
                  data.category = "Transcriptome Profiling",
                  data.type = "Gene Expression Quantification", 
                  workflow.type = "HTSeq - FPKM-UQ",
                  barcode = c("TCGA-14-0736-02A-01R-2005-01", "TCGA-06-0211-02A-02R-2005-01"))
GDCdownload(query)
data <- GDCprepare(query)
datatable(as.data.frame(colData(data)), 
              options = list(scrollX = TRUE, keys = TRUE, pageLength = 5), 
              rownames = FALSE)
datatable(assay(data)[1:100,], 
              options = list(scrollX = TRUE, keys = TRUE, pageLength = 5), 
              rownames = TRUE)
rowRanges(data)
## GRanges object with 56963 ranges and 3 metadata columns:
##                   seqnames                 ranges strand | ensembl_gene_id
##                      <Rle>              <IRanges>  <Rle> |     <character>
##   ENSG00000000003     chrX [100627109, 100639991]      - | ENSG00000000003
##   ENSG00000000005     chrX [100584802, 100599885]      + | ENSG00000000005
##   ENSG00000000419    chr20 [ 50934867,  50958555]      - | ENSG00000000419
##   ENSG00000000457     chr1 [169849631, 169894267]      - | ENSG00000000457
##   ENSG00000000460     chr1 [169662007, 169854080]      + | ENSG00000000460
##               ...      ...                    ...    ... .             ...
##   ENSG00000281904     chr2   [90365737, 90367699]      + | ENSG00000281904
##   ENSG00000281909    chr15   [22480439, 22484840]      - | ENSG00000281909
##   ENSG00000281910    chr16   [58559796, 58559931]      - | ENSG00000281910
##   ENSG00000281912     chr1   [45303910, 45305619]      + | ENSG00000281912
##   ENSG00000281920     chr2   [65623272, 65628424]      + | ENSG00000281920
##                   external_gene_name original_ensembl_gene_id
##                          <character>              <character>
##   ENSG00000000003             TSPAN6       ENSG00000000003.13
##   ENSG00000000005               TNMD        ENSG00000000005.5
##   ENSG00000000419               DPM1       ENSG00000000419.11
##   ENSG00000000457              SCYL3       ENSG00000000457.12
##   ENSG00000000460           C1orf112       ENSG00000000460.15
##               ...                ...                      ...
##   ENSG00000281904         AC233263.6        ENSG00000281904.1
##   ENSG00000281909         AC100757.4        ENSG00000281909.1
##   ENSG00000281910           SNORA50A        ENSG00000281910.1
##   ENSG00000281912          LINC01144        ENSG00000281912.1
##   ENSG00000281920         AC007389.5        ENSG00000281920.1
##   -------
##   seqinfo: 24 sequences from an unspecified genome; no seqlengths