Contents

Installation

library(cBioPortalData)
library(AnVIL)

Introduction

The cBioPortal for Cancer Genomics website is a great resource for interactive exploration of study datasets. However, it does not easily allow the analyst to obtain and further analyze the data.

We’ve developed the cBioPortalData package to fill this need to programmatically access the data resources available on the cBioPortal.

The cBioPortalData package provides an R interface for accessing the cBioPortal study data within the Bioconductor ecosystem.

It downloads study data from the cBioPortal API (the full API specification can be found here https://cbioportal.org/api) and uses Bioconductor infrastructure to cache and represent the data.

We use the MultiAssayExperiment (@Ramos2017-er) package to integrate, represent, and coordinate multiple experiments for the studies availble in the cBioPortal. This package in conjunction with curatedTCGAData give access to a large trove of publicly available bioinformatic data. Please see our publication here (@Ramos2020-ya).

We demonstrate common use cases of cBioPortalData and curatedTCGAData during Bioconductor conference workshops.

Overview

Data Structures

Data are provided as a single MultiAssayExperiment per study. The MultiAssayExperiment representation usually contains SummarizedExperiment objects for expression data and RaggedExperiment objects for mutation and CNV-type data. RaggedExperiment is a data class for representing ‘ragged’ genomic location data, meaning that the measurements per sample vary.

For more information, please see the RaggedExperiment and SummarizedExperiment vignettes.

Identifying available studies

As we work through the data, there are some datasest that cannot be represented as MultiAssayExperiment objects. This can be due to a number of reasons such as the way the data is handled, presence of mis-matched identifiers, invalid data types, etc. To see what datasets are currently not building, we can look refer to getStudies() with the buildReport = TRUE argument.

cbio <- cBioPortal()
studies <- getStudies(cbio, buildReport = TRUE)
head(studies)
## # A tibble: 6 × 15
##   name           description publicStudy pmid  citation groups status importDate
##   <chr>          <chr>       <lgl>       <chr> <chr>    <chr>   <int> <chr>     
## 1 Prostate Aden… "Genome-wi… TRUE        2502… Hierony… "PUBL…      0 2021-04-2…
## 2 China Pan-can… "Landscape… TRUE        <NA>  <NA>     ""          0 2021-09-2…
## 3 Skin Cutaneou… "Skin Cuta… TRUE        2962… TCGA, C… "PUBL…      0 2021-10-2…
## 4 Disparities i… "Targeted … TRUE        <NA>  <NA>     ""          0 2021-10-2…
## 5 Adrenocortica… "TCGA Adre… TRUE        <NA>  <NA>     "PUBL…      0 2021-10-2…
## 6 Adenoid Cysti… "Whole exo… TRUE        2377… Stephen… "ACYC…      0 2021-10-2…
## # … with 7 more variables: allSampleCount <int>, readPermission <lgl>,
## #   studyId <chr>, cancerTypeId <chr>, referenceGenome <chr>, api_build <lgl>,
## #   pack_build <lgl>

The last two columns will show the availability of each studyId for either download method (pack_build for cBioDataPack and api_build for cBioPortalData).

Choosing download method

There are two main user-facing functions for downloading data from the cBioPortal API.

  • cBioDataPack makes use of the tarball distribution of study data. This is useful when the user wants to download and analyze the entirety of the data as available from the cBioPortal.org website.

  • cBioPortalData allows a more flexibile approach to obtaining study data based on the available parameters such as molecular profile identifiers. This option is useful for users who have a set of gene symbols or identifiers and would like to get a smaller subset of the data that correspond to a particular molecular profile.

Two main functions

cBioDataPack: Obtain Study Data as Zipped Tarballs

This function will access the packaged data from and return an integrative MultiAssayExperiment representation.

## Use ask=FALSE for non-interactive use
laml <- cBioDataPack("laml_tcga", ask = FALSE)
laml
## A MultiAssayExperiment object of 11 listed
##  experiments with user-defined names and respective classes.
##  Containing an ExperimentList class object of length 11:
##  [1] CNA: SummarizedExperiment with 24776 rows and 191 columns
##  [2] RNA_Seq_expression_median: SummarizedExperiment with 19720 rows and 179 columns
##  [3] RNA_Seq_mRNA_median_Zscores: SummarizedExperiment with 19719 rows and 179 columns
##  [4] RNA_Seq_mRNA_median_all_sample_Zscores: SummarizedExperiment with 19720 rows and 179 columns
##  [5] RNA_Seq_v2_mRNA_median_Zscores: SummarizedExperiment with 20440 rows and 173 columns
##  [6] cna_hg19.seg: RaggedExperiment with 13571 rows and 191 columns
##  [7] linear_CNA: SummarizedExperiment with 24776 rows and 191 columns
##  [8] methylation_hm27: SummarizedExperiment with 10919 rows and 194 columns
##  [9] methylation_hm450: SummarizedExperiment with 10919 rows and 194 columns
##  [10] mutations_extended: RaggedExperiment with 2584 rows and 197 columns
##  [11] mutations_mskcc: RaggedExperiment with 2584 rows and 197 columns
## Functionality:
##  experiments() - obtain the ExperimentList instance
##  colData() - the primary/phenotype DataFrame
##  sampleMap() - the sample coordination DataFrame
##  `$`, `[`, `[[` - extract colData columns, subset, or experiment
##  *Format() - convert into a long or wide DataFrame
##  assays() - convert ExperimentList to a SimpleList of matrices
##  exportClass() - save data to flat files

cBioPortalData: Obtain data from the cBioPortal API

This function provides a more flexible and granular way to request a MultiAssayExperiment object from a study ID, molecular profile, gene panel, sample list.

acc <- cBioPortalData(api = cbio, by = "hugoGeneSymbol", studyId = "acc_tcga",
    genePanelId = "IMPACT341",
    molecularProfileIds = c("acc_tcga_rppa", "acc_tcga_linear_CNA")
)
## harmonizing input:
##   removing 1 colData rownames not in sampleMap 'primary'
acc
## A MultiAssayExperiment object of 2 listed
##  experiments with user-defined names and respective classes.
##  Containing an ExperimentList class object of length 2:
##  [1] acc_tcga_rppa: SummarizedExperiment with 57 rows and 46 columns
##  [2] acc_tcga_linear_CNA: SummarizedExperiment with 339 rows and 90 columns
## Functionality:
##  experiments() - obtain the ExperimentList instance
##  colData() - the primary/phenotype DataFrame
##  sampleMap() - the sample coordination DataFrame
##  `$`, `[`, `[[` - extract colData columns, subset, or experiment
##  *Format() - convert into a long or wide DataFrame
##  assays() - convert ExperimentList to a SimpleList of matrices
##  exportClass() - save data to flat files

Note. To avoid overloading the API service, the API was designed to only query a part of the study data. Therefore, the user is required to enter either a set of genes of interest or a gene panel identifier.

Clearing the cache

cBioDataPack

In cases where a download is interrupted, the user may experience a corrupt cache. The user can clear the cache for a particular study by using the removeCache function. Note that this function only works for data downloaded through the cBioDataPack function.

removeCache("laml_tcga")

cBioPortalData

For users who wish to clear the entire cBioPortalData cache, it is recommended that they use:

unlink("~/.cache/cBioPortalData/")

Example Analysis: Kaplan-Meier Plot

We can use information in the colData to draw a K-M plot with a few variables from the colData slot of the MultiAssayExperiment. First, we load the necessary packages:

library(survival)
library(survminer)

We can check the data to lookout for any issues.

table(colData(laml)$OS_STATUS)
## 
##   0:LIVING 1:DECEASED 
##         67        133
class(colData(laml)$OS_MONTHS)
## [1] "character"

Now, we clean the data a bit to ensure that our variables are of the right type for the subsequent survival model fit.

collaml <- colData(laml)
collaml[collaml$OS_MONTHS == "[Not Available]", "OS_MONTHS"] <- NA
collaml$OS_MONTHS <- as.numeric(collaml$OS_MONTHS)
colData(laml) <- collaml

We specify a simple survival model using SEX as a covariate and we draw the K-M plot.

fit <- survfit(
    Surv(OS_MONTHS, as.numeric(substr(OS_STATUS, 1, 1))) ~ SEX,
    data = colData(laml)
)
ggsurvplot(fit, data = colData(laml), risk.table = TRUE)

Data update requests

If you are interested in a particular study dataset that is not currently building, please open an issue at our GitHub repository location and we will do our best to resolve the issues with either the data or the code.

We appreciate your feedback!

sessionInfo

sessionInfo()
## R version 4.1.2 (2021-11-01)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Ubuntu 20.04.3 LTS
## 
## Matrix products: default
## BLAS:   /home/biocbuild/bbs-3.14-bioc/R/lib/libRblas.so
## LAPACK: /home/biocbuild/bbs-3.14-bioc/R/lib/libRlapack.so
## 
## locale:
##  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
##  [3] LC_TIME=en_GB              LC_COLLATE=C              
##  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
##  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
##  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
## [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
## 
## attached base packages:
## [1] stats4    stats     graphics  grDevices utils     datasets  methods  
## [8] base     
## 
## other attached packages:
##  [1] survminer_0.4.9             ggpubr_0.4.0               
##  [3] ggplot2_3.3.5               survival_3.2-13            
##  [5] cBioPortalData_2.6.1        MultiAssayExperiment_1.20.0
##  [7] SummarizedExperiment_1.24.0 Biobase_2.54.0             
##  [9] GenomicRanges_1.46.1        GenomeInfoDb_1.30.1        
## [11] IRanges_2.28.0              S4Vectors_0.32.3           
## [13] BiocGenerics_0.40.0         MatrixGenerics_1.6.0       
## [15] matrixStats_0.61.0          AnVIL_1.6.2                
## [17] dplyr_1.0.7                 BiocStyle_2.22.0           
## 
## loaded via a namespace (and not attached):
##   [1] backports_1.4.1           BiocFileCache_2.2.1      
##   [3] RCircos_1.2.2             splines_4.1.2            
##   [5] BiocParallel_1.28.3       TCGAutils_1.14.0         
##   [7] digest_0.6.29             htmltools_0.5.2          
##   [9] magick_2.7.3              fansi_1.0.2              
##  [11] magrittr_2.0.2            memoise_2.0.1            
##  [13] tzdb_0.2.0                limma_3.50.0             
##  [15] Biostrings_2.62.0         readr_2.1.1              
##  [17] vroom_1.5.7               prettyunits_1.1.1        
##  [19] colorspace_2.0-2          blob_1.2.2               
##  [21] rvest_1.0.2               rappdirs_0.3.3           
##  [23] xfun_0.29                 crayon_1.4.2             
##  [25] RCurl_1.98-1.5            jsonlite_1.7.3           
##  [27] RaggedExperiment_1.18.0   zoo_1.8-9                
##  [29] glue_1.6.1                GenomicDataCommons_1.18.0
##  [31] gtable_0.3.0              zlibbioc_1.40.0          
##  [33] XVector_0.34.0            DelayedArray_0.20.0      
##  [35] car_3.0-12                abind_1.4-5              
##  [37] scales_1.1.1              futile.options_1.0.1     
##  [39] DBI_1.1.2                 rstatix_0.7.0            
##  [41] Rcpp_1.0.8                xtable_1.8-4             
##  [43] progress_1.2.2            gridtext_0.1.4           
##  [45] bit_4.0.4                 km.ci_0.5-2              
##  [47] httr_1.4.2                ellipsis_0.3.2           
##  [49] pkgconfig_2.0.3           XML_3.99-0.8             
##  [51] rapiclient_0.1.3          farver_2.1.0             
##  [53] sass_0.4.0                dbplyr_2.1.1             
##  [55] utf8_1.2.2                RJSONIO_1.3-1.6          
##  [57] tidyselect_1.1.1          labeling_0.4.2           
##  [59] rlang_1.0.0               AnnotationDbi_1.56.2     
##  [61] munsell_0.5.0             tools_4.1.2              
##  [63] cachem_1.0.6              cli_3.1.1                
##  [65] generics_0.1.1            RSQLite_2.2.9            
##  [67] broom_0.7.12              evaluate_0.14            
##  [69] stringr_1.4.0             fastmap_1.1.0            
##  [71] yaml_2.2.2                knitr_1.37               
##  [73] bit64_4.0.5               survMisc_0.5.5           
##  [75] purrr_0.3.4               KEGGREST_1.34.0          
##  [77] formatR_1.11              xml2_1.3.3               
##  [79] biomaRt_2.50.2            compiler_4.1.2           
##  [81] filelock_1.0.2            curl_4.3.2               
##  [83] png_0.1-7                 ggsignif_0.6.3           
##  [85] tibble_3.1.6              bslib_0.3.1              
##  [87] stringi_1.7.6             highr_0.9                
##  [89] futile.logger_1.4.3       GenomicFeatures_1.46.4   
##  [91] lattice_0.20-45           Matrix_1.4-0             
##  [93] markdown_1.1              KMsurv_0.1-5             
##  [95] RTCGAToolbox_2.24.0       vctrs_0.3.8              
##  [97] pillar_1.6.5              lifecycle_1.0.1          
##  [99] BiocManager_1.30.16       jquerylib_0.1.4          
## [101] data.table_1.14.2         bitops_1.0-7             
## [103] rtracklayer_1.54.0        R6_2.5.1                 
## [105] BiocIO_1.4.0              bookdown_0.24            
## [107] gridExtra_2.3             codetools_0.2-18         
## [109] lambda.r_1.2.4            assertthat_0.2.1         
## [111] rjson_0.2.21              withr_2.4.3              
## [113] GenomicAlignments_1.30.0  Rsamtools_2.10.0         
## [115] GenomeInfoDbData_1.2.7    parallel_4.1.2           
## [117] hms_1.1.1                 ggtext_0.1.1             
## [119] grid_4.1.2                tidyr_1.1.4              
## [121] rmarkdown_2.11            carData_3.0-5            
## [123] restfulr_0.0.13

References