library(sesame)
sesameDataCache()

Calculate Quality Metrics

The main function to calculate the quality metrics is sesameQC_calcStats. This function takes a SigDF, calculates the QC statistics, and returns a single S4 sesameQC object, which can be printed directly to the console. To calculate QC metrics on a given list of samples or all IDATs in a folder, one can use sesameQC_calcStats within the standard openSesame pipeline. When used with openSesame, a list of sesameQCs will be returned. Note that one should turn off preprocessing using prep="":

## calculate metrics on all IDATs in a specific folder
qcs = openSesame(idat_dir, prep="", func=sesameQC_calcStats)

SeSAMe divides sample quality metrics into multiple groups. These groups are listed below and can be referred to by short keys. For example, “intensity” generates signal intensity-related quality metrics.

Short.Key Description
detection Signal Detection
numProbes Number of Probes
intensity Signal Intensity
channel Color Channel
dyeBias Dye Bias
betas Beta Value

By default, sesameQC_calcStats calculates all QC groups. To save time, one can compute a specific QC group by specifying one or multiple short keys in the funs= argument:

sdfs <- sesameDataGet("EPIC.5.SigDF.normal")[1:2] # get two examples
## only compute signal detection stats
qcs = openSesame(sdfs, prep="", func=sesameQC_calcStats, funs="detection")
qcs[[1]]
## 
## =====================
## | Detection 
## =====================
## N. Probes w/ Missing Raw Intensity   : 0 (num_dtna)
## % Probes w/ Missing Raw Intensity    : 0.0 % (frac_dtna)
## N. Probes w/ Detection Success       : 838020 (num_dt)
## % Detection Success                  : 96.7 % (frac_dt)
## N. Detection Succ. (after masking)   : 838020 (num_dt_mk)
## % Detection Succ. (after masking)    : 96.7 % (frac_dt_mk)
## N. Probes w/ Detection Success (cg)  : 835491 (num_dt_cg)
## % Detection Success (cg)             : 96.7 % (frac_dt_cg)
## N. Probes w/ Detection Success (ch)  : 2471 (num_dt_ch)
## % Detection Success (ch)             : 84.3 % (frac_dt_ch)
## N. Probes w/ Detection Success (rs)  : 58 (num_dt_rs)
## % Detection Success (rs)             : 98.3 % (frac_dt_rs)

We consider signal detection the most important QC metric.

One can retrieve the actual stat numbers from sesameQC using the sesameQC_getStats (the following generates the fraction of probes with detection success):

sesameQC_getStats(qcs[[1]], "frac_dt")
## [1] 0.9666915

After computing the QCs, one can optionally combine the sesameQC objects into a data frame for easy comparison.

## combine a list of sesameQC into a data frame
head(do.call(rbind, lapply(qcs, as.data.frame)))

Note that when the input is an SigDF object, calling sesameQC_calcStats within openSesame and as a standalone function are equivalent.

sdf <- sesameDataGet('EPIC.1.SigDF')
qc = openSesame(sdf, prep="", func=sesameQC_calcStats, funs=c("detection"))
## equivalent direct call
qc = sesameQC_calcStats(sdf, c("detection"))
qc
## 
## =====================
## | Detection 
## =====================
## N. Probes w/ Missing Raw Intensity   : 0 (num_dtna)
## % Probes w/ Missing Raw Intensity    : 0.0 % (frac_dtna)
## N. Probes w/ Detection Success       : 834922 (num_dt)
## % Detection Success                  : 96.3 % (frac_dt)
## N. Detection Succ. (after masking)   : 834922 (num_dt_mk)
## % Detection Succ. (after masking)    : 96.3 % (frac_dt_mk)
## N. Probes w/ Detection Success (cg)  : 832046 (num_dt_cg)
## % Detection Success (cg)             : 96.4 % (frac_dt_cg)
## N. Probes w/ Detection Success (ch)  : 2616 (num_dt_ch)
## % Detection Success (ch)             : 89.2 % (frac_dt_ch)
## N. Probes w/ Detection Success (rs)  : 58 (num_dt_rs)
## % Detection Success (rs)             : 98.3 % (frac_dt_rs)

