Why Diagnose a ComBat Adjustment?
ComBat estimates and adjusts known batch effects while allowing specified biological covariates to be retained. A completed adjustment is not, by itself, evidence that the fit is appropriate. An omitted biological covariate can be mistaken for batch, a poor design can make effects unidentifiable, and a model that fits imperfectly can leave batch structure in adjusted expression. Conversely, an adjustment can reduce a batch pattern by removing biological variation that should have been preserved.
The diagnostic task is therefore two-sided: look for residual batch structure after adjustment, and check whether the biological variation represented in the model remains visible. The introductory material on ComBat Empirical Bayes Batch Adjustment establishes the adjustment model and its empirical Bayes estimation; here the emphasis is on checking its specification and fit. Diagnostics are evidence about the fit, not a guarantee that all unwanted variation has been removed.
What the Diagnostics Assume
ComBat is applied to expression values on a suitable continuous, approximately Gaussian scale, commonly after appropriate normalization and transformation. It is not a procedure to apply directly to untransformed RNA-sequencing counts. For feature \(i\) in sample \(j\), a useful representation of the model is
Here \(Y_{ij}\) is the transformed expression value, \(X_j\) contains the biological covariates to preserve, \(b(j)\) is the batch containing sample \(j\), \(\gamma_{i,b(j)}\) is the feature-specific batch location effect, and \(\delta_{i,b(j)}\) is a positive batch scale factor. The error \(\epsilon_{ij}\) is modeled as having mean zero and variance one. The covariate and batch terms must be estimable from the observed design. In particular, the biological groups of interest cannot be completely confounded with batch if their effects are to be distinguished from batch effects.
In the standard parametric empirical Bayes version, standardized feature-level batch location effects within a batch are modeled with a normal prior, and the squared batch scale factors, or batch variance factors, are modeled with an inverse-gamma prior. These are assumptions across features that support shrinkage; they do not assert that every feature has identical batch effects. Diagnostics should assess whether the data appear broadly compatible with the working model and whether the adjustment behaves plausibly.
Before interpreting plots, check that samples have correctly assigned batch labels, that the covariates are recorded accurately, and that the expression matrix has been normalized and transformed appropriately. Confirm that the model matrix is full rank and that each biological group has representation across batches sufficient to distinguish group from batch. Independence of biological samples is also important: repeated or paired measurements need a design that reflects their dependence, rather than being treated as unrelated samples.
Check the Design Before the Plots
A covariate should be included because it represents biological variation that the analysis intends to retain, not merely because it is associated with the observed expression. Omitting a relevant group can cause ComBat to treat some of its expression differences as batch effects. Including a covariate that is redundant with batch does not solve confounding: the data still cannot determine which factor explains the difference.
For a quick design check, tabulate sample counts by batch and biological group, then inspect the model matrix for linear dependence. A crossed design, in which groups occur in multiple batches, generally provides more information to separate their effects than a design in which each batch contains only one group. Severe imbalance can still make estimates unstable even when the design is technically identifiable.
Worked Example: Checking Group Representation Across Batches
Suppose a hypothetical study has 12 samples in two batches and two biological groups. Batch A contains 4 controls and 2 treated samples; Batch B contains 2 controls and 4 treated samples. The intended model includes an intercept, a batch indicator, and a treated-group indicator.
Check representation. Both groups occur in both batches. Thus, group and batch are not completely confounded, and their effects can in principle be distinguished. The table also reveals imbalance: treated samples are more common in Batch B, so estimates may be less precise than in a balanced design.
Check the design dimension. There are 12 rows in the design matrix and three columns: an intercept, a batch indicator, and a group indicator. Because all four batch-group combinations occur, no one of these columns is an exact linear combination of the others. The matrix has rank 3, so these three coefficients are identifiable under this model.
If instead Batch A contained only controls and Batch B only treated samples, the batch indicator and group indicator would be identical (or exact complements, depending on coding). The matrix would not have rank 3. No diagnostic plot or empirical Bayes shrinkage can identify separate batch and treatment effects from that design. The correct conclusion is that their effects are confounded, not that the adjustment has successfully separated them.
Compare Expression Distributions Before and After Adjustment
Batch-stratified plots provide a direct check of feature-level behavior. For selected features, plot expression by batch before and after adjustment, ideally with biological groups indicated within each batch. Boxplots or dot plots can reveal persistent differences in location, spread, skewness, or outliers. Looking across a representative set of features is more informative than selecting only features that show the desired result.
Also inspect distributions across samples, such as sample-wise expression summaries and density plots, before and after adjustment. A substantial change in location or spread is not automatically a failure: removing estimated batch effects is intended to change these features. Instead, ask whether the adjusted values are plausible, whether batch differences have been reduced without erasing group contrasts, and whether a few samples or features are driving the apparent improvement.
Worked Example: Interpreting a Feature-Level Batch Plot
For a hypothetical feature measured in two batches, suppose the batch means before adjustment are 8.0 and 12.0 expression units. After adjustment, the corresponding means are 9.7 and 10.3 units. Assume that both batches contain the same biological-group composition for this comparison.
Before adjustment, the mean difference is \(12.0-8.0=4.0\) expression units. After adjustment, it is \(10.3-9.7=0.6\) expression units. The absolute difference has decreased by \(4.0-0.6=3.4\) units, or \(3.4/4.0=0.85\), an 85% reduction in this particular difference.
This is evidence that the batch mean contrast for this feature has been reduced; it is not proof that the fit is correct. The residual difference of 0.6 units may reflect remaining batch structure, sampling variation, or other features of the data. The same comparison should be made across features and alongside group-specific patterns. If the original difference included a biological contrast that was not represented in the model, its reduction could instead indicate overadjustment.
Use Principal Components as a Complementary Check
Principal components summarize major directions of variation across samples. Plotting samples using the first two or three components of the expression matrix before and after adjustment can show whether batch-associated clustering has weakened. Color points by batch and use a separate symbol or panel for the biological group. If adjusted samples still separate strongly by batch, that is a reason to investigate residual batch structure; if biological groups that were separated before adjustment collapse together, investigate whether meaningful biology was removed.
Principal components are summaries, not batch-effect tests. A batch pattern may remain in later components, and an apparent pattern in a low-dimensional plot may be driven by a small number of features or outliers. Conversely, overlapping batch colors on the first two components do not establish that all batch effects are absent. Interpret the plot together with feature-level checks and the study design.
Worked Example: Reading Batch and Group Patterns in a PCA Plot
Consider a hypothetical balanced study with two batches and two biological groups. Before adjustment, the mean PC1 score is \(-2.0\) for Batch A and \(2.0\) for Batch B, a batch difference of \(2.0-(-2.0)=4.0\) PC1 score units. After adjustment, the means are \(-0.4\) and \(0.4\), a difference of \(0.4-(-0.4)=0.8\) units. Suppose the group means on PC2 remain \(-1.5\) for controls and \(1.5\) for treated samples.
The PC1 batch difference has fallen by \(4.0-0.8=3.2\) units, an 80% reduction. The group difference on PC2 remains \(1.5-(-1.5)=3.0\) units in this summary. This pattern is consistent with reduced batch separation while group separation remains visible in the displayed components.
It does not prove that all batch effects are gone or that the group effect is preserved in every feature. Check additional components and feature-level plots, and verify that the group pattern is present within batches rather than being created by batch imbalance. PCA axes and their scores are descriptive summaries; their scales are not expression units.
Why the Adjustment Works Under Its Model
The standardization and adjustment clarify what a successful fit would do. Let \(\hat{\alpha}_i\), \(\hat{\beta}_i\), and \(\hat{\sigma}_i\) denote the fitted biological mean components and pooled feature scale used to form standardized values. For sample \(j\), define
If the fitted biological mean and pooled scale, as well as the batch parameters, equal their true values, then substituting the model gives \(z_{ij}=\gamma_{i,b(j)}+\delta_{i,b(j)}\epsilon_{ij}\). With the true batch location and scale, removing the location and dividing by the scale yields the standardized error:
The qualification about the biological mean and pooled scale matters. Correct batch parameters alone do not imply this equality. For example, if the fitted biological mean is too large by \(c\), while the pooled scale is correct, then the standardized value is shifted by \(-c/\sigma_i\). That discrepancy can remain after batch location and scale correction. In practice the parameters are estimated, so residual patterns can arise from model misspecification, estimation error, or both.
Common Failure Modes and Alternatives
- Reading batch overlap as proof of success. Overlap in a two-component PCA plot can hide residual structure elsewhere. Check multiple summaries and features.
- Ignoring biological composition. Batch means can differ because group proportions differ. Compare groups within batches where possible and retain appropriate biological covariates.
- Using an incomplete covariate model. An omitted biological factor may be absorbed into the estimated batch effect. Review the study question and design before interpreting an adjusted contrast.
- Assuming shrinkage fixes confounding. Empirical Bayes estimation stabilizes batch-effect estimates across features under its prior assumptions; it cannot recover effects that the design does not identify.
- Treating transformed values as counts. ComBat’s continuous-expression model is not a count model. Use the data scale and method appropriate to the analysis.
Alternative approaches answer different questions. Leaving data unadjusted avoids model-based changes but leaves known batch structure in the analysis. A feature-wise linear adjustment for known batch effects can be useful, but it does not provide ComBat’s across-feature empirical Bayes shrinkage. ComBat itself is appropriate only when its design and working assumptions are suitable. Principal components are useful diagnostics, not a replacement correction procedure. The choice should be guided by the design and the intended downstream analysis, not by which method produces the most visually attractive plot.
Check Your Understanding
Answer each question, then compare your reasoning with the solutions.
- Why can ComBat not separate treatment from batch if every control is in one batch and every treated sample is in another?
- After adjustment, the first two principal components show no visible separation by batch. Does this establish that no residual batch effect remains? Explain.
- A feature’s batch means are 5 and 9 units before adjustment and 6.5 and 7.5 units afterward. Calculate the before- and after-adjustment differences and describe what the result does and does not show.
- State the prior assumptions used by the standard parametric ComBat model for standardized batch location effects and batch scale effects.
Solutions. (1) Batch and treatment indicators are perfectly dependent in this design, so the model matrix is rank deficient and their separate effects are not identifiable. (2) No. A batch pattern may remain in later components or in particular features; the plot is one diagnostic, not proof of absence. (3) The differences are \(9-5=4\) units and \(7.5-6.5=1.0\) unit. The observed batch mean contrast is smaller after adjustment, but this alone does not prove correct adjustment or preservation of biology. (4) Standardized batch location effects within a batch follow a normal prior, and the squared batch scale factors (batch variance factors) follow an inverse-gamma prior.