Preparation

As sesame and sesameData are under active development, this documentation is specific to the following version of R, sesame, sesameData and ExperimentHub:

##        sesame    sesameData ExperimentHub 
##      "1.16.1"      "1.16.0"       "2.6.0"
## [1] "4.2.2"

We recommend updating your R, ExperimentHub, sesameData and sesame to use this documentation consistently. If you have installed directly from github, we should make sure the compatible ExperimentHub is installed.

CRITICAL: After a new installation, one must cache the associated annotation data using the following command. This needs to be done only once per SeSAMe installation/update. Caching data to local guarantees proper data retrieval and saves internet traffic.

This function caches the needed SeSAMe annotations. SeSAMe annotation data is managed by the sesameData package which uses the ExperimentHub infrastructure. You can find the location of the cached annotation data on your local computer using:

## [1] "/home/biocbuild/.cache/R/ExperimentHub"

The openSesame Pipeline

The openSesame function provides end-to-end processing that converts IDATs to DNA methylation level (aka β value) matrices in R. The function can take either one of the following input:

  • A path to a directory where the IDAT files live
  • Specific path(s) of IDAT file prefix, one for each IDAT pair
  • One or a list of SigDF objects

The following code uses a directory that contains built-in two HM27 IDAT pairs to demonstrates the use of openSesame:

The BPPARAM= option is from the BiocParallel package and controls parallel processing (in this case, we are using two cores). Under the hood, the function performs a series of tasks including: searching IDAT files from the directory (the searchIDATprefixes function), reading IDAT data in as SigDF objects (the readIDATpair function), preprocessing the signals (the prepSesame function), and finally converting them to DNA methylation levels (β values, the getBetas function). Alternatively, one can run the following command to get the same results, while gaining more refined control:

The openSesame function is highly customizable. The prep= argument is the same argument one gives to the prepSesame function (see Data Preprocessing for detail) which openSesame calls internally. The argument uniquely specifies a preprocessing procedure. The func= option specifies the signal extraction function. It can be either be getBetas (DNA methylation) or getAFs (allele frequencies of SNP probes) or NULL (returns SigDF). The manifest= option allows one to provide an array manifest when handling data from platform not supported natively. Finally, the BPPARAM= argument is the same argument taken by BiocParallel::bplapply to allow parallel processing. See Supplemental Vignette for details of these component functions of openSesame.

The output of openSesame can also be customized. It can either be beta values, which are the end DNA methylation readings, as shown above. It can also be a list of SigDFs which stores the signal intensities and can be further put back to openSesame for more processing. The openSesame(func=) argument specifies whether the output is a SigDF list or beta values. The following shows some usage:

EPICv2

To use SeSAMe with EPICv2, one needs to build and pass an address data frame to openSesame’s manifest argument. The address data frame can be built using the sesameAnno_buildAddressFile function. In the future releases, EPICv2 will be natively supported and this extra operation will be come unnecessary. Here is an example:

Data Preprocessing

The prep= argument instructs the openSesame function to call the prepSesame function to preprocess signal intensity under the hood. This can be skipped by using prep="". The prepSesame function takes a single SigDF as input and returns a processed SigDF. When prep= is non-empty, it selects the preprocessing functions (see Preprocessing Function Code) and specifies the order of their execution. For example,

performs dye bias correction (D) followed by background subtraction (B). In other words, prepSesame(sdf, "DB") is equivalent to noob(dyeBiasNL(sdf)). All the preprocessing functions take a SigDF as input and return an updated SigDF. Therefore, these functions can be chained together. The choice of preprocessing functions and the order of their chaining is important (see Supplemental Vignette) for detailed discussions of these functions). The following table lists the best preprocessing strategy based on our experience.

Recommended Preprocessing
Platform Sample Organism Prep Code
EPIC/HM450 human QCDPB
EPIC/HM450 non-human organism SQCDPB
MM285 mouse TQCDPB
MM285 non-mouse organism SQCDPB
Mammal40 human HCDPB
Mammal40 non-human organism SHCDPB

The optimal strategy of preprocessing depends on:

  1. The array platform. For example, certain array platforms (e.g., the Mammal40) do not have enough Infinium-I probes for background estimation and dye bias correction, therefore background subtraction (where the out-of-band signals are from) might not work most optimally;

  2. The expected sample property. For example, some samples have the signature bimodal distribution of methylation of most mammalian cells. Others may undergo global loss of methylation (germ cells, tumors etc). Other important factors include high-input vs low-input, tumor vs normal, somatic vs germ cells, human vs model organisms, mouse strains etc. Some platforms (e.g., Mammal40 and MM285) are designed for multiple species and strains. Therefore S and T would be important when those arrays are used on non-reference organisms (see Working with Nonhuman Arrays).

Preprocessing Function Code

The prepSesameList function lists all the available codes and the associated preprocessing functions.

