Tutorials › High-Dimensional Genomic Data Analysis › Differential Methylation Testing at Individual CpGs

Epigenomic and Regulatory Data · Tutorial 775 of 795

Differential Methylation Testing at Individual CpGs

Fit and interpret covariate-adjusted tests at individual CpG sites, including how to translate M-value effects into methylation differences on the beta scale.

Intermediate 12 min read

What You'll Learn

  • Specify a linear model for beta values or M values at one CpG.
  • Interpret a covariate-adjusted group contrast in the outcome’s units.
  • Calculate a contrast’s standard error, test statistic, and confidence interval.
  • Translate an M-value contrast into a beta-value difference at a stated profile.
  • Check model assumptions and distinguish sitewise from genome-wide evidence.
  • Report effect sizes alongside multiple-testing-adjusted results.

Why Test Methylation at an Individual CpG?

A differential methylation test asks whether methylation at a particular CpG site differs between groups, after accounting for specified covariates. The target is a group contrast for one site, not a claim that an entire genomic region changes or that group membership causes a change. Since an array can measure hundreds of thousands of sites, each site-specific result is also one part of a larger testing problem.

The choice of response scale affects how an estimated difference should be read. A beta value is on a 0-to-1 scale and supports direct statements in percentage points. An M value is a log-base-2 transformation of the methylation odds; its linear-model coefficients are often convenient for modelling, but are not constant differences in beta values. The earlier material on beta values and M values defines these scales; the essential formulas are given here so that the interpretation is explicit.

Definition: At CpG site \(j\), let \(Y_{ij}\) be the response for sample \(i\), either a beta value or an M value. A basic covariate-adjusted model is $$ Y_{ij}=\beta_{0j}+\beta_{1j}G_i+\boldsymbol{\gamma}_j^\top\mathbf{Z}_i+\varepsilon_{ij}, $$ where \(G_i\) indicates the group of interest, \(\mathbf{Z}_i\) contains specified covariates, and \(\varepsilon_{ij}\) is the residual. With \(G_i=1\) for the target group and \(G_i=0\) for the reference group, \(\beta_{1j}\) is the adjusted group difference when the model has no group-by-covariate interaction.

Model, Contrast, and Assumptions

For each CpG, ordinary least squares estimates the model coefficients by minimizing the sum of squared residuals. Testing no adjusted group difference at site \(j\) means testing \(H_0:\beta_{1j}=0\) against, commonly, the two-sided alternative \(H_a:\beta_{1j}\ne 0\). More generally, the scientific comparison may be a linear contrast \(c^\top\boldsymbol{\beta}_j\), where \(\boldsymbol{\beta}_j\) is the coefficient vector and \(c\) specifies the comparison. For example, with treatment coding and no interaction, the group coefficient itself is the contrast.

The interpretation depends on the model and design. The mean response must be adequately described by the included terms; the design matrix must have full column rank so the contrast is estimable; and, for the usual small-sample \(t\) test and confidence interval to be exact, errors must be independent, normally distributed, and have a common variance conditional on the predictors. Approximate inference can be useful with larger samples, but serious departures, influential observations, or an inadequate mean model can still undermine it. Samples, rather than repeated technical measurements of the same sample, are the independent observational units in this basic model.

Covariates can include measured characteristics or estimated cell-type fractions. If cell fractions sum to one, including every fraction together with an intercept creates exact collinearity; use an identifiable parameterization, such as omitting a reference fraction. The fitted group contrast is conditional on the covariates included. It is not automatically a causal effect, and the model does not repair a poorly chosen or non-identifiable adjustment set.

For an estimable contrast \(\theta_j=c^\top\boldsymbol{\beta}_j\), its estimated standard error is obtained from the coefficient covariance matrix \(\widehat{\mathbf V}_j\):

$$ \widehat{\theta}_j=c^\top\widehat{\boldsymbol{\beta}}_j,\qquad SE(\widehat{\theta}_j)=\sqrt{c^\top\widehat{\mathbf V}_jc},\qquad t=\frac{\widehat{\theta}_j}{SE(\widehat{\theta}_j)}. $$

