Source: https://github.com/markziemann/asd_meth

Introduction

Here I will be running a comparison of differential methylation data from guthrie and fresh blood samples.

Here are the files that I’m using:

  • limma_guthrie_diagnosis.csv

  • limma_blood_diagnosis.csv

suppressPackageStartupMessages({
  library("parallel")
  library("mitch")
  library("IlluminaHumanMethylationEPICanno.ilm10b4.hg19")
  source("https://raw.githubusercontent.com/markziemann/gmea/main/meth_functions.R")
  library("data.table")
  library("kableExtra")
  library("eulerr")
  library("RIdeogram")
  library("GenomicRanges")
  library("tictoc")
})

source("meth_functions.R")

Load Limma and RUV data for manhattan plot

First I will generate plots for limmma analysis.

# blood at assessment
top <- read.csv("limma_blood_diagnosis.csv")
nrow(top)
## [1] 802647
top <- subset(top,P.Value<1e-2)
nrow(top)
## [1] 1507
-log10(min(top$P.Value))
## [1] 3.756087
top$chr <- as.integer(gsub("chr","",top$chr))
top$snp <- paste(top$Name,top$UCSC_RefGene_Name)
top$snp <- sapply(strsplit(top$snp,";"),"[[",1)
up <- subset(top,logFC>0)
dn <- subset(top,logFC<0)

if ( (head(up$P.Value,1) < 1e-4) & (head(dn$P.Value,1) < 1e-4 ) ) {
  par(mfrow=c(2,1))
  par(mar=c(4,4,3,5))
  manhattan(x=up,chr="chr",bp="pos",p="P.Value",snp="snp",suggestiveline = -log10(1e-04),
    ylim=c(2,6), annotatePval= 1e-04 ,main="Blood at assessment limma hypermethylated")
  manhattan(x=dn,chr="chr",bp="pos",p="P.Value",snp="snp",suggestiveline = -log10(1e-04),
    ylim=c(2,6), annotatePval= 1e-04 , main="Blood at assessment limma hypomethylated")
  pdf("manhat_limma_bl.pdf")
  par(mfrow=c(2,1))
  par(mar=c(4,4,3,5))
  manhattan(x=up,chr="chr",bp="pos",p="P.Value",snp="snp",suggestiveline = -log10(1e-04),
    ylim=c(2,6), annotatePval= 1e-04 ,main="Blood at assessment limma hypermethylated")
  manhattan(x=dn,chr="chr",bp="pos",p="P.Value",snp="snp",suggestiveline = -log10(1e-04),
    ylim=c(2,6), annotatePval= 1e-04 , main="Blood at assessment limma hypomethylated")
  dev.off()
}

# neonatal guthrie card
top <- read.csv("limma_guthrie_diagnosis.csv")
nrow(top)
## [1] 790658
top <- subset(top,P.Value<1e-2)
nrow(top)
## [1] 2157
-log10(min(top$P.Value))
## [1] 4.511364
top$chr <- as.integer(gsub("chr","",top$chr))
top$snp <- paste(top$Name,top$UCSC_RefGene_Name)
top$snp <- sapply(strsplit(top$snp,";"),"[[",1)
up <- subset(top,logFC>0)
dn <- subset(top,logFC<0)

if ( (head(up$P.Value,1) < 1e-4) & (head(dn$P.Value,1) < 1e-4 ) ) {
  par(mfrow=c(2,1))
  par(mar=c(4,4,3,5))
  manhattan(x=up,chr="chr",bp="pos",p="P.Value",snp="snp",suggestiveline = -log10(1e-04),
    ylim=c(2,6), annotatePval= 1e-04 ,main="Neonatal Guthrie card limma hypermethylated",
    annotateTop=FALSE)
  manhattan(x=dn,chr="chr",bp="pos",p="P.Value",snp="snp",suggestiveline = -log10(1e-04),
    ylim=c(2,6), annotatePval= 1e-04 , main="Neonatal Guthrie card limma hypomethylated",
    annotateTop=FALSE)
  pdf("manhat_limma_gu.pdf")
  par(mfrow=c(2,1))
  par(mar=c(4,4,3,5))
  manhattan(x=up,chr="chr",bp="pos",p="P.Value",snp="snp",suggestiveline = -log10(1e-04),
    ylim=c(2,6), annotatePval= 1e-04 ,main="Neonatal Guthrie card limma hypermethylated",
    annotateTop=FALSE)
  manhattan(x=dn,chr="chr",bp="pos",p="P.Value",snp="snp",suggestiveline = -log10(1e-04),
    ylim=c(2,6), annotatePval= 1e-04 , main="Neonatal Guthrie card limma hypomethylated",
    annotateTop=FALSE)
  dev.off()
}

