Integration Outputs Answer Different Questions
Mixed-model integration can produce several objects that are all described informally as “corrected data.” They are not interchangeable. An expression value standardized to a reference batch remains on an expression scale; a residual measures a cell’s deviation from a model prediction; and a latent coordinate locates a cell in a learned representation. Each is useful for different purposes, and each supports different comparisons.
This distinction matters when the scientific question concerns a biological contrast. For example, a difference in gene expression between conditions is not automatically estimated by comparing residuals or embedding coordinates. The target of inference must be stated first: a gene’s expected expression at a common batch and cell state, a cell’s deviation from its predicted value, or a geometric relationship among cells in a representation.
The equation is a schematic mean decomposition. In an actual analysis, \(m_g\) may include condition, state, and other measured covariates, while \(u_g\) may include gene-specific batch intercepts or state-dependent batch slopes. The form used must match the model and the expression scale. For example, an additive batch contribution on log-normalized expression is not automatically an additive contribution on the raw-count scale.
For a random batch effect, a typical assumption is that batch contributions arise from a distribution centered at zero, conditional on modeled covariates, with a specified variance structure. The cell-level errors must also follow the assumed conditional distribution closely enough for the intended prediction or inference. These assumptions do not make batch effects known: fitted random effects are estimates, and predictions using them carry uncertainty.
Expression-Scale Predictions and Their Estimands
Choose a reference batch \(b^\ast\), often one whose fitted contribution is set to zero or to a defined reference value. The model’s adjusted fitted expression for a cell with condition \(c\) and state \(s\) is \(\widehat{m}_g(c,s)+\widehat{u}_g(b^\ast,s)\). If the reference contribution is zero, this reduces to \(\widehat{m}_g(c,s)\). It is a fitted mean, not the cell’s observed expression with all cell-level variation retained.
A different expression-scale output is an observed value with the estimated batch contribution removed and the reference contribution added: \(y_{ig}-\widehat{u}_g(b_i,s_i)+\widehat{u}_g(b^\ast,s_i)\). This corrected observation retains the cell’s deviation from its fitted mean. It is therefore generally not equal to the fitted adjusted mean. Software may use “adjusted expression” for either kind of output, so the definition should be checked before interpreting or analyzing a matrix.
These outputs support different estimands. A fitted adjusted expression estimates a conditional mean at the chosen state and reference batch. A contrast between conditions at state \(s\) is \(\Delta_g(s)=m_g(c_1,s)-m_g(c_0,s)\). This is a state-conditional biological contrast on the modeled expression scale. To describe a population spanning several states, define weights \(w_s\), with \(w_s\geq 0\) and \(\sum_s w_s=1\), before averaging: \(\Delta_g^{(w)}=\sum_s w_s\{m_g(c_1,s)-m_g(c_0,s)\}\). The weights specify the target state distribution. Using each condition’s observed state proportions instead can mix within-state expression differences with differences in cell-state composition.
The reference batch sets a common expression-scale origin for adjusted predictions. If the same reference contribution is added to both conditions at a fixed state, it cancels in their contrast. Thus the contrast does not depend on that shared offset, although the adjusted expression levels do. This cancellation does not rescue a contrast that the data cannot identify: if condition and batch are fully confounded, the model cannot distinguish their contributions without additional information or assumptions.
Worked Example: Standardizing a Cell to a Reference Batch
Suppose a hypothetical gene is modeled on a log-normalized expression scale at a fixed cell state. The estimated biological mean is \(8.0\), the observed batch contribution is \(-0.4\), and the reference batch contribution is \(0\). One cell has observed expression \(8.2\). Calculate its fitted adjusted expression, its observed corrected expression, and its residual from the full fitted value.
The full fitted value in the observed batch is the biological mean plus that batch’s contribution: \(\widehat{y}^{\,\mathrm{fit}}=8.0+(-0.4)=7.6\). The fitted adjusted value at the reference batch is \(8.0+0=8.0\).
The observed corrected value removes the observed batch contribution: \(8.2-(-0.4)+0=8.6\). The residual from the full fitted value is \(8.2-7.6=0.6\). Equivalently, the corrected observation is the fitted adjusted value plus this residual: \(8.0+0.6=8.6\).
All three numbers have different meanings. The value \(8.0\) is the fitted mean at the reference batch; \(8.6\) retains this cell’s positive deviation; and \(0.6\) is that deviation alone. The corrected value is not evidence that the modeled biological mean is \(8.6\).
Residuals Are Deviations, Not Adjusted Expression Levels
A residual is defined relative to a particular fitted value. A conditional residual subtracts a fitted mean that includes the cell’s estimated batch contribution; a marginal residual may instead subtract a mean that averages over the batch-effect distribution. These answer different questions. The analysis must state which prediction was subtracted, especially when random effects are involved.
Under a correctly specified model, conditional residuals are intended to represent variation not explained by the included biological and batch terms. They can be useful for examining unexplained cell-level deviations or for model checking. They are not expression levels standardized to a common batch: subtracting the fitted biological mean as well as the batch contribution removes the modeled biological level too. A residual can be negative even when the gene’s expression is positive, because it is a difference from a prediction.
Worked Example: A Residual Does Not Measure a Condition Contrast
In a hypothetical state and batch, the fitted mean for condition 0 is \(5.0\), and the fitted mean for condition 1 is \(6.2\). The observed expression of one condition-0 cell is \(5.3\); that of one condition-1 cell is \(6.0\). Calculate the condition contrast in fitted means and the two residuals.
The fitted condition contrast is \(6.2-5.0=1.2\) expression units. The condition-0 residual is \(5.3-5.0=0.3\), and the condition-1 residual is \(6.0-6.2=-0.2\).
The residual difference for these two cells is \(-0.2-0.3=-0.5\), not \(1.2\). It describes the difference between their deviations from their respective predictions. The fitted means, not these residuals, encode the modeled condition contrast. Nor should two individual residuals be treated as an estimate of that contrast: they include cell-level variation and do not summarize uncertainty or replication.
Residuals can be centered around zero by construction or by model properties, but this does not mean they contain no structure. Patterns by batch, state, or fitted value may indicate that the chosen mean or variance structure is inadequate. Conversely, a residual matrix with weak batch structure is not by itself evidence that biological signal has been preserved: the biological mean was subtracted in forming the residuals.
Latent Coordinates Represent Geometry, Not Gene Expression
An integration method may also output a vector \(z_i\) for each cell, constructed from expression values and a fitted model or transformation. These coordinates are designed to represent cells in a lower-dimensional space. Nearby cells may be treated as similar under the method’s chosen geometry, which can support tasks such as neighborhood-based visualization or mapping. But a coordinate is not a gene’s adjusted expression, and a difference of one unit on an axis is not one expression unit.
Latent axes are often not uniquely identified. If a representation is transformed by an orthogonal rotation, pairwise Euclidean distances can remain unchanged while every coordinate changes. Consequently, the sign, orientation, and biological label of an individual axis may have no stable interpretation. Comparisons in latent space concern geometry under a specified fitted representation; gene-level claims require expression-scale quantities and an appropriate model.
Worked Example: Interpreting a Latent Distance
Suppose two hypothetical cells have two-dimensional latent coordinates \(z_A=(1,2)\) and \(z_B=(4,6)\). Their Euclidean distance is \(\sqrt{(4-1)^2+(6-2)^2}=\sqrt{9+16}=5\) coordinate units.
This calculation describes their separation in this particular representation. It does not say that either cell has five more expression units, nor does it identify which genes account for the separation. If the same embedding is rotated, the coordinates may change even though this distance remains 5. Interpreting the distance therefore requires the representation’s construction and scaling, not gene-expression units.
When Biological Comparisons Are Supported
An adjusted condition contrast is interpretable when the model separates condition and batch contributions using the design and assumptions at hand. In particular, there should be enough overlap to compare conditions across batches or other justified structure that identifies their effects. If every control cell is in batch A and every treated cell is in batch B, observed differences alone cannot determine which part is biological and which part is batch. A model can still return estimates, but those estimates depend on untestable restrictions rather than a direct separation in the data.
State conditioning also defines the target. A contrast at one fixed state asks about expression differences within that state, not changes in the abundance of the state. An average across states requires declared target weights. If condition changes the state composition, a within-state contrast and an overall difference answer distinct questions. Neither is automatically the uniquely correct biological summary.
A short derivation shows why a common reference-batch offset cancels from a within-state contrast. Under the additive model, adjusted fitted means are \(\widehat{m}_g(c_1,s)+\widehat{u}_g(b^\ast,s)\) and \(\widehat{m}_g(c_0,s)+\widehat{u}_g(b^\ast,s)\). Subtracting gives \[ \{\widehat{m}_g(c_1,s)+\widehat{u}_g(b^\ast,s)\} -\{\widehat{m}_g(c_0,s)+\widehat{u}_g(b^\ast,s)\} =\widehat{m}_g(c_1,s)-\widehat{m}_g(c_0,s). \] The equality requires the same reference contribution for both conditions at that state. If the batch effect is state-dependent, the state must be held fixed for this cancellation.
Worked Example: A State-Weighted Condition Contrast
For a hypothetical gene, fitted condition-1 minus condition-0 contrasts are \(2.0\) expression units in state A and \(-1.0\) unit in state B. A target population assigns weights \(0.75\) to state A and \(0.25\) to state B. Calculate the weighted contrast.
The weights are nonnegative and sum to one. Therefore, \(\Delta_g^{(w)}=0.75(2.0)+0.25(-1.0)=1.50-0.25=1.25\) expression units.
This is the contrast standardized to the stated target distribution, not the contrast in a population with some other state composition. If the weights were reversed, the result would be \(0.25(2.0)+0.75(-1.0)=0.50-0.75=-0.25\) expression units. The change in result reflects a different target population, not a change in either state-specific contrast.
Choosing an Output and Avoiding Common Errors
| Output | What it represents | Appropriate interpretation |
|---|---|---|
| Fitted adjusted expression | Predicted expression at a stated reference batch and covariate values | Gene-level means and contrasts defined by the model |
| Observed corrected expression | Observed expression with an estimated batch contribution replaced by the reference contribution | Cell-level expression-scale values that retain residual variation |
| Residual | Observed expression minus a specified fitted value | Unexplained deviation or model checking, not a biological expression level |
| Latent representation | Learned coordinates summarizing cells under a chosen geometry | Neighborhood or distance comparisons in that representation, not gene-wise effects |
A common mistake is to subtract the full fitted value, call the result “batch-corrected expression,” and then compare those residuals across conditions. The reasoning is wrong because the full fitted value includes the modeled biological mean as well as the batch term. The correction is to define the target first: use fitted means or observed values adjusted only for the batch contribution when the goal is expression-scale comparison, and use residuals when the goal is to study deviations from a specified model.
Another mistake is to infer a gene-level condition effect from separation in an embedding. An embedding’s geometry may aid exploration, but its axes are not gene-specific expression scales. Estimate gene-level contrasts from an expression-scale model that includes the relevant biological covariates and accounts for batch. No output can compensate for absent design overlap, an unsuitable mean structure, or an ambiguous target population.
Check Your Understanding
Answer each question, then compare with the solutions below.
- A fitted mean is \(7.0\), the observed batch contribution is \(0.5\), and the reference contribution is zero. An observed value is \(7.9\). Find the fitted adjusted expression, corrected observation, and conditional residual.
- Why is a residual of \(-0.4\) not evidence that a gene’s expression is negative?
- State one condition under which a fitted condition contrast cannot be separated from batch using the data alone.
- What does a Euclidean distance in a latent representation measure, and what does it not measure?
Solutions. 1. The fitted adjusted expression is \(7.0+0=7.0\). The corrected observation is \(7.9-0.5+0=7.4\). The conditional residual from the full fitted value \(7.0+0.5=7.5\) is \(7.9-7.5=0.4\). 2. A residual is observed expression minus a fitted prediction, so it can be negative even when both expression and its prediction are positive. 3. If all cells in one condition occur in one batch and all cells in the other condition occur in a different batch, the effects are confounded without additional identifying assumptions or information. 4. It measures separation under the specified embedding and its coordinate scaling; it is not a difference in gene-expression units or a gene-specific effect.