Under the null and the model assumptions, this statistic follows a \(t\) distribution with residual degrees of freedom \(df\). A two-sided \(p\)-value is \(2P(T_{df}\ge |t|)\). A \(100(1-\alpha)\%\) confidence interval is \(\widehat{\theta}_j\pm t_{1-\alpha/2,df}SE(\widehat{\theta}_j)\). The interval describes the range of contrast values compatible with the data and model at that confidence level; it is not a probability statement about the fixed parameter after observing the data.

Worked Examples on the Two Scales

Worked Example: Adjusted Difference in Beta Values

Suppose a hypothetical study measures one CpG in 40 independent samples. A model includes an intercept, group indicator, age, and sex indicator. Assume the linear mean is adequate, residual diagnostics show no severe outliers or variance pattern, and residuals are reasonably normal. The design is full rank. The group coefficient is \(0.080\), its standard error is \(0.030\), and the residual degrees of freedom are \(36\).

The group coefficient is the adjusted beta-value difference, holding age and sex fixed. The test statistic is $$ t=\frac{0.080}{0.030}=2.667. $$

For a two-sided test with \(df=36\), the \(p\)-value is approximately \(0.0114\). The 95% interval uses \(t_{0.975,36}\approx2.028\): $$ 0.080\pm 2.028(0.030)=0.080\pm0.06084=(0.0192,\ 0.1408). $$

The estimated difference is 0.080 beta units, or 8.0 percentage points of methylation, adjusted for age and sex. The interval corresponds to about 1.9 to 14.1 percentage points. The data provide evidence against a zero adjusted difference at the 0.05 level, but this one-site \(p\)-value does not account for testing many CpGs.

Worked Example: Translating an M-Value Contrast

At a second hypothetical CpG, suppose the M-value model has an estimated group contrast of \(0.60\), standard error \(0.20\), and \(df=26\). Assume independent samples, a full-rank design, and no major residual or influence problems. The statistic is $$ t=\frac{0.60}{0.20}=3.00. $$ The two-sided \(p\)-value is \(0.005885\) (approximately).

An M value is \(M=\log_2\{\beta/(1-\beta)\}\), so an M difference of 0.60 is a difference of 0.60 on this log-odds scale; the corresponding ratio of methylation odds is \(2^{0.60}\approx1.516\). It is not a 60-percentage-point beta difference.

To give a beta-scale illustration, suppose the fitted reference-group M value at a stated covariate profile is \(-1.00\). Its beta value is $$ \beta_{\mathrm{ref}}=\frac{2^{-1.00}}{1+2^{-1.00}}=\frac{1}{3}=0.3333. $$ At that same profile, the fitted target-group M value is \(-1.00+0.60=-0.40\), giving $$ \beta_{\mathrm{target}}=\frac{2^{-0.40}}{1+2^{-0.40}}=\frac{1}{1+2^{0.40}}\approx0.4311. $$ The fitted difference at this profile is \(0.4311-0.3333=0.0978\), or about 9.78 percentage points. This is a profile-specific translation: because the inverse transformation is nonlinear, the same M contrast can imply a different beta difference at another baseline M value.

Contrasts When the Group Effect Varies

If the model includes a group-by-covariate interaction, the group coefficient alone is not the group difference at every covariate value. The relevant contrast must be evaluated at the covariate profile of interest, and its uncertainty must include covariance among the estimated coefficients.

Worked Example: Group Difference at a Specific Age

In a hypothetical beta-value analysis, let \(D=1\) denote the target group, and let age be centered at 50 years. The fitted model includes \(D\), centered age \(A\), and their interaction: $$ Y=\beta_0+\beta_DD+\beta_AA+\beta_{DA}DA+\varepsilon. $$ Assume the model assumptions for ordinary least-squares inference are reasonable. Estimates are \(\hat\beta_D=0.040\), \(SE(\hat\beta_D)=0.020\), \(\hat\beta_{DA}=0.0030\) per year, and \(SE(\hat\beta_{DA})=0.0015\) per year. Their estimated covariance is \(-0.000010\), and \(df=45\).