## png 
##   2

Compartment enrichment

Looking for enrichments in different genomic compartments.

Guthrie cards.

par(mfrow=c(2,1))

# guthrie
dma1 <- read.csv("limma_guthrie_diagnosis.csv")
if (nrow(subset(dma1,P.Value <1e-4)) > 100 ) {
comp <- compartment_enrichment(dma1)
comp <- lapply(comp,function(x) {subset(x,OR!=0)} )
comp
make_forest_plots_up(comp)
make_forest_plots_dn(comp)
}

Blood at assessment.

# blood
dma2 <- read.csv("limma_blood_diagnosis.csv")
if (nrow(subset(dma2,P.Value <1e-4)) > 100 ) {
comp <- compartment_enrichment(dma2)
comp <- lapply(comp,function(x) {subset(x,OR!=0)} )
comp
make_forest_plots_up(comp)
make_forest_plots_dn(comp)
}

Compartments top 1000

Guthrie cards.

par(mfrow=c(2,1))
# guthrie
comp <- compartment_enrichment2(dma1)
comp <- lapply(comp,function(x) {subset(x,OR!=0)} )
comp
## $up_comp
##               all  up        OR   fisherPval   lowerCI  upperCI
## Intergenic  43381  48 0.8721791 0.4011089855 0.6378084 1.167366
## 3'UTR       22433  26 0.9185289 0.7736433088 0.5963917 1.355727
## 5'UTR      102937 123 0.9412863 0.5678937037 0.7714975 1.140370
## Body       333689 410 0.9557899 0.5214073772 0.8351632 1.093519
## ExonBnd      6713   5 0.5892519 0.2978741008 0.1907901 1.381058
## TSS1500    115845 187 1.3595446 0.0002790428 1.1504080 1.600318
## TSS200      75104  82 0.8538688 0.1908189187 0.6717213 1.072984
## 
## $dn_comp
##               all  dn        OR fisherPval   lowerCI  upperCI
## Intergenic  43381  50 0.9252457  0.6722445 0.6808805 1.231844
## 3'UTR       22433  23 0.8220623  0.4391607 0.5181340 1.242177
## 5'UTR      102937 129 1.0126870  0.8856203 0.8332339 1.222597
## Body       333689 437 1.1135015  0.1177990 0.9724742 1.275059
## ExonBnd      6713   7 0.8395929  0.8605795 0.3364153 1.738356
## TSS1500    115845 139 0.9615907  0.7146521 0.7961454 1.154474
## TSS200      75104  83 0.8797337  0.2968239 0.6929059 1.104307
make_forest_plots_up(comp)

make_forest_plots_dn(comp)

Blood at assessment.

# blood
comp <- compartment_enrichment2(dma2)
comp <- lapply(comp,function(x) {subset(x,OR!=0)} )
comp
## $up_comp
##               all  up        OR fisherPval   lowerCI  upperCI
## Intergenic  43528  49 0.9390860 0.72045754 0.6887659 1.253933
## 3'UTR       22758  31 1.1462064 0.43460189 0.7734369 1.640322
## 5'UTR      104442 127 1.0215121 0.80843483 0.8390501 1.235288
## Body       339559 423 1.0862445 0.22891194 0.9471164 1.245823
## ExonBnd      6862   6 0.7300621 0.59603211 0.2670757 1.596565
## TSS1500    117509 121 0.8391903 0.07877845 0.6863917 1.018683
## TSS200      75457  91 1.0110947 0.91119859 0.8042657 1.258235
## 
## $dn_comp
##               all  dn        OR fisherPval   lowerCI  upperCI
## Intergenic  43528  42 0.8017818 0.17260404 0.5732471 1.093897
## 3'UTR       22758  39 1.4640122 0.02410984 1.0329605 2.019766
## 5'UTR      104442 113 0.8963048 0.30702660 0.7285315 1.094183
## Body       339559 405 1.0067758 0.94503559 0.8773461 1.155080
## ExonBnd      6862   8 0.9806965 1.00000000 0.4218273 1.942443
## TSS1500    117509 146 1.0549322 0.54701035 0.8763561 1.262811
## TSS200      75457  91 1.0164731 0.86686236 0.8084955 1.265011
make_forest_plots_up(comp)

