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 demonstrate common use cases of cBioPortalData and curatedTCGAData during Bioconductor conference workshops.

We use the MultiAssayExperiment (Ramos et al. (2017)) package to integrate, represent, and coordinate multiple experiments for the studies available in the cBioPortal. This package in conjunction with curatedTCGAData give access to a large trove of publicly available bioinformatic data. Please see our JCO Clinical Cancer Informatics publication here (Ramos et al. (2020)).

Citations

Our free and open source project depends on citations for funding. When using cBioPortalData, please cite the following publications:

citation("MultiAssayExperiment")
citation("cBioPortalData")

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 Adenoid Cysti… Whole exom… TRUE        2609… Martelo… ACYC;…      0 2023-12-0…
## 2 Adenoid Cysti… Whole-exom… TRUE        2368… Ho et a… ACYC;…      0 2023-12-0…
## 3 Adenoid Cysti… Targeted S… TRUE        2441… Ross et… ACYC;…      0 2023-12-0…
## 4 Adenoid Cysti… Whole-geno… TRUE        2686… Rettig … ACYC;…      0 2023-12-0…
## 5 Adenoid Cysti… WGS of 21 … TRUE        2663… Mitani … ACYC;…      0 2023-12-0…
## 6 Adenoid Cysti… Whole-geno… TRUE        2682… Drier e… ACYC        0 2023-12-0…
## # ℹ 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 12 listed
##  experiments with user-defined names and respective classes.
##  Containing an ExperimentList class object of length 12:
##  [1] cna_hg19.seg: RaggedExperiment with 13571 rows and 191 columns
##  [2] cna: SummarizedExperiment with 24776 rows and 191 columns
##  [3] linear_cna: SummarizedExperiment with 24776 rows and 191 columns
##  [4] methylation_hm27: SummarizedExperiment with 10968 rows and 194 columns
##  [5] methylation_hm450: SummarizedExperiment with 10968 rows and 194 columns
##  [6] mrna_seq_rpkm_zscores_ref_all_samples: SummarizedExperiment with 19720 rows and 179 columns
##  [7] mrna_seq_rpkm_zscores_ref_diploid_samples: SummarizedExperiment with 19719 rows and 179 columns
##  [8] mrna_seq_rpkm: SummarizedExperiment with 19720 rows and 179 columns
##  [9] mrna_seq_v2_rsem_zscores_ref_all_samples: SummarizedExperiment with 20531 rows and 173 columns
##  [10] mrna_seq_v2_rsem_zscores_ref_diploid_samples: SummarizedExperiment with 20440 rows and 173 columns
##  [11] mrna_seq_v2_rsem: SummarizedExperiment with 20531 rows and 173 columns
##  [12] mutations: 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_linear_CNA: SummarizedExperiment with 339 rows and 90 columns
##  [2] acc_tcga_rppa: SummarizedExperiment with 57 rows and 46 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.

Considerations

Note that cBioPortalData and cBioDataPack obtain data diligently curated by the cBio Portal data team. The original data and curation lies in the https://github.com/cBioPortal/cBioPortal GitHub repository. However, despite the curation efforts there may be some inconsistencies in identifiers in the data. This causes our software to not work as intended though we have made efforts to represent all the data from both API and tarball formats.

metadata

You may notice that the metadata() may have some additional data that was not able to be integrated in the MultiAssayExperiment.

