The epialleleR output values

24 October, 2023

Abstract

A comparison and visualisation of epialleleR output values for various input files

Introduction

The best possible explanation on VEF and lMHL values is given in help files for generateCytosineReport and generateMhlReport methods, respectively. Here we try to show some simplified and real situations, i.e., different methylation patterns that may exist, and provide a visual summary of epialleleR output.

The readers are welcome to try their own real and simulated data. If it might be of interest to others, please create an issue and these examples might get included in this vignette.

NB: the plotMetrics function used below is a piece of spaghetti code, hence hidden. If you still want to use it or see what it does - browse a source code of this vignette online.

out.bam <- tempfile(pattern="simulated", fileext=".bam")

# no epimutations
simulateBam(
  output.bam.file=out.bam,
  XM=c(
    sapply(
      lapply(1:1000, function (x) sample(c("Z",rep("z", 9)), 10)),
      paste, collapse=""
    )
  ),
  XG="CT"
)
#> Writing sample BAM [0.153s]
#> [1] 1000
plotMetrics(out.bam, as("chrS:1-10", "GRanges"), 0, title="no epimutations")


# one complete epimutation
simulateBam(
  output.bam.file=out.bam,
  XM=c(
    paste(rep("Z", 10), collapse=""),
    sapply(
      lapply(1:999, function (x) sample(c("Z",rep("z", 9)), 10)),
      paste, collapse=""
    )
  ),
  XG="CT"
)
#> Writing sample BAM [0.223s]
#> [1] 1000
plotMetrics(out.bam, as("chrS:1-10", "GRanges"), title="one complete epimutation")


# one partial epimutation
simulateBam(
  output.bam.file=out.bam,
  XM=c(
    paste(c(rep("Z", 4), "z", "z", rep("Z", 4)), collapse=""),
    sapply(
      lapply(1:999, function (x) sample(c("Z",rep("z", 9)), 10)),
      paste, collapse=""
    )
  ),
  XG="CT"
)
#> Writing sample BAM [0.142s]
#> [1] 1000
plotMetrics(out.bam, as("chrS:1-10", "GRanges"), title="one partial epimutation")


# another partial epimutation
simulateBam(
  output.bam.file=out.bam,
  XM=c(
    "zZZZZZZZzz",
    sapply(
      lapply(1:999, function (x) sample(c("Z",rep("z", 9)), 10)),
      paste, collapse=""
    )
  ),
  XG="CT"
)
#> Writing sample BAM [0.145s]
#> [1] 1000
plotMetrics(out.bam, as("chrS:1-10", "GRanges"), title="another partial epimutation")


# several partial epimutations
simulateBam(
  output.bam.file=out.bam,
  XM=c(
    sapply(
      lapply(1:10, function (x) c(rep("Z", 6), rep("z", 4))),
      paste, collapse=""
    ),
    sapply(
      lapply(1:999, function (x) sample(c("Z",rep("z", 9)), 10)),
      paste, collapse=""
    )
  ),
  XG="CT"
)
#> Writing sample BAM [0.153s]
#> [1] 1009
plotMetrics(out.bam, as("chrS:1-10", "GRanges"), title="several partial epimutations")


# several short partial epimutations
simulateBam(
  output.bam.file=out.bam,
  XM=c(
    sapply(
      lapply(1:10, function (x) c(rep("Z", 4), rep("z", 6))),
      paste, collapse=""
    ),
    sapply(
      lapply(1:999, function (x) sample(c("Z",rep("z", 9)), 10)),
      paste, collapse=""
    )
  ),
  XG="CT"
)
#> Writing sample BAM [0.180s]
#> [1] 1009
plotMetrics(out.bam, as("chrS:1-10", "GRanges"), title="several short partial epimutations")


# several overlapping partial epimutations
simulateBam(
  output.bam.file=out.bam,
  pos=1:10,
  XM=c(
    "ZZZZZZZZZZ", "ZZZZZZZZZz", "ZZZZZZZZzz", "ZZZZZZZzzz", "ZZZZZZzzzz",
    sapply(
      lapply(1:15, function (x) sample(c("Z",rep("z", 9)), 10)),
      paste, collapse=""
    )
  ),
  XG="CT"
)
#> Writing sample BAM [0.007s]
#> [1] 20
plotMetrics(out.bam, as("chrS:1-20", "GRanges"), title="several overlapping partial epimutations")


# amplicon 0%
plotMetrics(
  system.file("extdata", "amplicon000meth.bam", package="epialleleR"),
  as("chr17:43124861-43126026", "GRanges"), title="amplicon, 0%"
)


# amplicon 10%
plotMetrics(
  system.file("extdata", "amplicon010meth.bam", package="epialleleR"),
  as("chr17:43124861-43126026", "GRanges"), title="amplicon, 10%"
)


# sample capture, BMP7
plotMetrics(
  system.file("extdata", "capture.bam", package="epialleleR"),
  as("chr20:57266125-57268185:+", "GRanges"), title="sample capture, BMP7, + strand"
)


# sample capture, BMP7
plotMetrics(
  system.file("extdata", "capture.bam", package="epialleleR"),
  as("chr20:57266125-57268185:-", "GRanges"), title="sample capture, BMP7, - strand"
)


# sample capture, RAD51C
plotMetrics(
  system.file("extdata", "capture.bam", package="epialleleR"),
  as("chr17:58691673-58693108:+", "GRanges"), title="sample capture, RAD51C, + strand"
)


