Differential Methylation

Here we demonstrate the analysis of DNA methylation dependent on one or more predictors. The predictors might be tissue, cell type, sex, age, tumor/normal, case/control or a combination of these factors. The DML (Differential Methylation Locus) function models β values (DNA methylation levels) using mixed linear models. This general supervised learning framework identifies CpG loci whose differential methylation is associated with known co-variates and can be used to perform epigenome-wide association studies (EWAS). Let’s first load the needed packages:

In the following, we will use an MM285 dataset of 10 mouse samples. This dataset contains mouse samples from different tissues and mice of different ages and sexes. The dataset is stored in a SummarizedExperiment object, which contains a data matrix combined with column-wise metadata accessible with colData:

CRITICAL: If your data contains NA, it is required that you exclude CpGs with missing levels. For example, one cannot assess sex-specific DNA methylation for a CpG that only has non-NA measurement on one sex. Exclusion of such CpGs for differential methylation modeling can be done using the checkLevels function. Here, we will check this for both sex and tissue:

## [1] 995

NOTE: If your model include discrete contrast variables like tissue and sex as in the current example, you should consider explicitly turning it into a factor variable with a reference level (we use treatment coding, see different coding systems).

For example, to use Colon as the reference tissue and Female as the reference sex, one can do the following

Then we will model DNA methylation variation treating tissue and sex as covariates. To do that we will call the DML function and specify the R formula ~tissue + sex. This function fits DNA methylation reading to a linear model and perform the corresponding slope test and goodness-of-fit test (F-test holding out each contrast variable). See also formula for how to specify lm/glm-like symbolic form for regression. All these results are returned in an object of class DMLSummary:

## DMLSummary Object with 995 Loci, 10 samples.
## Contrasts: tissue, sex

You can use mc.cores argument to parallelize the computing.

Test Interpretation

The DMLSummary object is a list of slightly expanded summary.lm objects as is typically returned by summary(lm()). The summaryExtractTest function extracts some key test statistics from the DMLSummary object and store them in a data frame. Rows of the data frame correspond to CpGs/loci and columns contain the slopes and p-values of each variable.

##  [1] "Probe_ID"             "Est_X.Intercept."     "Est_tissueCecum"     
##  [4] "Est_tissueEsophagus"  "Est_tissueFat"        "Est_tissueHeart"     
##  [7] "Est_sexMale"          "Pval_X.Intercept."    "Pval_tissueCecum"    
## [10] "Pval_tissueEsophagus" "Pval_tissueFat"       "Pval_tissueHeart"    
## [13] "Pval_sexMale"         "FPval_tissue"         "FPval_sex"           
## [16] "Eff_tissue"           "Eff_sex"

With the exception of the Intercept, there are four groups of columns, each starting with “Est_”, “Pval_”, “FPval_”, and “Eff_” as prefix. Here are what they represent:

  • Est_* : The slope estimate (aka the β coefficient, not to be confused with the DNA methylation β-value though) for continuous variable. DNA methylation difference of the current level with respect to the reference level for nominal contrast variables. Each suffix is concatenated from the contrast variable name (e.g., tissue, sex) and the level name if the contrast variable is discrete (e.g, Cecum, Esophagus, Fat). For example, Est_tissueFat should be interpreted as the estimated methylation level difference of Fat compared to the reference tissue (which is Colon, as set above). If reference is not set, the first level in the alphabetic order is used as the reference level. There is a special column named Est_`(Intercept)`. It corresponds to the base-level methylation of the reference (in this case a Female Colon sample).

  • Pval_* : The unadjusted p-values of t-testing the slope. This represents the statistical significance of the methylation difference. For example, Pval_tissueFat tests whether Fat is significantly different from Colon (the reference level) in DNA methylation. The Pval_`(Intercept)` tests whether the reference level is significantly different from zero.

  • FPval_* : The unadjusted p-value of the F-test contrasting the full model against a reduced model with the labeled contrast variable held out. Note that “Pval_” and “FPval_” are equivalent when the contrast variable is a 2-level factor, i.e., in the case of a pairwise comparison.

  • Eff_* : The effect size of each normial contrast variable. This is equivalent to the maximum slope subtracted by the minimum level including the reference level (0).

Multiple-testing adjustment can be done afterwards using R’s p.adjust function. It is integrated to the DMR function by default (see below).

Goodness of Fit

One may want to ask a question like

Is the CpG methylation tissue-specific?

rather than

Is the CpG more methylated in fat compared to liver?

