Tutorials › Multi-Omics Data Integration › Uncertainty in Estimated Batch Corrections

Batch Effects and Confounding Across Cohorts · Tutorial 121 of 597

Uncertainty in Estimated Batch Corrections

Learn to quantify uncertainty in batch-adjustment estimates and propagate it into corrected feature comparisons without mistaking a precise-looking correction for a well-supported one.

Advanced 11 min read

What You'll Learn

  • Construct a confidence interval for a batch shift estimated from paired bridge samples.
  • Propagate correction uncertainty into a biological contrast, including covariance when estimates are dependent.
  • Choose a resampling unit that respects pairing, clustering, and the batch design.
  • Diagnose unstable corrections and distinguish parameter uncertainty from residual variation.
  • Explain why correction cannot resolve batch–biology confounding or weak overlap.

Why an Estimated Correction Is Not Exact

A batch correction is calculated from data, so its estimated parameters are uncertain. If a feature is shifted upward in one batch, subtracting the estimated shift produces adjusted values; it does not make the shift known without error. This distinction matters when comparing biological groups: uncertainty in the correction can make an adjusted contrast much less precise than its point estimate suggests.

The introductory material on location-scale batch effects and ComBat established common ways to represent batch differences and adjust feature values. Here the focus is narrower: how to quantify uncertainty in the fitted adjustment and carry it through to an adjusted feature comparison. An interval describes uncertainty under a specified model and design. It cannot recover information absent from the data, such as a biological contrast that is inseparable from batch.

Model-Based Uncertainty

For one feature, a simple location model is \(y_i=\mu+\gamma_{b(i)}+\epsilon_i\), where \(y_i\) is the measured feature value for sample \(i\), \(\mu\) is a reference level, \(\gamma_{b(i)}\) is the shift for that sample’s batch relative to the reference batch, and \(\epsilon_i\) is residual variation. A model may also include biological covariates. The correction for a non-reference batch subtracts its estimated shift, \(\hat{\gamma}_b\), from that batch’s values.

Definition: The standard error of an estimated batch parameter measures its sampling variability under the fitted model. A confidence interval for \(\gamma_b\) is an interval procedure that, under the model and repeated sampling, covers the fixed parameter at its stated rate. It is an interval for the batch parameter, not a probability statement about the parameter after observing the data.

In a linear model \(y=X\beta+\epsilon\), suppose the design matrix \(X\) has full column rank and the errors are independent with \(\epsilon\sim N(0,\sigma^2I)\). The least-squares estimate is \(\hat{\beta}=(X^\mathsf{T}X)^{-1}X^\mathsf{T}y\), and its estimated covariance matrix is \(\widehat{\mathrm{Var}}(\hat{\beta})=s^2(X^\mathsf{T}X)^{-1}\), where \(s^2\) is the residual mean square. If the batch shift is a coefficient or a linear combination of coefficients, its standard error follows from this covariance matrix. For a contrast \(a^\mathsf{T}\beta\), the estimated standard error is \(SE=s\sqrt{a^\mathsf{T}(X^\mathsf{T}X)^{-1}a}\); under the stated Gaussian model, a two-sided \(100(1-\alpha)\%\) interval is \(\hat{\theta}\pm t_{1-\alpha/2,df}SE\), with \(\hat{\theta}=a^\mathsf{T}\hat{\beta}\) and residual degrees of freedom \(df\).

These formulas rely on a correctly specified mean structure, independent errors with a common variance, full-rank design, and Gaussian errors for the exact \(t\)-interval. If observations are paired, clustered, heteroscedastic, or otherwise dependent, the corresponding covariance model or resampling scheme must reflect that structure. A narrow interval obtained from a model that treats dependent samples as independent can be misleading.

Worked Example: A Shift Estimated From Bridge Samples

Suppose five hypothetical bridge specimens are measured in both Batch A and Batch B. For a feature measured in log2 abundance units, their paired differences \(d_k=y_{kB}-y_{kA}\) are 1.0, 1.4, 0.8, 1.2, and 1.6. Assume the specimens are independent of one another, each pair is measured under the same conditions apart from batch, and the differences are normally distributed with a common mean shift.

The estimated Batch B shift relative to Batch A is the mean paired difference:

