Why Batch Effects Can Change More Than the Mean
A batch effect is not always a constant offset. For a molecular feature measured on two platforms, one platform might shift values upward, while also producing more variable measurements around the expected value. Removing the mean shift can align the centers of the batches but leave their spreads unequal. That remaining difference matters: it can distort comparisons of variability, affect uncertainty calculations, and cause downstream methods to treat noisy measurements as if they were equally precise.
The focus here is the feature-level distinction between a location effect, which changes a conditional mean, and a scale effect, which changes the conditional residual standard deviation. The model is useful only when biological signal can be distinguished from batch. As established in the earlier material on identifiability and batch-design connectivity, a batch difference cannot be uniquely separated from biology if the design does not provide the necessary overlap or controls.
This formulation treats the batch scale as acting on residual variation around the modeled biological signal and batch location. That distinction is important: simply dividing the entire measured value by a batch scale could also alter the biological component. A location-scale correction intended to preserve the fitted biological signal instead uses \(x_i^\top\beta_g+(Y_{igb}-x_i^\top\beta_g-\gamma_{gb})/\delta_{gb}\). The model does not by itself make the parameters identifiable; the design must support estimating biological and batch terms separately.
Estimating and Interpreting Location and Scale
For a particular feature, first account for the biological covariates that belong in the mean model. Within each batch, let \(\widehat{Y}_{igb}\) be the fitted value from that model, including the estimated batch location, and define the residual \(e_{igb}=Y_{igb}-\widehat{Y}_{igb}\). A residual variance estimate within batch \(b\) is $$ s_{gb}^2=\frac{\sum_{i\in b}e_{igb}^2}{n_b-r_b}, $$ where \(n_b\) is the number of samples in batch \(b\), and \(r_b\) is the rank of the fitted mean design for that batch. Thus \(n_b-r_b\) is the residual degrees of freedom. Under a correctly specified mean model with independent errors of common conditional variance within that batch, this is the usual unbiased residual variance estimate. If the design is unbalanced, use the rank of the actual fitted design rather than counting covariates informally.
After accounting for the mean, evidence that \(s_{gb}^2\) differs across batches is evidence of a possible scale effect. A ratio \(s_{g b_2}^2/s_{g b_1}^2\) compares estimated residual variances; its square root compares estimated residual standard deviations. With limited residual degrees of freedom, these are noisy diagnostic estimates, not precise measurements of the population variance ratio. Variance ratios can also be strongly affected by outliers, so inspect the residual distributions as well as the summaries.
Worked Example: Correct Residual Degrees of Freedom
Consider one feature measured in two batches, with two biological groups represented in each batch. The measurements are hypothetical. Batch A has group values \(9,11\) and \(19,21\); Batch B has \(8,12\) and \(18,22\). Fit a separate group mean within each batch. Estimate the within-batch residual variances and compare them.
Batch A. The fitted group means are \(10\) and \(20\). The residuals are \(-1,1,-1,1\), so the residual sum of squares is \(1+1+1+1=4\). Two group means are fitted to four observations, giving residual degrees of freedom \(4-2=2\). Therefore, $$ s_{gA}^2=\frac{4}{4-2}=\frac{4}{2}=2. $$
Batch B. Its fitted group means are also \(10\) and \(20\). The residuals are \(-2,2,-2,2\), with residual sum of squares \(4+4+4+4=16\). The residual degrees of freedom are again \(4-2=2\), so $$ s_{gB}^2=\frac{16}{4-2}=\frac{16}{2}=8. $$
The estimated residual variance ratio, Batch B to Batch A, is \(8/2=4\); the corresponding standard-deviation ratio is \(\sqrt{4}=2\). In this small hypothetical data set, Batch B has an estimated residual standard deviation twice that of Batch A after fitting the two group means. Each estimate uses only two residual degrees of freedom, so the ratio is a diagnostic signal with substantial uncertainty, not a precise population scale estimate.
Why Mean-Only Adjustment Leaves Heteroscedasticity
Heteroscedasticity means that conditional variances are unequal across groups or batches. The key algebra is simple: subtracting a constant changes a mean but does not change a variance. For a random variable \(Y\) and a constant \(c\), $$ \operatorname{Var}(Y-c)=E\{(Y-c-E[Y-c])^2\} =E\{(Y-E[Y])^2\} =\operatorname{Var}(Y). $$ Consequently, if the batch-specific fitted location is subtracted from each measurement, the residual variance remains \(\delta_{gb}^2\sigma_g^2\). A mean-only correction cannot equalize variances unless they were already equal.
In the previous example, subtracting each fitted group mean leaves residuals \(-1,1,-1,1\) in Batch A and \(-2,2,-2,2\) in Batch B. The residual sums of squares remain \(4\) and \(16\), and the residual variance estimates remain \(2\) and \(8\). The centers align, but the spread does not. This is why checking only batch means, or only a plot of batch averages, is not enough to assess correction.
Worked Example: Mean Alignment Does Not Equal Variance Alignment
Suppose a feature has a common fitted biological mean of \(50\) units in two batches. Batch A’s hypothetical measurements are \(48,52,48,52\), while Batch B’s are \(46,54,46,54\). Assume the biological mean is known from suitable controls or an adequately supported model. Calculate each residual variance using the residual mean as the only fitted mean parameter in that batch, then apply mean-only adjustment.
Both batch sample means are \(50\). Batch A residuals are \(-2,2,-2,2\), so the residual sum of squares is \(4+4+4+4=16\). One mean is fitted to four values, giving \(df=4-1=3\), and \(s_A^2=16/3=5.333\) squared measurement units.
Batch B residuals are \(-4,4,-4,4\), so its residual sum of squares is \(16+16+16+16=64\). Its residual degrees of freedom are also \(3\), giving \(s_B^2=64/3=21.33\) squared measurement units. The variance ratio is \((64/3)/(16/3)=4\), and the estimated standard-deviation ratio is \(2\).
Subtracting \(50\) from each measurement makes both adjusted sample means zero, but leaves residuals \(-2,2,-2,2\) and \(-4,4,-4,4\). The estimated variances therefore remain \(5.333\) and \(21.33\) squared units. Mean-only adjustment has removed no scale difference.
Diagnosing Location-Scale Patterns
A useful diagnostic compares batches after accounting for the biological mean structure, not just in the raw pooled data. A batch with a different mix of biological groups can have a different raw mean or variance even if its conditional batch effects are identical. The following checks are complementary:
- Compare adjusted residual centers. Batch-specific residual averages or robust center summaries can reveal remaining location shifts. A systematic center difference suggests that the mean model or location adjustment may be inadequate.
- Compare adjusted residual spreads. Plot residuals by batch and compare residual standard deviations, variances, or robust spread summaries. A wider residual cloud in one batch, repeated across relevant samples, supports a scale concern.
- Check the biological strata and design. Where sample size permits, examine spreads within comparable biological groups or after fitting the same biological covariates. Otherwise, biological composition may be mistaken for a batch scale effect.
- Inspect shape and outliers. A variance difference driven by one extreme observation is not the same pattern as a consistent change in spread. Look for skewness, heavy tails, multimodality, and influential samples.
- Check feature behavior across the data range. If spread increases with the mean or differs systematically with intensity, a single batch scale multiplier may be inadequate. A transformation or a mean-dependent variance model may be more appropriate, provided it is scientifically defensible.
A scale ratio is interpretable only in the context of its uncertainty and the model used to obtain it. With few samples, variance estimates can vary greatly from sample to sample. For inferential claims about unequal variances, use a method appropriate to the design and distributional assumptions; do not treat a large sample variance ratio alone as proof of a technical cause. Earlier material on residual checks and technical replicates provides useful context for separating residual patterns from measurement noise and for assessing whether the available observations support that separation.
Worked Example: A Residual-Spread Diagnostic
Suppose a hypothetical negative-control feature has already been centered for its expected biological signal. Its residuals are \(-2,0,0,2\) in Batch A and \(-4,0,0,4\) in Batch B. There are no fitted batch-specific mean parameters left to estimate in this diagnostic, so use the sample variance with \(n-1=3\) degrees of freedom. Compare the centers and spreads.
Both residual means equal zero: each set sums to zero, and each has four observations. For Batch A, the residual sum of squares is \(4+0+0+4=8\), so \(s_A^2=8/3=2.667\) squared units. For Batch B, it is \(16+0+0+16=32\), so \(s_B^2=32/3=10.67\) squared units. The estimated variance ratio is \((32/3)/(8/3)=4\), and the estimated standard-deviation ratio is \(2\).
The matching centers and larger spread in Batch B are consistent with a scale difference for this feature. However, the sample is small, and the four residuals do not establish a general batch mechanism. A useful next diagnostic would examine other controls and features, and check whether the same pattern appears after accounting for the relevant biological structure.
Assumptions, Alternatives, and Limits
The location-scale representation is most useful when the conditional mean model is adequate, the batches are identifiable separately from biology, and the residuals within a batch are sufficiently comparable for a variance estimate to be meaningful. The variance formula requires finite variances; the usual unbiased residual variance interpretation also relies on an appropriate mean model and error structure. Normality is not required for the algebraic identity that subtraction leaves variance unchanged, but it is often assumed by small-sample procedures for formal variance comparisons. If residuals are dependent, the simple degrees-of-freedom calculation and standard uncertainty arguments may not apply.
A common working assumption is that batches differ by a location and a multiplicative scale while the standardized residual distribution is otherwise similar. Equalizing variances does not guarantee equal distributions: skewness, tail behavior, or multimodality can remain different after rescaling. Conversely, different estimated variances may reflect outliers, unequal biological composition, or a misspecified mean model rather than a genuine technical scale effect.
The main alternatives address different goals:
| Approach | What it addresses | Main caution |
|---|---|---|
| Mean-only adjustment | Shifts conditional centers across batches. | Does not change residual variances. |
| Location-scale adjustment | Targets both conditional centers and residual spreads. | Requires scale estimates supported by the design; may alter real biological variability if the model is wrong. |
| Variance-aware analysis model | Allows unequal residual variances when estimating effects or uncertainty. | Does not necessarily harmonize values for a shared downstream data matrix. |
| Reference-based calibration | Uses comparable reference material to assess or align measurement scales. | Calibration is limited by the reference’s representativeness and measurement precision. |
A location-scale adjustment is not a substitute for design information. When batch and biology are perfectly confounded, the observed difference cannot determine which component is biological and which is technical. Even with overlap, small batches may yield unstable scale estimates. Scaling also changes the magnitude of deviations from the fitted biological mean, so it can suppress real biological heterogeneity if that variability differs across batches for genuine reasons. The later material on empirical-Bayes adjustment develops a particular estimation strategy; the key prerequisite here is recognizing when the data show a plausible scale component and when such a component is not identifiable or reliably estimable.
Common Pitfalls
- Wrong: “The batch means match after centering, so the batches have been harmonized.” Correction: Centering leaves variance unchanged; compare adjusted residual spreads as well as centers.
- Wrong: Divide a residual sum of squares by the number of observations without considering fitted parameters. Correction: Use the residual degrees of freedom \(n_b-r_b\). For four observations with two fitted group means, that is \(4-2=2\), not \(3\).
- Wrong: Interpret an observed variance ratio as proof that the platform caused the difference. Correction: Treat it as a diagnostic under the fitted model; consider biological composition, outliers, dependence, and estimation uncertainty.
- Wrong: Assume variance standardization makes the entire residual distributions identical. Correction: It aligns a second-moment measure under the model, but may leave differences in shape or tails.
Check Your Understanding
Try each problem, then compare your reasoning with the solutions below.
- A batch has six observations, and a separate intercept and two biological group effects are fitted with a design-matrix rank of three. What are the residual degrees of freedom?
- Two batches have adjusted residual variance estimates of \(3\) and \(12\) squared units. Give the variance ratio and the standard-deviation ratio, comparing the second batch with the first.
- Why does subtracting a batch-specific constant not remove a batch-specific variance difference?
- After mean adjustment, one batch has a much larger variance estimate, but that estimate is based on two residual degrees of freedom and one extreme residual. What is a cautious interpretation and a useful diagnostic follow-up?
Solutions. (1) The residual degrees of freedom are \(n_b-r_b=6-3=3\). (2) The variance ratio is \(12/3=4\), and the standard-deviation ratio is \(\sqrt{4}=2\); the second batch’s estimated residual standard deviation is twice the first’s. (3) For a constant \(c\), \(\operatorname{Var}(Y-c)=\operatorname{Var}(Y)\), so subtracting a location shift leaves the spread unchanged. (4) The estimate suggests a possible scale difference but is highly uncertain and may be driven by the extreme value. Inspect the residuals, check the relevant biological strata and sample quality, and seek additional controls or observations before treating it as a stable batch effect.