Why Partition Expression Variation?
A gene can vary across samples for several reasons: biological condition, technical batch, and sample-to-sample variation not captured by either factor. A gene-wise linear model gives a structured way to summarize how much of its observed variation is associated with each modeled source. These summaries help describe a dataset and assess whether batch is a substantial feature of expression. They do not, by themselves, establish that a source caused the variation or that the same source matters equally for every gene.
The earlier material on principal components provides a low-dimensional view of sample-level structure. A linear model answers a different question: for a particular gene, how much variation is associated with named design variables? A defensible answer depends on which samples were measured in which batches and conditions. When those variables overlap imperfectly, some variation may be shared rather than uniquely assignable.
Gene-Wise Model and Variation Summaries
Let \(Y_{gi}\) denote normalized, transformed expression for gene \(g\) in sample \(i\), with \(i=1,\ldots,n\). Consider a model with an intercept, batch, and biological condition:
Here \(b(i)\) and \(c(i)\) identify the batch and condition for sample \(i\). The terms \(\beta_{g,b(i)}\) and \(\gamma_{g,c(i)}\) represent gene-specific batch and condition effects; constraints such as effects summing to zero within each factor make the intercept and factor effects identifiable when the design permits it. In matrix form, the model is \(Y_g=X\theta_g+\varepsilon_g\), where \(Y_g\) is the vector of expression values for gene \(g\), \(X\) is the design matrix, and \(\theta_g\) contains the coefficients.
For descriptive least-squares fitting, the fitted values are the projection of \(Y_g\) onto the column space of \(X\). Define the total sum of squares around the gene's sample mean, the residual sum of squares, and the coefficient of determination as follows:
When \(\mathrm{SST}_g>0\), \(R_g^2\) is the fraction of that gene's centered sample variation captured by the fitted model. It is not the fraction of expression level explained, and it does not identify which factor is responsible unless the design supports a unique partition. If the fitted factor columns are orthogonal after accounting for the intercept, their sums of squares add without overlap. Otherwise, attribution requires a stated convention.
When Classical Tests Are Used
An \(F\)-test for a factor compares a reduced model that omits the factor with a full model that includes it. If the factor adds \(q\) independent columns to the design, the usual statistic is
The subscript \(R\) denotes the reduced fit and \(F\) the full fit; \(df_F\) is the full model's residual degrees of freedom. For the classical reference distribution \(F(q,df_F)\), the model errors must be independent, normally distributed with mean zero and a common variance, and the models must be nested with the stated rank difference. The factor being tested must add estimable columns. These assumptions concern inference, not the arithmetic of descriptive sums of squares. In expression data, departures from constant variance or independence can make classical p-values unreliable, so an \(F\)-test should not be treated as an automatic feature of every variance summary.
A short justification explains the ratio: under the null that the added factor contributes no effect, the reduction in residual sum of squares, divided by its degrees of freedom, and the full-model residual mean square estimate the same error variance. Their ratio then has the stated \(F\) distribution under the assumptions above. A large ratio indicates that the added factor reduces residual variation substantially relative to the estimated error variance; it is not the probability that the null hypothesis is true.
Worked Example: Orthogonal Batch and Condition Effects
Suppose one hypothetical gene has the following transformed expression values. There are two batches, two conditions, and two samples in each batch-condition cell.
| Batch | Condition | Expression values | Cell mean |
|---|---|---|---|
| A | Control | 8, 10 | 9 |
| A | Treated | 12, 14 | 13 |
| B | Control | 10, 12 | 11 |
| B | Treated | 14, 16 | 15 |
The grand mean is \(\bar{Y}_g=12\). The total sum of squares is
There are four samples in each batch, whose means are 11 and 13. Thus the batch sum of squares is \(4(11-12)^2+4(13-12)^2=8\). There are four samples in each condition, whose means are 10 and 14. The condition sum of squares is \(4(10-12)^2+4(14-12)^2=32\). Within each cell the two observations differ from the cell mean by 1 in opposite directions, so each cell contributes \(1^2+1^2=2\) to the residual sum of squares, giving \(\mathrm{RSS}_g=8\). The design is balanced and the batch and condition columns are orthogonal after accounting for the intercept; therefore these components add to the total: \(8+32+8=48\).
The fitted model has \(R_g^2=1-8/48=40/48=5/6\), or about 0.8333. For this gene, the batch, condition, and residual shares are respectively \(8/48=16.67\%\), \(32/48=66.67\%\), and \(8/48=16.67\%\). These are shares of this gene's observed variation in these hypothetical samples, not universal percentages for other genes or studies.
For the batch test, omitting batch while retaining condition gives \(\mathrm{RSS}_R=16\), so the added batch contribution is \(16-8=8\). The full model has rank 3 and \(df_F=8-3=5\). Thus \(F=(8/1)/(8/5)=5.00\), with an \(F(1,5)\) p-value of approximately 0.07559. At \(\alpha=0.05\), this is not statistically significant. For condition, the reduced model has \(\mathrm{RSS}_R=40\); hence \(F=(32/1)/(8/5)=20.0\), with an \(F(1,5)\) p-value of approximately 0.0066. Under the classical assumptions, the data provide evidence of a condition association for this gene after accounting for batch. This does not imply that condition caused the expression difference.
Attribution Depends on the Design
In a balanced crossed design, the batch and condition columns can be orthogonal, as in the example above. The named sums of squares then form a clean additive partition. In an imbalanced or associated design, the factors may share information about the response. One useful distinction is between sequential sums of squares, which measure the reduction in residual sum of squares as terms are entered in a specified order, and partial contributions, which measure the additional reduction from a term after the other specified terms are already included. Neither convention should be silently presented as a unique allocation of shared variation.
Worked Example: Sequential Contributions Change With Order
Consider a hypothetical gene measured in six samples, with expression \(Y_g=(1,2,3,4,5,6)\). Let batch be coded \(B=(0,0,0,1,1,1)\), and condition be coded \(C=(0,0,1,0,1,1)\). Both factors are represented, but their sample assignments are associated. The mean expression is 3.5 and \(\mathrm{SST}_g=17.5\).
After centering, the expression vector is \((-2.5,-1.5,-0.5,0.5,1.5,2.5)\). The centered batch vector is \((-0.5,-0.5,-0.5,0.5,0.5,0.5)\); its sum of squares is 1.5 and its inner product with centered expression is 4.5. Entering batch first therefore gives a sequential contribution of \(4.5^2/1.5=13.5\). Adding condition after batch increases explained sum of squares by 3.0.
Reversing the order, the centered condition vector is \((-0.5,-0.5,0.5,-0.5,0.5,0.5)\). Its sum of squares is 1.5 and its inner product with centered expression is 3.5, so condition entered first contributes \(3.5^2/1.5=49/6\), or about 8.167. Batch then adds \(16.5-49/6=25/3\), or about 8.333. In either order, the full model captures 16.5 of the total 17.5 and leaves \(\mathrm{RSS}_g=1\). But the sequential allocation differs: batch-first gives 13.5 to batch and 3.0 to condition, whereas condition-first gives about 8.333 to batch and 8.167 to condition. The data have not changed; only the allocation rule has.
This example shows why a reported “batch percentage” must state how it was calculated. A partial test of batch after condition answers whether batch adds information beyond condition in this model; it is not necessarily a unique share of all explained variation. Design imbalance alone does not always make effects impossible to estimate, but increasing overlap between factors can make their separate contributions unstable or difficult to interpret.
Worked Example: Duplicate Design Columns and Zero Residual Error
Suppose four hypothetical samples have expression values 5, 6, 9, and 10. The first two are in one condition and the last two in another; batch labels divide the samples in exactly the same way. A condition-only model fits group means 5.5 and 9.5. Each group contributes \(2(0.5^2)=0.5\) to the residual sum of squares, so \(\mathrm{RSS}_R=1\). The grand mean is 7.5, and \(\mathrm{SST}_g=2(2.5^2)+2(1.5^2)=17\).
Because batch and condition have identical indicator columns, adding batch to the condition model does not change fitted values: \(\mathrm{RSS}_F=1\). The two effects cannot be assigned separate unique contributions from these observations. The fitted model has the same column space as the condition-only model, and its rank does not increase by one.
For contrast, four observations can have two independent binary predictors and a full-rank model with an intercept and two predictors. If the values are \(1,2,3,4\) in the four combinations of those predictors, the additive model fits them exactly. The rank is 3, so the residual degrees of freedom are \(4-3=1\), not zero; nevertheless, \(\mathrm{RSS}_F=0\). The usual \(F\) ratio has a zero residual mean square in its denominator and is undefined or degenerate for these data. Positive residual degrees of freedom do not guarantee a usable finite \(F\) statistic.
Diagnostics, Alternatives, and Limits
Before interpreting a partition, check the design matrix and the gene-wise fits. Confirm that each factor has observed levels and that the model rank and residual degrees of freedom are as expected. Inspect condition and batch counts together: empty cells, highly unequal cell sizes, or one condition appearing mostly in one batch warn that the factors may share information. For individual genes, examine fitted values and residuals for unusual samples, strong outliers, and patterns that suggest unequal residual spread. A small residual sum of squares is not automatically reassuring if the model is too flexible or the number of replicates is limited.
There are several related summaries, each with a different purpose:
| Approach | What it summarizes | Main caution |
|---|---|---|
| Gene-wise \(R_g^2\) | Fraction of a gene's centered sample variation captured by the specified model | Does not allocate variation among predictors on its own |
| Sequential sums of squares | Incremental fit as terms enter in a chosen order | Contributions can change when the order changes |
| Partial model comparison | Whether a term adds fit given the other included terms | Tests a conditional contribution, not a unique additive share |
| Principal component plots | Major directions of sample-to-sample variation across many genes | Do not directly quantify a named factor's contribution for each gene |
A gene-wise analysis can reveal that batch is associated with expression for some genes and not others, but thousands of separate summaries do not automatically provide a genome-wide error-controlled conclusion. Nor does a large batch share establish that a technical process caused the observed pattern. The response scale matters too: sums of squares on a transformed expression scale describe variation on that scale, not on the original count scale. Finally, variance partitioning is descriptive of the observed design. If batch and biology are strongly entangled, no choice of summary can manufacture information the study did not collect.
Common Mistakes
- Using one partition formula without checking the design. Batch and condition sums of squares need not add to the model sum of squares when their design columns are correlated. State whether contributions are sequential or conditional.
- Calling \(R_g^2\) a batch effect. \(R_g^2\) summarizes all included terms together. A batch-specific claim requires a defined batch contribution or a model comparison.
- Interpreting a p-value as a probability that a factor has no effect. A p-value is calculated under the null model and assumptions; it is not the probability that \(H_0\) is true.
- Assuming residual degrees of freedom must be zero when a model fits perfectly. Rank determines residual degrees of freedom. A positive \(df_F\) can coexist with zero RSS, in which case the usual \(F\) ratio is not a finite usable statistic.
- Treating a large variance share as a causal conclusion. A model describes associations in the observed samples; interpretation depends on how samples were assigned and measured.
Check Your Understanding
Try each problem, then compare your reasoning with the brief solutions.
- In a balanced design, a gene has \(\mathrm{SST}_g=60\), batch sum of squares 12, condition sum of squares 30, and residual sum of squares 18. What are \(R_g^2\) and the three variation shares?
- Why can sequential batch sums of squares differ when batch is entered before condition rather than after condition?
- A full model has \(n=10\), rank 4, and RSS 12. Give its residual degrees of freedom and \(R_g^2\) if \(\mathrm{SST}_g=48\).
- If batch and condition have identical indicator columns, can their separate unique contributions be estimated from the data? Explain.
- What assumptions are needed to use the classical \(F(q,df_F)\) reference distribution for a nested-model test?
Solutions. (1) \(R_g^2=1-18/60=0.70\); the shares are \(12/60=20\%\) for batch, \(30/60=50\%\) for condition, and \(18/60=30\%\) residual. (2) When predictors are associated, they explain some of the same response variation, so the first term entered can receive variation that would otherwise be attributed to the second. (3) \(df_F=10-4=6\), and \(R_g^2=1-12/48=0.75\). (4) No. Identical columns do not add independent information, so their separate unique effects are not identifiable from this design. (5) The nested models must have the stated rank difference, the tested coefficients must be estimable, and errors must be independent, normally distributed with mean zero and a common variance under the model.