At age 60, \(A=10\), so the adjusted group contrast is $$ \widehat{\theta}(60)=0.040+10(0.0030)=0.070. $$ Its variance uses both coefficient variances and their covariance: $$ SE^2=\left(0.020\right)^2+10^2\left(0.0015\right)^2+2(10)(-0.000010) =0.000400+0.000225-0.000200=0.000425. $$ Thus \(SE=\sqrt{0.000425}=0.02062\). Using \(t_{0.975,45}\approx2.014\), the 95% interval is $$ 0.070\pm2.014(0.02062)=(0.0285,\ 0.1115). $$

At age 60, the estimated adjusted group difference is 7.0 percentage points, with a 95% interval of about 2.85 to 11.15 percentage points. Reporting only \(\hat\beta_D=0.040\) would describe the group contrast at age 50, not age 60.

Genome-Wide Testing, Diagnostics, and Alternatives

A test at one CpG has a sitewise \(p\)-value. When tests are performed at many CpGs, some small \(p\)-values can arise by chance even if all null hypotheses hold. A common approach is to apply the Benjamini–Hochberg procedure to the full set of sitewise \(p\)-values: order them from smallest to largest, compare the \(k\)th ordered value with \(k\alpha/m\), where \(m\) is the number of tests, and identify the largest \(k\) that meets the comparison. This controls the false discovery rate under its standard dependence conditions. Report the adjustment method and the set of tests to which it was applied. An adjusted result is not the probability that a particular site is truly differential.

Inspect diagnostics at representative sites and, where feasible, at sites driving important conclusions. Residual-versus-fitted plots can reveal nonconstant variance or a misspecified mean; normal quantile plots can reveal severe tail departures; leverage and influence checks can identify samples that dominate a contrast. Beta values are bounded, so a linear model can in principle predict outside 0 to 1, especially near the boundaries. M values remove that bound but do not guarantee normal, homoskedastic residuals. The scale should be chosen with both inference and biological interpretation in mind.

An unadjusted two-group comparison can be simpler, but does not estimate a covariate-adjusted contrast. A rank-based test can reduce reliance on a normal model, but generally targets a different comparison and does not automatically provide the same covariate-adjusted effect. A transformation or alternative response model may be worth considering when the linear-model diagnostics are poor; no method makes design limitations disappear. For the present model, a clear report gives the response scale, contrast, effect estimate and units, uncertainty, sitewise and adjusted evidence, and the covariates used.

Common pitfall: “The M-value coefficient is 0.60, so methylation increased by 60 percentage points.” This confuses a log-base-2 contrast with a beta-scale difference. Report the 0.60 M-unit contrast as such; if a beta difference is needed, transform fitted values at a stated covariate profile and subtract them.

Check Your Understanding

Answer each question, then compare with the solutions below.

  1. A beta-scale model estimates a group coefficient of \(-0.04\). What is its direction and size in percentage points, assuming no interaction?
  2. Why does an M-value difference not determine one universal beta-value difference?
  3. In a model with a group-by-age interaction, which contrast gives the group difference at age 70?
  4. What is the distinction between a sitewise \(p\)-value and a Benjamini–Hochberg-adjusted result?
  5. Name two diagnostics that could reveal problems with the usual linear-model inference.

Solutions. (1) The target group has an adjusted beta value 0.04 lower than the reference group, or 4 percentage points lower. (2) The inverse M-to-beta transformation is nonlinear, so the beta difference depends on the fitted baseline M value. (3) Substitute the centered age corresponding to 70 into the group main effect plus the interaction term, then use the full covariance matrix for the contrast standard error. (4) A sitewise \(p\)-value tests one site without accounting for the full collection of tests; the adjusted result accounts for the specified multiple-testing procedure and its error-rate target. (5) Residual-versus-fitted plots can expose variance or mean-model problems; residual quantile plots can reveal non-normality; leverage or influence checks can identify observations with undue impact.

Clinical Biostats