make_forest_plots_dn(comp)

Looking for enrichments in proximity to CGI contexts

Guthrie cards.

par(mfrow=c(2,1))

if (nrow(subset(dma1,P.Value <1e-4)) > 100 ) {
# guthrie
comp <- cgi_enrichment(dma1)
comp <- lapply(comp,function(x) {subset(x,OR!=0)} )
comp
make_forest_plots_up(comp)
make_forest_plots_dn(comp)
}

Blood at assessment.

if (nrow(subset(dma2,P.Value <1e-4)) > 100 ) {
# blood
comp <- cgi_enrichment(dma2)
comp <- lapply(comp,function(x) {subset(x,OR!=0)} )
comp
make_forest_plots_up(comp)
make_forest_plots_dn(comp)
}

CGI enrichments in top 1000 probes

Guthrie cards.

par(mfrow=c(2,1))
# guthrie
comp <- cgi_enrichment2(dma1)
comp <- lapply(comp,function(x) {subset(x,OR!=0)} )
comp
## $up_comp
##            all  up        OR   fisherPval   lowerCI   upperCI
## Island  150182 157 0.7940359 7.710853e-03 0.6652682 0.9426955
## OpenSea 442427 534 0.9018297 1.041635e-01 0.7948994 1.0234256
## Shelf    55491  53 0.7412019 3.488778e-02 0.5510427 0.9779716
## Shore   142558 256 1.5653019 2.655120e-09 1.3525269 1.8067845
## 
## $dn_comp
##            all  dn        OR   fisherPval   lowerCI   upperCI
## Island  150182 215 1.1682299 4.798240e-02 0.9998384 1.3603642
## OpenSea 442427 489 0.7529396 7.885658e-06 0.6637424 0.8540824
## Shelf    55491  73 1.0433648 7.101004e-01 0.8104514 1.3252248
## Shore   142558 223 1.3052471 6.248293e-04 1.1194681 1.5169333
make_forest_plots_up(comp)

make_forest_plots_dn(comp)

Blood at assessment.

# blood
comp <- cgi_enrichment2(dma2)
comp <- lapply(comp,function(x) {subset(x,OR!=0)} )
comp
## $up_comp
##            all  up        OR  fisherPval   lowerCI   upperCI
## Island  150186 169 0.8833778 0.144322947 0.7441519 1.0435926
## OpenSea 452360 607 1.1962758 0.005508621 1.0518795 1.3617234
## Shelf    56174  54 0.7583004 0.047048080 0.5653311 0.9980987
## Shore   143927 170 0.9373149 0.458074617 0.7899350 1.1069169
## 
## $dn_comp
##            all  dn        OR fisherPval   lowerCI   upperCI
## Island  150186 207 1.1342423 0.11347305 0.9684715 1.3234726
## OpenSea 452360 525 0.8557004 0.01403665 0.7543374 0.9709051
## Shelf    56174  62 0.8782116 0.35212623 0.6677778 1.1364475
## Shore   143927 206 1.1876576 0.03186243 1.0138363 1.3862598
make_forest_plots_up(comp)

make_forest_plots_dn(comp)

Session information

For reproducibility