Rank Quality Metrics

SeSAMe features comparison of your sample with public data sets. The sesameQC_rankStats() function ranks the input sesameQC object with sesameQC calculated from public datasets. It shows the rank percentage of the input sample as well as the number of datasets compared.

sdf <- sesameDataGet('EPIC.1.SigDF')
qc <- sesameQC_calcStats(sdf, "intensity")
qc
## 
## =====================
## | Signal Intensity 
## =====================
## Mean sig. intensity          : 3171.21 (mean_intensity)
## Mean sig. intensity (M+U)    : 6342.41 (mean_intensity_MU)
## Mean sig. intensity (Inf.II) : 2991.85 (mean_ii)
## Mean sig. intens.(I.Grn IB)  : 3004.33 (mean_inb_grn)
## Mean sig. intens.(I.Red IB)  : 4670.97 (mean_inb_red)
## Mean sig. intens.(I.Grn OOB) : 318.55 (mean_oob_grn)
## Mean sig. intens.(I.Red OOB) : 606.99 (mean_oob_red)
## N. NA in M (all probes)      : 0 (na_intensity_M)
## N. NA in U (all probes)      : 0 (na_intensity_U)
## N. NA in raw intensity (IG)  : 0 (na_intensity_ig)
## N. NA in raw intensity (IR)  : 0 (na_intensity_ir)
## N. NA in raw intensity (II)  : 0 (na_intensity_ii)
sesameQC_rankStats(qc, platform="EPIC")
## 
## =====================
## | Signal Intensity 
## =====================
## Mean sig. intensity          : 3171.21 (mean_intensity) - Rank 15.7% (N=636)
## Mean sig. intensity (M+U)    : 6342.41 (mean_intensity_MU)
## Mean sig. intensity (Inf.II) : 2991.85 (mean_ii) - Rank 15.6% (N=636)
## Mean sig. intens.(I.Grn IB)  : 3004.33 (mean_inb_grn) - Rank 7.5% (N=636)
## Mean sig. intens.(I.Red IB)  : 4670.97 (mean_inb_red) - Rank 21.2% (N=636)
## Mean sig. intens.(I.Grn OOB) : 318.55 (mean_oob_grn) - Rank 4.2% (N=636)
## Mean sig. intens.(I.Red OOB) : 606.99 (mean_oob_red) - Rank 3.6% (N=636)
## N. NA in M (all probes)      : 0 (na_intensity_M)
## N. NA in U (all probes)      : 0 (na_intensity_U)
## N. NA in raw intensity (IG)  : 0 (na_intensity_ig)
## N. NA in raw intensity (IR)  : 0 (na_intensity_ir)
## N. NA in raw intensity (II)  : 0 (na_intensity_ii)

Quality Control Plots

SeSAMe provides functions to create QC plots. Some functions takes sesameQC as input while others directly plot the SigDF objects. Here are some examples:

  • sesameQC_plotBar() takes a list of sesameQC objects and creates bar plot for each metric calculated.

  • sesameQC_plotRedGrnQQ() graphs the dye bias between the two color channels.

  • sesameQC_plotIntensVsBetas() plots the relationship between β values and signal intensity and can be used to diagnose artificial readout and influence of signal background.

  • sesameQC_plotHeatSNPs() plots SNP probes and can be used to detect sample swaps.

More about quality control plots can be found in Supplemental Vignette.

Session Info

