Why Audit the Design Matrix?
A batch-adjusted analysis can only separate batch differences from condition differences to the extent that the study design contains the comparisons needed to distinguish them. A design-matrix audit makes that structural information explicit before fitting a model. It can reveal redundant columns, show whether the model coefficients are uniquely determined by the design, and identify effects that can still be expressed as functions of the observed data.
The audit concerns the arrangement of samples across batches and conditions, not the values of their expression measurements. The same design matrix is used for every gene if the sample layout is the same. A rank problem therefore cannot be fixed by choosing a different gene or by changing the measured expression values.
Set Up the Model and Coding
Suppose \(y_i\) is a response for sample \(i\), such as a transformed expression summary, \(b_i\) identifies one of three batches, and \(c_i\) identifies one of two conditions. For this audit, use an additive fixed-effects model: each sample's mean response is the sum of an intercept, a batch effect, and a condition effect, with no batch-by-condition interaction.
Here batch \(B_1\) and condition \(A\) are reference levels. The indicator \(I(\cdot)\) equals 1 when its statement is true and 0 otherwise. Thus \(\beta_0\) is the mean for batch \(B_1\), condition \(A\); \(\beta_2\) and \(\beta_3\) are batch differences from \(B_1\) at the reference condition in this additive model; and \(\gamma\) is the condition \(B\)-versus-\(A\) difference shared across batches by the model. The design matrix \(X\) has one row per sample and four columns: an intercept, the \(B_2\) indicator, the \(B_3\) indicator, and the condition \(B\) indicator. In matrix notation, the systematic part of the model is \(X\beta\).
The algebraic audit does not require normally distributed errors. For inferential conclusions from a linear model, however, the response model and its error assumptions must also be appropriate. In particular, samples should represent independent experimental units for the intended analysis, and the additive model must be a defensible description of their mean response. A full-rank matrix cannot establish independence or validate the no-interaction assumption.
A Short Rank and Estimability Justification
For a fixed design, the fitted mean vector is \(X\beta\). If a nonzero vector \(v\) satisfies \(Xv=0\), then \(X(\beta+v)=X\beta\): changing coefficients in that direction leaves every fitted mean unchanged. This is why redundant columns prevent unique recovery of all coefficients. Conversely, if the columns are linearly independent, \(Xv=0\) implies \(v=0\), so two coefficient vectors giving the same fitted means must be identical.
A linear combination \(q^\mathsf{T}\beta\) is called estimable if the design determines its value even when it does not determine every coefficient separately. One useful criterion is that \(q^\mathsf{T}\) must be a linear combination of the rows of \(X\). If \(q^\mathsf{T}=a^\mathsf{T}X\) for some vector \(a\), then
so the target is a specified combination of the fitted means. This criterion is useful in an audit: it prevents the mistaken conclusion that a rank-deficient model contains no estimable information at all. It may identify a combination of effects even when the individual effects involved are not separately determined.
Worked Example: All Six Batch-Condition Combinations Are Represented
Consider one hypothetical independent sample in each of the six combinations of three batches and two conditions. The response values are illustrative, not from a real study.
| Batch | Condition | Response \(y\) | Intercept | \(B_2\) | \(B_3\) | Condition \(B\) |
|---|---|---|---|---|---|---|
| \(B_1\) | A | 5 | 1 | 0 | 0 | 0 |
| \(B_1\) | B | 8 | 1 | 0 | 0 | 1 |
| \(B_2\) | A | 6 | 1 | 1 | 0 | 0 |
| \(B_2\) | B | 10 | 1 | 1 | 0 | 1 |
| \(B_3\) | A | 7 | 1 | 0 | 1 | 0 |
| \(B_3\) | B | 12 | 1 | 0 | 1 | 1 |
The four columns are independent. For example, subtracting the \(B_1,A\) row from the \(B_2,A\) and \(B_3,A\) rows isolates the two batch indicators; subtracting the \(B_1,A\) row from the \(B_1,B\) row isolates the condition indicator. Together with the intercept row, these give rank 4, so the matrix has full column rank.
For these equally represented cells, the least-squares coefficient estimates are \(\hat{\beta}_0=4.5\), \(\hat{\beta}_2=1.5\), \(\hat{\beta}_3=3\), and \(\hat{\gamma}=4\). For example, the reference-batch condition difference is \(8-5=3\), and averaging the two condition differences within each batch gives \((3+4+5)/3=4\). The fitted response for \(B_2,A\) is \(4.5+1.5=6\); for \(B_3,B\), it is \(4.5+3+4=11.5\). Because there are six observations and rank 4, the residual degrees of freedom are \(6-4=2\). Full rank permits separate coefficient estimates, but this small residual degrees of freedom still limits assessment of residual variation.
Worked Example: The Condition Indicator Duplicates a Batch Indicator
Now suppose the hypothetical sample layout has condition \(A\) in batches \(B_1\) and \(B_2\), and condition \(B\) in batch \(B_3\), with no other combinations. Specifically, all and only the samples from \(B_3\) are in condition \(B\). Consider one sample per represented combination, with responses 5, 7, and 11.
| Batch | Condition | \(y\) | Intercept | \(B_2\) | \(B_3\) | Condition \(B\) |
|---|---|---|---|---|---|---|
| \(B_1\) | A | 5 | 1 | 0 | 0 | 0 |
| \(B_2\) | A | 7 | 1 | 1 | 0 | 0 |
| \(B_3\) | B | 11 | 1 | 0 | 1 | 1 |
For every sample in this specified layout, the condition \(B\) indicator equals the \(B_3\) indicator. The last two columns are duplicates, so the four-column matrix has rank 3, not 4. This equality depends on the stated layout: it would not hold if even one \(B_3,A\) sample were present.
The model's fitted means are \(\beta_0\) for \(B_1,A\), \(\beta_0+\beta_2\) for \(B_2,A\), and \(\beta_0+\beta_3+\gamma\) for \(B_3,B\). The responses therefore determine \(\hat{\beta}_0=5\), \(\hat{\beta}_2=7-5=2\), and the combined quantity \(\hat{\beta}_3+\hat{\gamma}=11-5=6\). They do not separately determine \(\beta_3\) and \(\gamma\). For instance, \(\beta_3=1,\gamma=5\) and \(\beta_3=4,\gamma=2\) give the same observed fitted means. The observable difference of 6 response units between the \(B_3,B\) and \(B_1,A\) groups is not, on this design alone, a separate batch effect or a separate condition effect.
Worked Example: A Missing Cell Does Not Automatically Mean Redundancy
Consider a different hypothetical layout, with no \(B_1,B\) or \(B_3,A\) samples, but with both conditions represented in \(B_2\). The four observed samples have responses 8, 10, 13, and 14.
| Batch | Condition | \(y\) | Intercept | \(B_2\) | \(B_3\) | Condition \(B\) |
|---|---|---|---|---|---|---|
| \(B_1\) | A | 8 | 1 | 0 | 0 | 0 |
| \(B_2\) | A | 10 | 1 | 1 | 0 | 0 |
| \(B_2\) | B | 13 | 1 | 1 | 0 | 1 |
| \(B_3\) | B | 14 | 1 | 0 | 1 | 1 |
The rows are linearly independent. Subtract the first row from the second to obtain the \(B_2\) direction; subtract the second from the third to obtain the condition \(B\) direction; and subtract the first from the fourth to obtain a row with \(B_3\) and condition \(B\) entries, which, together with the condition direction, isolates \(B_3\). Thus rank is 4. The least-squares estimates fit these four responses exactly: \(\hat{\beta}_0=8\), \(\hat{\beta}_2=10-8=2\), \(\hat{\gamma}=13-10=3\), and \(\hat{\beta}_3=14-8-3=3\).
This matrix is full rank despite two absent cells, but it has four observations and four independent columns, so its residual degrees of freedom are \(4-4=0\). The coefficients are uniquely determined under the specified additive model; these data alone provide no residual degrees of freedom for estimating the model's residual variance. The example also shows why an audit must inspect the actual columns rather than infer redundancy simply from a blank cell.
A Practical Audit Workflow
Use the same systematic checks for each proposed batch-adjusted model. Keep the sample rows fixed while constructing every indicator; a coding error can create or hide an apparent design problem.
Tabulate the number of samples in each batch-condition combination. Confirm that each row of the planned matrix corresponds to the intended experimental unit.
State the reference batch and condition, list the columns, and make clear whether the model is additive. Do not silently change the reference levels or include interaction columns.
Look for duplicate columns or exact linear combinations, then compute the matrix rank. Compare rank with the number of columns to determine whether all coefficients are uniquely identified.
If the matrix is rank deficient, identify the redundant columns and any directly supported coefficient combinations. If it is full rank, check residual degrees of freedom and consider whether the design supports the intended interpretation.
Diagnostics, Comparisons, and Limitations
A cross-tabulation of batch by condition is a quick first diagnostic; the design matrix is the definitive algebraic check for the stated coding. Software may report a dropped coefficient, a singular fit, or a non-estimable term when columns are redundant. Those messages should be traced back to the sample layout and matrix columns, not treated as evidence that a particular biological effect is zero.
Treatment coding, as used here, makes coefficients comparisons with reference levels. Other full-rank codings, such as sum coding, can produce different coefficient values while spanning the same model space. The rank of a correctly recoded design does not change. A separate issue arises if an intercept and indicators for every level of a factor are included together: those columns are redundant because the level indicators sum to the intercept column. Choose a consistent coding scheme rather than interpreting software's automatic removal of a column as a scientific result.
A structural rank calculation and a numerical rank calculation are not always identical in practice. With very large or poorly scaled design entries, numerical software may use a tolerance to decide whether a column is effectively dependent. For the binary indicators in these examples, the dependencies are exact and visible. A near-dependency is a different problem from an exact duplicate and should not be described as perfect confounding.
The audit's conclusions are conditional on the model that was written down. In particular, an additive model imposes a common condition effect across batches. If that assumption is inappropriate, the displayed design matrix is not the matrix for the intended model. Also, full rank is not proof of adequate replication, low uncertainty, representative sampling, or causal identification. It only answers a linear-algebra question about whether the specified coefficients can be separated under the specified model.
Common Mistakes
- Equating a condition indicator with a batch indicator from a one-way implication. Saying that condition \(B\) occurs only in \(B_3\) means there are no condition \(B\) samples elsewhere; it does not rule out \(B_3,A\) samples. The indicators are identical only when all and only \(B_3\) samples are condition \(B\).
- Calling every missing cell perfect confounding. A missing combination can leave enough independent rows for full column rank, as the third example shows. Check the actual matrix.
- Assuming rank deficiency means no effects are estimable. Some coefficients or combinations, such as \(\beta_3+\gamma\) in the second example, can still be determined from the observed fitted means.
- Treating full rank as a guarantee of a sound analysis. Full rank does not supply residual degrees of freedom or validate independence, model form, or the scientific interpretation.
Check Your Understanding
Use treatment coding with \(B_1\) and condition \(A\) as reference levels. Solutions follow each question.
- If every sample in \(B_3\) is condition \(B\), but some condition \(B\) samples occur in \(B_2\), are the \(B_3\) and condition \(B\) indicators identical? Solution: No. A \(B_2,B\) sample has \(B_3=0\) and condition \(B=1\), so the columns differ.
- In the three-row design of the second example, what is the rank, and which observed mean difference corresponds to \(\beta_3+\gamma\)? Solution: The rank is 3 because the \(B_3\) and condition \(B\) columns are duplicates. The difference between the \(B_3,B\) and \(B_1,A\) means is \(\beta_3+\gamma\); for the given responses it is \(11-5=6\).
- Why does the four-row design in the third example have full column rank even though two cells are empty? Solution: The four rows are independent: row differences isolate \(B_2\), condition \(B\), and then \(B_3\), while the first row supplies the intercept direction. Thus its rank is 4, equal to its four columns.
- What does full rank imply about residual degrees of freedom in a design with \(n=4\) observations and rank 4? Solution: The residual degrees of freedom are \(n-\operatorname{rank}(X)=4-4=0\). Coefficients can be uniquely determined, but residual variance cannot be estimated from residual degrees of freedom in that model.
- Does changing from treatment coding to another valid full-rank coding resolve a genuine exact dependency in the sample layout? Solution: No. Coefficient labels and values can change under recoding, but the represented model space and its rank remain the same when the recoding is valid. Redundant information in the observed layout is not created by changing labels.