metadata(acc)
## [[1]]
## # A tibble: 30,510 × 6
##    uniqueSampleKey    uniquePatientKey entrezGeneId molecularProfileId patientId
##    <chr>              <chr>                   <int> <chr>              <chr>    
##  1 VENHQS1PUi1BNUoxL… VENHQS1PUi1BNUo…           25 acc_tcga_linear_C… TCGA-OR-…
##  2 VENHQS1PUi1BNUoxL… VENHQS1PUi1BNUo…          142 acc_tcga_linear_C… TCGA-OR-…
##  3 VENHQS1PUi1BNUoxL… VENHQS1PUi1BNUo…          207 acc_tcga_linear_C… TCGA-OR-…
##  4 VENHQS1PUi1BNUoxL… VENHQS1PUi1BNUo…          208 acc_tcga_linear_C… TCGA-OR-…
##  5 VENHQS1PUi1BNUoxL… VENHQS1PUi1BNUo…          238 acc_tcga_linear_C… TCGA-OR-…
##  6 VENHQS1PUi1BNUoxL… VENHQS1PUi1BNUo…          242 acc_tcga_linear_C… TCGA-OR-…
##  7 VENHQS1PUi1BNUoxL… VENHQS1PUi1BNUo…          324 acc_tcga_linear_C… TCGA-OR-…
##  8 VENHQS1PUi1BNUoxL… VENHQS1PUi1BNUo…          331 acc_tcga_linear_C… TCGA-OR-…
##  9 VENHQS1PUi1BNUoxL… VENHQS1PUi1BNUo…          367 acc_tcga_linear_C… TCGA-OR-…
## 10 VENHQS1PUi1BNUoxL… VENHQS1PUi1BNUo…          369 acc_tcga_linear_C… TCGA-OR-…
## # ℹ 30,500 more rows
## # ℹ 1 more variable: studyId <chr>
## 
## [[2]]
## # A tibble: 2,622 × 6
##    uniqueSampleKey    uniquePatientKey entrezGeneId molecularProfileId patientId
##    <chr>              <chr>                   <int> <chr>              <chr>    
##  1 VENHQS1PUi1BNUoyL… VENHQS1PUi1BNUo…          207 acc_tcga_rppa      TCGA-OR-…
##  2 VENHQS1PUi1BNUoyL… VENHQS1PUi1BNUo…          208 acc_tcga_rppa      TCGA-OR-…
##  3 VENHQS1PUi1BNUoyL… VENHQS1PUi1BNUo…          367 acc_tcga_rppa      TCGA-OR-…
##  4 VENHQS1PUi1BNUoyL… VENHQS1PUi1BNUo…          472 acc_tcga_rppa      TCGA-OR-…
##  5 VENHQS1PUi1BNUoyL… VENHQS1PUi1BNUo…          595 acc_tcga_rppa      TCGA-OR-…
##  6 VENHQS1PUi1BNUoyL… VENHQS1PUi1BNUo…          596 acc_tcga_rppa      TCGA-OR-…
##  7 VENHQS1PUi1BNUoyL… VENHQS1PUi1BNUo…          598 acc_tcga_rppa      TCGA-OR-…
##  8 VENHQS1PUi1BNUoyL… VENHQS1PUi1BNUo…          673 acc_tcga_rppa      TCGA-OR-…
##  9 VENHQS1PUi1BNUoyL… VENHQS1PUi1BNUo…          675 acc_tcga_rppa      TCGA-OR-…
## 10 VENHQS1PUi1BNUoyL… VENHQS1PUi1BNUo…          898 acc_tcga_rppa      TCGA-OR-…
## # ℹ 2,612 more rows
## # ℹ 1 more variable: studyId <chr>

Build prompts

You will also get a message for studyIds whose data has not been fully integrated into a MultiAssayExperiment.

## Our testing shows that '%s' is not currently building.
##    Use 'downloadStudy()' to manually obtain the data.
##    Proceed anyway? [y/n]: y

Manual downloads

For this reason, we have also provided the downloadStudy, untarStudy, and loadStudy functions to allow researchers to simply download the data and potentially, manually curate it. Generally, we advise researchers to report inconsistencies in the data in the cBioPortal data repository.

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:

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 and we will do our best to resolve the issues with the code base. Data issues can be opened at the cBioPortal data repository.

We appreciate your feedback!

sessionInfo