sessionInfo()
## R version 4.3.0 (2023-04-21)
## Platform: aarch64-apple-darwin22.3.0 (64-bit)
## Running under: macOS Ventura 13.5.2
## 
## Matrix products: default
## BLAS:   /Users/zhouw3/.Renv/versions/4.3.0.devel/lib/R/lib/libRblas.dylib 
## LAPACK: /Users/zhouw3/.Renv/versions/4.3.0.devel/lib/R/lib/libRlapack.dylib;  LAPACK version 3.11.0
## 
## locale:
## [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
## 
## time zone: America/New_York
## tzcode source: internal
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## other attached packages:
##  [1] knitr_1.44          sesame_1.19.8       sesameData_1.19.0  
##  [4] ExperimentHub_2.9.1 AnnotationHub_3.9.2 BiocFileCache_2.9.1
##  [7] dbplyr_2.3.4        BiocGenerics_0.47.0 rmarkdown_2.25     
## [10] R6_2.5.1           
## 
## loaded via a namespace (and not attached):
##  [1] tidyselect_1.2.0              dplyr_1.1.3                  
##  [3] blob_1.2.4                    filelock_1.0.2               
##  [5] Biostrings_2.69.2             bitops_1.0-7                 
##  [7] fastmap_1.1.1                 RCurl_1.98-1.12              
##  [9] promises_1.2.1                digest_0.6.33                
## [11] mime_0.12                     lifecycle_1.0.3              
## [13] ellipsis_0.3.2                KEGGREST_1.41.4              
## [15] interactiveDisplayBase_1.39.0 RSQLite_2.3.1                
## [17] magrittr_2.0.3                compiler_4.3.0               
## [19] rlang_1.1.1                   sass_0.4.7                   
## [21] tools_4.3.0                   utf8_1.2.3                   
## [23] yaml_2.3.7                    S4Arrays_1.1.6               
## [25] bit_4.0.5                     curl_5.1.0                   
## [27] DelayedArray_0.27.10          plyr_1.8.9                   
## [29] RColorBrewer_1.1-3            abind_1.4-5                  
## [31] BiocParallel_1.35.4           withr_2.5.1                  
## [33] purrr_1.0.2                   grid_4.3.0                   
## [35] stats4_4.3.0                  preprocessCore_1.63.1        
## [37] fansi_1.0.5                   wheatmap_0.2.0               
## [39] colorspace_2.1-0              xtable_1.8-4                 
## [41] ggplot2_3.4.4                 scales_1.2.1                 
## [43] SummarizedExperiment_1.31.1   cli_3.6.1                    
## [45] crayon_1.5.2                  generics_0.1.3               
## [47] reshape2_1.4.4                httr_1.4.7                   
## [49] tzdb_0.4.0                    DBI_1.1.3                    
## [51] cachem_1.0.8                  stringr_1.5.0                
## [53] zlibbioc_1.47.0               parallel_4.3.0               
## [55] AnnotationDbi_1.63.2          BiocManager_1.30.22          
## [57] XVector_0.41.1                matrixStats_1.0.0            
## [59] vctrs_0.6.4                   Matrix_1.6-1.1               
## [61] jsonlite_1.8.7                IRanges_2.35.3               
## [63] hms_1.1.3                     S4Vectors_0.39.3             
## [65] bit64_4.0.5                   jquerylib_0.1.4              
## [67] glue_1.6.2                    codetools_0.2-19             
## [69] stringi_1.7.12                gtable_0.3.4                 
## [71] BiocVersion_3.18.0            later_1.3.1                  
## [73] GenomeInfoDb_1.37.6           GenomicRanges_1.53.2         
## [75] munsell_0.5.0                 tibble_3.2.1                 
## [77] pillar_1.9.0                  rappdirs_0.3.3               
## [79] htmltools_0.5.6.1             GenomeInfoDbData_1.2.10      
## [81] lattice_0.21-9                evaluate_0.22                
## [83] shiny_1.7.5.1                 Biobase_2.61.0               
## [85] readr_2.1.4                   png_0.1-8                    
## [87] memoise_2.0.1                 BiocStyle_2.29.2             
## [89] httpuv_1.6.11                 bslib_0.5.1                  
## [91] Rcpp_1.0.11                   SparseArray_1.1.12           
## [93] xfun_0.40                     MatrixGenerics_1.13.1        
## [95] pkgconfig_2.0.3