$$ \hat{\gamma}_B=\bar{d}=\frac{1.0+1.4+0.8+1.2+1.6}{5}=1.20\text{ log2 units}. $$

The deviations from 1.20 are \(-0.20,0.20,-0.40,0,0.40\). Thus their squared sum is \(0.04+0.04+0.16+0+0.16=0.40\), and the sample variance is \(s_d^2=0.40/(5-1)=0.10\). The standard deviation is \(s_d=\sqrt{0.10}=0.3162\) log2 units, giving \(SE(\hat{\gamma}_B)=s_d/\sqrt{5}=0.1414\) log2 units.

With \(df=4\), \(t_{0.975,4}=2.776\). The 95% interval is \(1.20\pm2.776(0.1414)=1.20\pm0.3926\), or \([0.8074,1.593]\) log2 units. Under the paired normal model, this procedure has 95% coverage over repeated samples of bridge specimens. It does not imply a 95% probability that this particular fixed shift lies in this observed interval.

How Correction Uncertainty Affects a Feature Comparison

An adjusted biological contrast is often a function of both the observed feature contrast and one or more estimated batch parameters. Its uncertainty must account for all estimated quantities in that function. For a simple case, let \(\hat{\delta}_{raw}\) be an unadjusted group contrast and let \(\hat{\gamma}\) be the estimated batch difference that must be removed from it. The adjusted estimate is \(\hat{\theta}=\hat{\delta}_{raw}-\hat{\gamma}\). Its variance is

$$ \mathrm{Var}(\hat{\theta})=\mathrm{Var}(\hat{\delta}_{raw})+\mathrm{Var}(\hat{\gamma})-2\mathrm{Cov}(\hat{\delta}_{raw},\hat{\gamma}). $$

If the two estimates come from independent data, the covariance term is zero. If they use overlapping samples or are fitted together, it generally need not be zero. In a joint linear model, the direct approach is to define the adjusted comparison as a contrast \(a^\mathsf{T}\beta\) and use the full estimated covariance matrix of \(\hat{\beta}\). This automatically retains covariance among the biological and batch coefficients.

Worked Example: A Wide Interval After Adjustment

In a hypothetical analysis, the raw difference between two biological groups is estimated as \(\hat{\delta}_{raw}=0.70\) log2 units with \(SE=0.18\). An independent set of bridge measurements gives a batch shift estimate \(\hat{\gamma}=0.40\) log2 units with \(SE=0.25\). Assume the estimates are independent and that a normal approximation is suitable for this illustration.

The adjusted contrast is \(0.70-0.40=0.30\) log2 units. Independence gives \(SE(\hat{\theta})=\sqrt{0.18^2+0.25^2}=\sqrt{0.0324+0.0625}=\sqrt{0.0949}=0.3081\) log2 units.

A 95% normal-approximation interval is \(0.30\pm1.96(0.3081)=0.30\pm0.6039\), or \([-0.3039,0.9039]\) log2 units. The adjusted point estimate is positive, but the interval includes zero and also allows effects in either direction. The correction has materially increased uncertainty: reporting only the adjusted point estimate would conceal how imprecisely the comparison is determined.

The independence assumption is essential to the variance calculation. If the bridge specimens were also used to estimate the raw group contrast, the two estimates could be correlated; the covariance term would then have to be included, or the entire analysis could be fitted jointly.

Resampling the Correction Procedure

When a reliable analytic standard error is unavailable, resampling can approximate sampling variability. A bootstrap replicate is made by sampling the independent observational units with replacement, refitting the batch model, and recalculating the correction or adjusted contrast. The spread of replicate estimates approximates sampling uncertainty, while their empirical quantiles can form a percentile interval.

The resampling unit must match the sampling design. For paired bridge measurements, resample specimen pairs together, not each batch measurement separately. For repeated observations from one person, resample people or clusters rather than individual rows. If the target is generalization to new cohorts, resampling only samples within the observed cohorts does not represent between-cohort variation. With very few cohorts, resampling cohorts may itself be unreliable.

1
Choose the target.
Decide whether uncertainty concerns a batch parameter, an adjusted feature contrast, or both. State the population or sampling process to which the interval is intended to apply.
2
Resample valid units.
Sample independent specimens, paired bridges, or clusters in a way that preserves the observed design and dependence.
3
Repeat the full estimation.
Refit the batch model and redo the correction in every replicate. If the target is an adjusted contrast, recalculate that contrast in the same replicate.
4
Summarize and diagnose.
Use the bootstrap distribution to estimate a standard error or interval, and check for failed fits, extreme estimates, or strong asymmetry.