sessionInfo()
## R version 4.2.2 Patched (2022-11-10 r83330)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Ubuntu 22.04.2 LTS
## 
## Matrix products: default
## BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.10.0
## 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_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       
## 
## attached base packages:
##  [1] grid      stats4    parallel  stats     graphics  grDevices utils    
##  [8] datasets  methods   base     
## 
## other attached packages:
##  [1] tictoc_1.1                                         
##  [2] RIdeogram_0.2.2                                    
##  [3] kableExtra_1.3.4                                   
##  [4] data.table_1.14.8                                  
##  [5] ENmix_1.34.0                                       
##  [6] doParallel_1.0.17                                  
##  [7] qqman_0.1.8                                        
##  [8] RCircos_1.2.2                                      
##  [9] beeswarm_0.4.0                                     
## [10] forestplot_3.1.1                                   
## [11] abind_1.4-5                                        
## [12] checkmate_2.1.0                                    
## [13] reshape2_1.4.4                                     
## [14] gplots_3.1.3                                       
## [15] eulerr_7.0.0                                       
## [16] GEOquery_2.66.0                                    
## [17] RColorBrewer_1.1-3                                 
## [18] IlluminaHumanMethylation450kmanifest_0.4.0         
## [19] topconfects_1.14.0                                 
## [20] DMRcatedata_2.16.0                                 
## [21] ExperimentHub_2.6.0                                
## [22] AnnotationHub_3.6.0                                
## [23] BiocFileCache_2.6.0                                
## [24] dbplyr_2.3.1                                       
## [25] DMRcate_2.12.0                                     
## [26] limma_3.54.0                                       
## [27] missMethyl_1.32.0                                  
## [28] IlluminaHumanMethylation450kanno.ilmn12.hg19_0.6.1 
## [29] R.utils_2.12.2                                     
## [30] R.oo_1.25.0                                        
## [31] R.methodsS3_1.8.2                                  
## [32] plyr_1.8.8                                         
## [33] IlluminaHumanMethylationEPICanno.ilm10b4.hg19_0.6.0
## [34] minfi_1.44.0                                       
## [35] bumphunter_1.40.0                                  
## [36] locfit_1.5-9.7                                     
## [37] iterators_1.0.14                                   
## [38] foreach_1.5.2                                      
## [39] Biostrings_2.66.0                                  
## [40] XVector_0.38.0                                     
## [41] SummarizedExperiment_1.28.0                        
## [42] Biobase_2.58.0                                     
## [43] MatrixGenerics_1.10.0                              
## [44] matrixStats_0.63.0                                 
## [45] GenomicRanges_1.50.2                               
## [46] GenomeInfoDb_1.34.6                                
## [47] IRanges_2.32.0                                     
## [48] S4Vectors_0.36.1                                   
## [49] BiocGenerics_0.44.0                                
## [50] mitch_1.10.0                                       
## 
## loaded via a namespace (and not attached):
##   [1] rappdirs_0.3.3                rtracklayer_1.58.0           
##   [3] GGally_2.1.2                  tidyr_1.3.0                  
##   [5] ggplot2_3.4.1                 bit64_4.0.5                  
##   [7] knitr_1.42                    DelayedArray_0.24.0          
##   [9] rpart_4.1.19                  KEGGREST_1.38.0              
##  [11] RCurl_1.98-1.10               AnnotationFilter_1.22.0      
##  [13] generics_0.1.3                GenomicFeatures_1.50.3       
##  [15] preprocessCore_1.60.2         RSQLite_2.3.0                
##  [17] bit_4.0.5                     tzdb_0.3.0                   
##  [19] webshot_0.5.4                 xml2_1.3.3                   
##  [21] httpuv_1.6.9                  assertthat_0.2.1             
##  [23] xfun_0.37                     hms_1.1.2                    
##  [25] jquerylib_0.1.4               evaluate_0.20                
##  [27] promises_1.2.0.1              fansi_1.0.4                  
##  [29] restfulr_0.0.15               scrime_1.3.5                 
##  [31] progress_1.2.2                caTools_1.18.2               
##  [33] readxl_1.4.2                  DBI_1.1.3                    
##  [35] geneplotter_1.76.0            htmlwidgets_1.6.2            
##  [37] reshape_0.8.9                 purrr_1.0.1                  
##  [39] ellipsis_0.3.2                dplyr_1.1.0                  
##  [41] backports_1.4.1               permute_0.9-7                
##  [43] calibrate_1.7.7               grImport2_0.2-0              
##  [45] annotate_1.76.0               biomaRt_2.54.0               
##  [47] deldir_1.0-6                  sparseMatrixStats_1.10.0     
##  [49] vctrs_0.6.0                   ensembldb_2.22.0             
##  [51] withr_2.5.0                   cachem_1.0.7                 
##  [53] Gviz_1.42.0                   BSgenome_1.66.2              
##  [55] GenomicAlignments_1.34.0      prettyunits_1.1.1            
##  [57] mclust_6.0.0                  svglite_2.1.1                
##  [59] cluster_2.1.4                 RPMM_1.25                    
##  [61] lazyeval_0.2.2                crayon_1.5.2                 
##  [63] genefilter_1.80.3             edgeR_3.40.2                 
##  [65] pkgconfig_2.0.3               nlme_3.1-162                 
##  [67] ProtGenerics_1.30.0           nnet_7.3-18                  
##  [69] rlang_1.1.0                   lifecycle_1.0.3              
##  [71] filelock_1.0.2                dichromat_2.0-0.1            
##  [73] rsvg_2.4.0                    cellranger_1.1.0             
##  [75] rngtools_1.5.2                base64_2.0.1                 
##  [77] Matrix_1.5-3                  Rhdf5lib_1.20.0              
##  [79] base64enc_0.1-3               viridisLite_0.4.1            
##  [81] png_0.1-8                     rjson_0.2.21                 
##  [83] bitops_1.0-7                  KernSmooth_2.23-20           
##  [85] rhdf5filters_1.10.0           blob_1.2.4                   
##  [87] DelayedMatrixStats_1.20.0     doRNG_1.8.6                  
##  [89] stringr_1.5.0                 nor1mix_1.3-0                
##  [91] readr_2.1.4                   jpeg_0.1-10                  
##  [93] scales_1.2.1                  memoise_2.0.1                
##  [95] magrittr_2.0.3                zlibbioc_1.44.0              
##  [97] compiler_4.2.2                BiocIO_1.8.0                 
##  [99] illuminaio_0.40.0             Rsamtools_2.14.0             
## [101] cli_3.6.0                     DSS_2.46.0                   
## [103] htmlTable_2.4.1               Formula_1.2-5                
## [105] MASS_7.3-58.3                 tidyselect_1.2.0             
## [107] stringi_1.7.12                highr_0.10                   
## [109] yaml_2.3.7                    askpass_1.1                  
## [111] latticeExtra_0.6-30           sass_0.4.5                   
## [113] VariantAnnotation_1.44.0      tools_4.2.2                  
## [115] rstudioapi_0.14               foreign_0.8-84               
## [117] bsseq_1.34.0                  gridExtra_2.3                
## [119] digest_0.6.31                 BiocManager_1.30.20          
## [121] shiny_1.7.4                   quadprog_1.5-8               
## [123] Rcpp_1.0.10                   siggenes_1.72.0              
## [125] BiocVersion_3.16.0            later_1.3.0                  
## [127] org.Hs.eg.db_3.16.0           httr_1.4.5                   
## [129] AnnotationDbi_1.60.0          biovizBase_1.46.0            
## [131] colorspace_2.1-0              rvest_1.0.3                  
## [133] XML_3.99-0.13                 splines_4.2.2                
## [135] statmod_1.5.0                 multtest_2.54.0              
## [137] systemfonts_1.0.4             xtable_1.8-4                 
## [139] jsonlite_1.8.4                dynamicTreeCut_1.63-1        
## [141] R6_2.5.1                      echarts4r_0.4.4              
## [143] Hmisc_5.0-1                   pillar_1.8.1                 
## [145] htmltools_0.5.4               mime_0.12                    
## [147] glue_1.6.2                    fastmap_1.1.1                
## [149] BiocParallel_1.32.5           interactiveDisplayBase_1.36.0
## [151] beanplot_1.3.1                codetools_0.2-19             
## [153] utf8_1.2.3                    lattice_0.20-45              
## [155] bslib_0.4.2                   tibble_3.2.0                 
## [157] curl_5.0.0                    gtools_3.9.4                 
## [159] openssl_2.0.6                 interp_1.1-3                 
## [161] survival_3.5-5                rmarkdown_2.20               
## [163] munsell_0.5.0                 rhdf5_2.42.0                 
## [165] GenomeInfoDbData_1.2.9        HDF5Array_1.26.0             
## [167] impute_1.72.3                 gtable_0.3.2