The first question ask about the contrast variable as a whole while the second question concerns only a specific level in the contrast variable. To answer this question, we can use an F-test contasting the full model with a reduced model with the target contrast held out. By default, this statistics is already computed in the DML function. The test result is recorded in the FPval_ columns. For example, to get all CpGs that are methylated specific to sex,

Here we used 0.1 as the effect size threshold. This means DNA methylation difference under 0.1 (10%) is considered not biologically meaningful. This can be a valid assumption for homogenous cell composition as most cells would be either biallelically methylated, unmethylated or monoallelically methylated. But different threshold can be used in different analysis scenarios.

We can define CpG methylation as sex-specific, tissue-specific or both, by:

##             tissue_specific
## sex_specific FALSE TRUE
##        FALSE   891   99
##        TRUE      5    0

As you can see from the result, some probes are sex-specific and others are tissue-specific. There is no overlap between probes whose methylation reading is differential along both contrasts.

Pairwise Comparison

From the test result, we can also ask whether the DNA methylation is different between two sexes or between two specific tissues. For example, Est_sexMale compares male from females. The following code creates a volcano plot.

Likewise, we can ask whether DNA methylation might be different between fat and colon. We can do

Continuous Predictors

The variable tested in the DML function can be continuous. Suppose we are interested in age besides sex. We will call the same function but with the following formula:

Let’s verify the CpGs positively associated with age.

## `geom_smooth()` using formula = 'y ~ x'

DMR

For a given contrast, one can merge neighboring CpGs that show consistent methylation variation into differentially methylated regions (DMRs). For example, we can merge sex-specific differential methylation identified above to chromosome X regions that show X-inactivation-related methylation difference. To do this, we need to pick a contrast:

## [1] "X.Intercept."    "tissueCecum"     "tissueEsophagus" "tissueFat"      
## [5] "tissueHeart"     "sexMale"
## Platform set to: MM285
## Merging correlated CpGs ... Done.
## Generated 509 segments.
## Combine p-values ... 
##  - 25 significant segments.
##  - 1 significant segments (after BH).
## Done.

See Supplemental Vignette for track-view visualization of the data.

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] tidyr_1.2.1                 dplyr_1.0.10               
##  [3] ggplot2_3.4.0               tibble_3.1.8               
##  [5] SummarizedExperiment_1.28.0 Biobase_2.58.0             
##  [7] GenomicRanges_1.50.1        GenomeInfoDb_1.34.3        
##  [9] IRanges_2.32.0              S4Vectors_0.36.0           
## [11] MatrixGenerics_1.10.0       matrixStats_0.62.0         
## [13] knitr_1.40                  sesame_1.16.1              
## [15] sesameData_1.16.0           ExperimentHub_2.6.0        
## [17] AnnotationHub_3.6.0         BiocFileCache_2.6.0        
## [19] dbplyr_2.2.1                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                wheatmap_0.2.0               
## [45] BiocParallel_1.32.1           RCurl_1.98-1.9               
## [47] magrittr_2.0.3                GenomeInfoDbData_1.2.9       
## [49] Matrix_1.5-3                  Rcpp_1.0.9                   
## [51] munsell_0.5.0                 fansi_1.0.3                  
## [53] lifecycle_1.0.3               stringi_1.7.8                
## [55] yaml_2.3.6                    MASS_7.3-58.1                
## [57] zlibbioc_1.44.0               plyr_1.8.8                   
## [59] grid_4.2.2                    blob_1.2.3                   
## [61] ggrepel_0.9.2                 parallel_4.2.2               
## [63] promises_1.2.0.1              crayon_1.5.2                 
## [65] lattice_0.20-45               splines_4.2.2                
## [67] Biostrings_2.66.0             hms_1.1.2                    
## [69] KEGGREST_1.38.0               pillar_1.8.1                 
## [71] reshape2_1.4.4                codetools_0.2-18             
## [73] glue_1.6.2                    BiocVersion_3.16.0           
## [75] evaluate_0.18                 BiocManager_1.30.19          
## [77] png_0.1-7                     vctrs_0.5.0                  
## [79] tzdb_0.3.0                    httpuv_1.6.6                 
## [81] purrr_0.3.5                   gtable_0.3.1                 
## [83] assertthat_0.2.1              cachem_1.0.6                 
## [85] xfun_0.34                     mime_0.12                    
## [87] xtable_1.8-4                  e1071_1.7-12                 
## [89] later_1.3.0                   class_7.3-20                 
## [91] AnnotationDbi_1.60.0          memoise_2.0.1                
## [93] ellipsis_0.3.2                interactiveDisplayBase_1.36.0
## [95] BiocStyle_2.26.0