Here are some consideration when determining the preprocessing order. Species (S) and strain (T) inference resets the mask and color channels based on probe alignment and presence of genetic variants. Therefore when they are used, they need to be called first. Q masks non-uniquely mapped probes which may inflate the out-of-band signal for background estimation. Therefore Q should be used before detection p-value calculation (P) and background subtraction (B) when necessary. Channel inference (C) and dye bias correction (D) should take place early since dye bias effect is global. C should be placed before D because dye bias correction uses in-band signal the identification of which relies on correct channel designation. Detection p-value (P) should happen before background subtraction (B) since background subtraction modifies signal and may affect out-of-band signal assumption used in P. Lastly, functions that explicitly normalizes β value distribution (M) should happen last if they even need to be used.

See Supplemental Vignette for details of preprocessing functions.

Session Info

## R version 4.2.2 (2022-10-31)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Ubuntu 20.04.5 LTS
## 
## Matrix products: default
## BLAS:   /home/biocbuild/bbs-3.16-bioc/R/lib/libRblas.so
## LAPACK: /home/biocbuild/bbs-3.16-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] wheatmap_0.2.0              tidyr_1.2.1                
##  [3] dplyr_1.0.10                ggplot2_3.4.0              
##  [5] tibble_3.1.8                SummarizedExperiment_1.28.0
##  [7] Biobase_2.58.0              GenomicRanges_1.50.1       
##  [9] GenomeInfoDb_1.34.3         IRanges_2.32.0             
## [11] S4Vectors_0.36.0            MatrixGenerics_1.10.0      
## [13] matrixStats_0.62.0          knitr_1.40                 
## [15] sesame_1.16.1               sesameData_1.16.0          
## [17] ExperimentHub_2.6.0         AnnotationHub_3.6.0        
## [19] BiocFileCache_2.6.0         dbplyr_2.2.1               
## [21] BiocGenerics_0.44.0        
## 
## loaded via a namespace (and not attached):
##  [1] nlme_3.1-160                  bitops_1.0-7                 
##  [3] bit64_4.0.5                   filelock_1.0.2               
##  [5] RColorBrewer_1.1-3            httr_1.4.4                   
##  [7] tools_4.2.2                   bslib_0.4.1                  
##  [9] utf8_1.2.2                    R6_2.5.1                     
## [11] mgcv_1.8-41                   DBI_1.1.3                    
## [13] colorspace_2.0-3              withr_2.5.0                  
## [15] tidyselect_1.2.0              preprocessCore_1.60.0        
## [17] bit_4.0.4                     curl_4.3.3                   
## [19] compiler_4.2.2                cli_3.4.1                    
## [21] DelayedArray_0.24.0           labeling_0.4.2               
## [23] sass_0.4.2                    scales_1.2.1                 
## [25] randomForest_4.7-1.1          readr_2.1.3                  
## [27] proxy_0.4-27                  rappdirs_0.3.3               
## [29] stringr_1.4.1                 digest_0.6.30                
## [31] rmarkdown_2.18                XVector_0.38.0               
## [33] pkgconfig_2.0.3               htmltools_0.5.3              
## [35] highr_0.9                     fastmap_1.1.0                
## [37] rlang_1.0.6                   RSQLite_2.2.18               
## [39] shiny_1.7.3                   farver_2.1.1                 
## [41] jquerylib_0.1.4               generics_0.1.3               
## [43] jsonlite_1.8.3                BiocParallel_1.32.1          
## [45] RCurl_1.98-1.9                magrittr_2.0.3               
## [47] GenomeInfoDbData_1.2.9        Matrix_1.5-3                 
## [49] Rcpp_1.0.9                    munsell_0.5.0                
## [51] fansi_1.0.3                   lifecycle_1.0.3              
## [53] stringi_1.7.8                 yaml_2.3.6                   
## [55] MASS_7.3-58.1                 zlibbioc_1.44.0              
## [57] plyr_1.8.8                    grid_4.2.2                   
## [59] blob_1.2.3                    ggrepel_0.9.2                
## [61] parallel_4.2.2                promises_1.2.0.1             
## [63] crayon_1.5.2                  lattice_0.20-45              
## [65] splines_4.2.2                 Biostrings_2.66.0            
## [67] hms_1.1.2                     KEGGREST_1.38.0              
## [69] pillar_1.8.1                  reshape2_1.4.4               
## [71] codetools_0.2-18              glue_1.6.2                   
## [73] BiocVersion_3.16.0            evaluate_0.18                
## [75] BiocManager_1.30.19           png_0.1-7                    
## [77] vctrs_0.5.0                   tzdb_0.3.0                   
## [79] httpuv_1.6.6                  purrr_0.3.5                  
## [81] gtable_0.3.1                  assertthat_0.2.1             
## [83] cachem_1.0.6                  xfun_0.34                    
## [85] mime_0.12                     xtable_1.8-4                 
## [87] e1071_1.7-12                  later_1.3.0                  
## [89] class_7.3-20                  AnnotationDbi_1.60.0         
## [91] memoise_2.0.1                 ellipsis_0.3.2               
## [93] interactiveDisplayBase_1.36.0 BiocStyle_2.26.0