# sample capture, RAD51C
plotMetrics(
  system.file("extdata", "capture.bam", package="epialleleR"),
  as("chr17:58691673-58693108:-", "GRanges"), title="sample capture, RAD51C, - strand"
)


# long-read sequencing, low methylation
getXM <- function (p) {sample(x=c("z", "Z"), size=1, prob=c(p, 1-p))}
probs <- (sin(seq(-2*pi, +1*pi, by = pi/125))+2)/3
simulateBam(
  output.bam.file=out.bam,
  pos=1:10,
  XM=sapply(1:10, function (i) {paste(sapply(probs, getXM), collapse="")}),
  XG="CT"
)
#> Writing sample BAM [0.060s]
#> [1] 10
plotMetrics(out.bam, as("chrS:1-1000", "GRanges"), title="long-read sequencing, low methylation")


# long-read sequencing, high methylation
simulateBam(
  output.bam.file=out.bam,
  pos=1:10,
  XM=sapply(1:10, function (i) {paste(sapply(1-probs, getXM), collapse="")}),
  XG="CT"
)
#> Writing sample BAM [0.052s]
#> [1] 10
plotMetrics(out.bam, as("chrS:1-1000", "GRanges"), title="long-read sequencing, high methylation")

Session Info

sessionInfo()
#> R version 4.3.1 (2023-06-16)
#> Platform: x86_64-pc-linux-gnu (64-bit)
#> Running under: Ubuntu 22.04.3 LTS
#> 
#> Matrix products: default
#> BLAS:   /home/biocbuild/bbs-3.18-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               LC_TIME=en_GB             
#>  [4] LC_COLLATE=C               LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
#>  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                  LC_ADDRESS=C              
#> [10] LC_TELEPHONE=C             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] data.table_1.14.8    XVector_0.42.0       GenomicRanges_1.54.0 ggstance_0.3.6      
#> [5] IRanges_2.36.0       S4Vectors_0.40.0     gridExtra_2.3        ggplot2_3.4.4       
#> [9] epialleleR_1.10.0   
#> 
#> loaded via a namespace (and not attached):
#>  [1] tidyselect_1.2.0            farver_2.1.1                dplyr_1.1.3                
#>  [4] blob_1.2.4                  filelock_1.0.2              Biostrings_2.70.0          
#>  [7] bitops_1.0-7                fastmap_1.1.1               RCurl_1.98-1.12            
#> [10] BiocFileCache_2.10.0        VariantAnnotation_1.48.0    GenomicAlignments_1.38.0   
#> [13] XML_3.99-0.14               digest_0.6.33               lifecycle_1.0.3            
#> [16] KEGGREST_1.42.0             RSQLite_2.3.1               magrittr_2.0.3             
#> [19] compiler_4.3.1              rlang_1.1.1                 sass_0.4.7                 
#> [22] progress_1.2.2              tools_4.3.1                 utf8_1.2.4                 
#> [25] yaml_2.3.7                  rtracklayer_1.62.0          knitr_1.44                 
#> [28] labeling_0.4.3              prettyunits_1.2.0           S4Arrays_1.2.0             
#> [31] bit_4.0.5                   curl_5.1.0                  DelayedArray_0.28.0        
#> [34] RColorBrewer_1.1-3          plyr_1.8.9                  xml2_1.3.5                 
#> [37] abind_1.4-5                 BiocParallel_1.36.0         withr_2.5.1                
#> [40] BiocGenerics_0.48.0         grid_4.3.1                  stats4_4.3.1               
#> [43] fansi_1.0.5                 colorspace_2.1-0            scales_1.2.1               
#> [46] biomaRt_2.58.0              SummarizedExperiment_1.32.0 cli_3.6.1                  
#> [49] rmarkdown_2.25              crayon_1.5.2                generics_0.1.3             
#> [52] httr_1.4.7                  rjson_0.2.21                DBI_1.1.3                  
#> [55] cachem_1.0.8                stringr_1.5.0               zlibbioc_1.48.0            
#> [58] parallel_4.3.1              AnnotationDbi_1.64.0        restfulr_0.0.15            
#> [61] matrixStats_1.0.0           vctrs_0.6.4                 Matrix_1.6-1.1             
#> [64] jsonlite_1.8.7              hms_1.1.3                   bit64_4.0.5                
#> [67] GenomicFeatures_1.54.0      jquerylib_0.1.4             glue_1.6.2                 
#> [70] codetools_0.2-19            gtable_0.3.4                stringi_1.7.12             
#> [73] GenomeInfoDb_1.38.0         BiocIO_1.12.0               munsell_0.5.0              
#> [76] tibble_3.2.1                pillar_1.9.0                rappdirs_0.3.3             
#> [79] htmltools_0.5.6.1           GenomeInfoDbData_1.2.11     BSgenome_1.70.0            
#> [82] R6_2.5.1                    dbplyr_2.3.4                evaluate_0.22              
#> [85] lattice_0.22-5              Biobase_2.62.0              png_0.1-8                  
#> [88] Rsamtools_2.18.0            memoise_2.0.1               bslib_0.5.1                
#> [91] Rcpp_1.0.11                 SparseArray_1.2.0           xfun_0.40                  
#> [94] MatrixGenerics_1.14.0       pkgconfig_2.0.3