Click to see session info
## R version 4.3.2 (2023-10-31)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Ubuntu 22.04.3 LTS
## 
## Matrix products: default
## BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 
## LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so;  LAPACK version 3.10.0
## 
## locale:
##  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
##  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
##  [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       
## 
## time zone: Etc/UTC
## tzcode source: system (glibc)
## 
## attached base packages:
## [1] stats4    stats     graphics  grDevices utils     datasets  methods  
## [8] base     
## 
## other attached packages:
##  [1] survminer_0.4.9             ggpubr_0.6.0               
##  [3] ggplot2_3.4.4               survival_3.5-7             
##  [5] cBioPortalData_2.14.2       MultiAssayExperiment_1.28.0
##  [7] SummarizedExperiment_1.32.0 Biobase_2.62.0             
##  [9] GenomicRanges_1.54.1        GenomeInfoDb_1.38.5        
## [11] IRanges_2.36.0              S4Vectors_0.40.2           
## [13] BiocGenerics_0.48.1         MatrixGenerics_1.14.0      
## [15] matrixStats_1.2.0           AnVIL_1.14.1               
## [17] dplyr_1.1.4                 BiocStyle_2.30.0           
## 
## loaded via a namespace (and not attached):
##   [1] jsonlite_1.8.8            magrittr_2.0.3           
##   [3] GenomicFeatures_1.54.3    farver_2.1.1             
##   [5] rmarkdown_2.25            fs_1.6.3                 
##   [7] BiocIO_1.12.0             zlibbioc_1.48.0          
##   [9] ragg_1.2.7                vctrs_0.6.5              
##  [11] memoise_2.0.1             Rsamtools_2.18.0         
##  [13] RCurl_1.98-1.14           rstatix_0.7.2            
##  [15] BiocBaseUtils_1.4.0       htmltools_0.5.7          
##  [17] S4Arrays_1.2.0            progress_1.2.3           
##  [19] lambda.r_1.2.4            curl_5.2.0               
##  [21] broom_1.0.5               SparseArray_1.2.3        
##  [23] sass_0.4.8                bslib_0.6.1              
##  [25] htmlwidgets_1.6.4         desc_1.4.3               
##  [27] zoo_1.8-12                futile.options_1.0.1     
##  [29] cachem_1.0.8              commonmark_1.9.1         
##  [31] GenomicAlignments_1.38.2  mime_0.12                
##  [33] lifecycle_1.0.4           pkgconfig_2.0.3          
##  [35] Matrix_1.6-5              R6_2.5.1                 
##  [37] fastmap_1.1.1             GenomeInfoDbData_1.2.11  
##  [39] shiny_1.8.0               digest_0.6.34            
##  [41] colorspace_2.1-0          RaggedExperiment_1.26.0  
##  [43] AnnotationDbi_1.64.1      textshaping_0.3.7        
##  [45] RSQLite_2.3.5             labeling_0.4.3           
##  [47] filelock_1.0.3            RTCGAToolbox_2.32.1      
##  [49] km.ci_0.5-6               fansi_1.0.6              
##  [51] RJSONIO_1.3-1.9           httr_1.4.7               
##  [53] abind_1.4-5               compiler_4.3.2           
##  [55] bit64_4.0.5               withr_3.0.0              
##  [57] backports_1.4.1           BiocParallel_1.36.0      
##  [59] carData_3.0-5             DBI_1.2.1                
##  [61] highr_0.10                ggsignif_0.6.4           
##  [63] biomaRt_2.58.2            rappdirs_0.3.3           
##  [65] DelayedArray_0.28.0       rjson_0.2.21             
##  [67] tools_4.3.2               httpuv_1.6.14            
##  [69] glue_1.7.0                restfulr_0.0.15          
##  [71] promises_1.2.1            gridtext_0.1.5           
##  [73] grid_4.3.2                generics_0.1.3           
##  [75] gtable_0.3.4              KMsurv_0.1-5             
##  [77] tzdb_0.4.0                tidyr_1.3.1              
##  [79] data.table_1.15.0         hms_1.1.3                
##  [81] car_3.1-2                 xml2_1.3.6               
##  [83] utf8_1.2.4                XVector_0.42.0           
##  [85] markdown_1.12             pillar_1.9.0             
##  [87] stringr_1.5.1             later_1.3.2              
##  [89] splines_4.3.2             ggtext_0.1.2             
##  [91] BiocFileCache_2.10.1      lattice_0.22-5           
##  [93] rtracklayer_1.62.0        bit_4.0.5                
##  [95] tidyselect_1.2.0          Biostrings_2.70.2        
##  [97] miniUI_0.1.1.1            knitr_1.45               
##  [99] gridExtra_2.3             bookdown_0.37            
## [101] futile.logger_1.4.3       xfun_0.41                
## [103] DT_0.31                   stringi_1.8.3            
## [105] yaml_2.3.8                evaluate_0.23            
## [107] codetools_0.2-19          tibble_3.2.1             
## [109] BiocManager_1.30.22.4     cli_3.6.2                
## [111] xtable_1.8-4              systemfonts_1.0.5        
## [113] munsell_0.5.0             jquerylib_0.1.4          
## [115] survMisc_0.5.6            Rcpp_1.0.12              
## [117] GenomicDataCommons_1.26.0 dbplyr_2.4.0             
## [119] png_0.1-8                 XML_3.99-0.16.1          
## [121] rapiclient_0.1.3          parallel_4.3.2           
## [123] TCGAutils_1.22.2          ellipsis_0.3.2           
## [125] pkgdown_2.0.7             readr_2.1.5              
## [127] blob_1.2.4                prettyunits_1.2.0        
## [129] bitops_1.0-7              scales_1.3.0             
## [131] purrr_1.0.2               crayon_1.5.2             
## [133] rlang_1.1.3               KEGGREST_1.42.0          
## [135] rvest_1.0.3               formatR_1.14

References

Ramos, Marcel, Ludwig Geistlinger, Sehyun Oh, Lucas Schiffer, Rimsha Azhar, Hanish Kodali, Ino de Bruijn, et al. 2020. “Multiomic Integration of Public Oncology Databases in Bioconductor.” JCO Clinical Cancer Informatics 1 (4): 958–71. https://doi.org/10.1200/CCI.19.00119.
Ramos, Marcel, Lucas Schiffer, Angela Re, Rimsha Azhar, Azfar Basunia, Carmen Rodriguez, Tiffany Chan, et al. 2017. Software for the Integration of Multiomics Experiments in Bioconductor.” Cancer Research 77 (21): e39–42. https://doi.org/10.1158/0008-5472.CAN-17-0344.