CytoMethIC Quick Start

2 May 2024

Installation

To use CytoMethIC, you need to install the package from Bioconductor. If you don’t have the BiocManager package installed, install it first:

if (!requireNamespace("BiocManager", quietly = TRUE)) {
  install.packages("BiocManager")
}
if (!requireNamespace("CytoMethIC", quietly = TRUE)) {
  BiocManager::install("CytoMethIC")
}

Introduction

CytoMethIC is a comprehensive package that provides model data and functions for easily using machine learning models that use data from the DNA methylome to classify cancer type and phenotype from a sample. The primary motivation for the development of this package is to abstract away the granular and accessibility-limiting code required to utilize machine learning models in R. Our package provides this abstraction for RandomForest, e1071 Support Vector, Extreme Gradient Boosting, and Tensorflow models. This is paired with an ExperimentHub component, which contains our lab’s models developed for epigenetic cancer classification and predicting phenotypes. This includes CNS tumor classification, Pan-cancer classification, race prediction, cell of origin classification, and subtype classification models.

library(CytoMethIC)
library(ExperimentHub)
library(sesame)
sesameDataCache()

Data from ExperimentHub

For these examples, we’ll be using models from ExperimentHub and a sample from sesameData.

Table: CytoMethIC supported models

ModelID PredictionLabelDescription
rfc_cancertype_TCGA33 TCGA cancer types (N=33)
svm_cancertype_TCGA33 TCGA cancer types (N=33)
xgb_cancertype_TCGA33 TCGA cancer types (N=33)
mlp_cancertype_TCGA33 TCGA cancer types (N=33)
rfc_cancertype_CNS66 CNS Tumor Class (N=66)
svm_cancertype_CNS66 CNS Tumor Class (N=66)
xgb_cancertype_CNS66 CNS Tumor Class (N=66)
mlp_cancertype_CNS66 CNS Tumor Class (N=66)
NA NA
NA NA
NA NA

Pan-Cancer type classification

The below snippet shows a demonstration of the model abstraction working on random forest and support vector models from CytoMethIC models on ExperimentHub.

cmi_predict(sesameDataGet("HM450.1.TCGA.PAAD")$betas, ExperimentHub()[["EH8395"]],
    lift_over=TRUE)
## # A tibble: 1 × 2
##   response  prob
##   <chr>    <dbl>
## 1 PAAD     0.852
cmi_predict(sesameDataGet("HM450.1.TCGA.PAAD")$betas, ExperimentHub()[["EH8396"]],
    lift_over=TRUE)
## # A tibble: 1 × 2
##   response  prob
##   <chr>    <dbl>
## 1 PAAD     0.986

Pan-Cancer subtype classification

The below snippet shows a demonstration of the cmi_predict function working to predict the subtype of the cancer.

cmi_predict(sesameDataGet("HM450.1.TCGA.PAAD")$betas, ExperimentHub()[["EH8422"]])
## # A tibble: 1 × 2
##   response  prob
##   <chr>    <dbl>
## 1 GI.CIN   0.462

Ethnicity classification

The below snippet shows a demonstration of the cmi_predict function working to predict the ethnicity of the patient.

cmi_predict(sesameDataGet("HM450.1.TCGA.PAAD")$betas, ExperimentHub()[["EH8421"]])
## # A tibble: 1 × 2
##   response  prob
##   <chr>    <dbl>
## 1 WHITE    0.886

Pan-Cancer COO classification

The below snippet shows a demonstration of the cmi_predict function working to predict the cell of origin of the cancer.

cmi_predict(sesameDataGet("HM450.1.TCGA.PAAD")$betas, ExperimentHub()[["EH8423"]])
## # A tibble: 1 × 2
##   response                    prob
##   <chr>                      <dbl>
## 1 C20:Mixed (Stromal/Immune) 0.768

Ethnicity From GitHub Link

In addition to ExperimentHub Models, this package also supports using models from GitHub URLs. Note that https://github.com/zhou-lab/CytoMethIC_models will be the most frequently updated public repository of our lab’s classifiers.