Worked Example: A Bootstrap Interval for a Batch Shift

Suppose 1,000 hypothetical bootstrap replicates are produced by resampling independent bridge specimens as pairs and refitting the batch-shift estimate each time. The original estimate is \(\hat{\gamma}=0.52\) log2 units. The 25th and 975th ordered replicate estimates are 0.12 and 0.93 log2 units, respectively. Using these empirical 2.5th and 97.5th percentiles gives a 95% percentile interval of \([0.12,0.93]\) log2 units.

The interval is asymmetric around 0.52: the lower distance is \(0.52-0.12=0.40\), while the upper distance is \(0.93-0.52=0.41\), which is nearly symmetric in this example. These endpoints summarize the resampled estimation distribution; they are not a guarantee that the bootstrap has captured every source of uncertainty. In particular, resampling bridge specimens does not quantify uncertainty from an incorrect batch model or from a lack of overlap between batch and biology.

Diagnostics, Alternatives, and Limits

Useful diagnostics focus on whether the uncertainty calculation reflects the information in the design and whether the fitted model behaves plausibly. Examine standard errors and interval widths across features, the distribution of bootstrap estimates, sensitivity to individual bridge specimens, and whether resamples frequently produce singular or unstable fits. An interval that changes sharply when one specimen is removed suggests that the correction is influential and weakly supported. Residual patterns or unequal variability may indicate that the model-based covariance assumptions need reconsideration.

Model-based intervals are efficient and interpretable when the mean and covariance assumptions are defensible. Bootstrap intervals can better accommodate skewness or complicated fitting procedures, but they require enough independent sampling units and a resampling design that mirrors the intended sampling process. Neither approach automatically accounts for uncertainty in a chosen model specification. A sensitivity analysis across plausible specifications can reveal that instability, but it is not a substitute for a correctly defined sampling model.

Empirical-Bayes adjustments can stabilize feature-specific estimates by sharing information across features. An interval conditional on estimated prior or hyperparameters may understate uncertainty if those quantities are treated as fixed. A bootstrap that refits the empirical-Bayes procedure can capture more of this estimation variability, provided the resampling and fitting steps are appropriate. This does not remove the need to examine model assumptions.

Key distinction: Uncertainty quantification describes how precisely a correction or adjusted contrast is estimated under its assumptions. It does not establish that the correction is biologically appropriate, remove residual batch signal, or identify a biological effect when batch and biology are confounded.

A common mistake is to correct every value using \(\hat{\gamma}\), then calculate a downstream standard error as though \(\hat{\gamma}\) were fixed. That calculation omits the correction’s estimation uncertainty and can yield intervals that are too narrow. The correction is not a constant supplied by nature: include its variance and any relevant covariance, or refit the whole procedure within each valid resample. When overlap is inadequate, the honest result may be a wide interval or an explicitly non-identifiable contrast, not a more elaborate correction.

Check Your Understanding

Answer each question, then compare your reasoning with the solutions.

  1. In a paired bridge analysis, why should the two measurements from one specimen be resampled together?
  2. An adjusted contrast is \(\hat{\delta}_{raw}-\hat{\gamma}\). What additional term is required in its variance if the two estimates are dependent?
  3. Why can an adjusted point estimate be scientifically uninformative when its interval is wide?
  4. Does a narrow bootstrap interval prove that batch and biology were not confounded? Explain.

Solutions. (1) The two measurements share a specimen and are dependent; resampling them separately breaks the pairing and misrepresents the sampling design. (2) Include \(-2\mathrm{Cov}(\hat{\delta}_{raw},\hat{\gamma})\) in \(\mathrm{Var}(\hat{\delta}_{raw}-\hat{\gamma})\). (3) The estimate may be compatible with a range of effects, including effects in the opposite direction; precision and direction cannot be judged from the point estimate alone. (4) No. A bootstrap interval reflects the variation represented by its resampling scheme and fitted model. It cannot create information to separate batch from biology when the design lacks the required overlap.

Clinical Biostats