base_url <- "https://github.com/zhou-lab/CytoMethIC_models/raw/main/models"
cmi_model <- readRDS(url(sprintf("%s/Race3_rfcTCGA_InfHum3.rds", base_url)))
betas <- openSesame(sesameDataGet("EPICv2.8.SigDF")[[1]])
cmi_predict(betas, cmi_model, lift_over=TRUE)
## # A tibble: 1 × 2
##   response  prob
##   <chr>    <dbl>
## 1 WHITE     0.69
sessionInfo()
## R version 4.4.0 RC (2024-04-16 r86468)
## Platform: x86_64-pc-linux-gnu
## Running under: Ubuntu 22.04.4 LTS
## 
## Matrix products: default
## BLAS:   /home/biocbuild/bbs-3.20-bioc/R/lib/libRblas.so 
## LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.10.0
## 
## 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       
## 
## time zone: America/New_York
## tzcode source: system (glibc)
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## other attached packages:
## [1] knitr_1.46           sesame_1.23.0        sesameData_1.23.0   
## [4] CytoMethIC_1.1.0     ExperimentHub_2.13.0 AnnotationHub_3.13.0
## [7] BiocFileCache_2.13.0 dbplyr_2.5.0         BiocGenerics_0.51.0 
## 
## loaded via a namespace (and not attached):
##  [1] tidyselect_1.2.1            dplyr_1.1.4                
##  [3] blob_1.2.4                  filelock_1.0.3             
##  [5] Biostrings_2.73.0           fastmap_1.1.1              
##  [7] digest_0.6.35               mime_0.12                  
##  [9] lifecycle_1.0.4             KEGGREST_1.45.0            
## [11] RSQLite_2.3.6               magrittr_2.0.3             
## [13] compiler_4.4.0              rlang_1.1.3                
## [15] tools_4.4.0                 utf8_1.2.4                 
## [17] yaml_2.3.8                  S4Arrays_1.5.0             
## [19] bit_4.0.5                   curl_5.2.1                 
## [21] DelayedArray_0.31.0         plyr_1.8.9                 
## [23] RColorBrewer_1.1-3          abind_1.4-5                
## [25] BiocParallel_1.39.0         withr_3.0.0                
## [27] purrr_1.0.2                 grid_4.4.0                 
## [29] stats4_4.4.0                preprocessCore_1.67.0      
## [31] fansi_1.0.6                 wheatmap_0.2.0             
## [33] e1071_1.7-14                colorspace_2.1-0           
## [35] ggplot2_3.5.1               MASS_7.3-60.2              
## [37] scales_1.3.0                SummarizedExperiment_1.35.0
## [39] cli_3.6.2                   rmarkdown_2.26             
## [41] crayon_1.5.2                generics_0.1.3             
## [43] reshape2_1.4.4              httr_1.4.7                 
## [45] tzdb_0.4.0                  proxy_0.4-27               
## [47] DBI_1.2.2                   cachem_1.0.8               
## [49] stringr_1.5.1               zlibbioc_1.51.0            
## [51] parallel_4.4.0              AnnotationDbi_1.67.0       
## [53] BiocManager_1.30.22         XVector_0.45.0             
## [55] matrixStats_1.3.0           vctrs_0.6.5                
## [57] Matrix_1.7-0                jsonlite_1.8.8             
## [59] IRanges_2.39.0              hms_1.1.3                  
## [61] S4Vectors_0.43.0            bit64_4.0.5                
## [63] glue_1.7.0                  codetools_0.2-20           
## [65] stringi_1.8.3               gtable_0.3.5               
## [67] BiocVersion_3.20.0          GenomeInfoDb_1.41.0        
## [69] GenomicRanges_1.57.0        UCSC.utils_1.1.0           
## [71] munsell_0.5.1               tibble_3.2.1               
## [73] pillar_1.9.0                rappdirs_0.3.3             
## [75] htmltools_0.5.8.1           randomForest_4.7-1.1       
## [77] GenomeInfoDbData_1.2.12     R6_2.5.1                   
## [79] lattice_0.22-6              evaluate_0.23              
## [81] Biobase_2.65.0              readr_2.1.5                
## [83] png_0.1-8                   memoise_2.0.1              
## [85] BiocStyle_2.33.0            class_7.3-22               
## [87] Rcpp_1.0.12                 SparseArray_1.5.0          
## [89] xfun_0.43                   MatrixGenerics_1.17.0      
## [91] pkgconfig_2.0.3