Why Check the Design Before Adjusting for Batch?
A batch adjustment is useful only to the extent that the observed design contains information to distinguish batch-associated shifts from cohort-associated shifts. If every cohort is measured in its own batch, the data cannot reveal which part of a difference belongs to the cohort and which part belongs to the batch. Less obvious patterns can create the same problem: there may be several groups of cohorts and batches, with observations linking groups internally but no observations connecting them to one another.
Design-matrix rank and graph connectivity provide two ways to diagnose this structure before fitting an additive batch-and-cohort model. The checks concern what the design can identify, not whether a batch effect is present or whether an adjustment will remove all unwanted variation.
The Additive Model and Its Design Matrix
Suppose each sample \(i\) belongs to one cohort \(c(i)\) and one batch \(b(i)\). For a single measured feature, consider the fixed-effect additive model
Here \(y_i\) is the measured value, \(\mu\) is an overall level, \(\gamma_c\) is the cohort-associated shift, \(\delta_b\) is the batch-associated shift, and \(\varepsilon_i\) is the residual. The model assumes that cohort and batch contribute additively, with no cohort-by-batch interaction, and that the same cohort and batch shifts apply across the observations being modeled. Rank calculations do not require a particular residual distribution, but standard linear-model inference additionally relies on the relevant error assumptions.
To define coefficients without redundant columns, one common parameterization includes an intercept and indicator columns for all but one reference cohort and all but one reference batch. The resulting design matrix \(X\) satisfies \(y=X\beta+\varepsilon\). The coefficient vector is uniquely identified by the design if \(X\) has full column rank. If the columns are linearly dependent, different coefficient vectors can produce the same fitted values.
For the connectivity check, construct a bipartite graph: one set of vertices represents the observed cohorts, the other represents the observed batches, and an edge joins cohort \(c\) to batch \(b\) if at least one sample has that combination. A cell with no samples contributes no edge. Replicates in an already observed cell add observations but do not add a new connection.
Why Rank and Connectivity Agree for the Additive Design
There is a convenient equivalent parameterization with one indicator column for every cohort and one for every batch, but no intercept. Its row for a sample has a 1 in that sample's cohort column and a 1 in its batch column. Call this the two-way incidence design. It is not full column rank even in a connected design, because the sum of the cohort columns equals the sum of the batch columns. This built-in redundancy is a coding feature, not evidence of disconnected groups.
The following argument identifies any additional redundancy. Suppose a vector of changes \(a_c\) to the cohort coefficients and \(d_b\) to the batch coefficients leaves every fitted value unchanged. For every observed cohort–batch edge, it must satisfy
Within a connected component, moving along an edge forces the batch change to be the negative of its cohort change. Moving from that batch to another cohort forces the new cohort change to equal the first cohort change. Repeating this along paths shows that all cohort changes in the component equal one constant \(t\), and all batch changes equal \(-t\). Each connected component therefore permits one independent shift of this form. If the graph has \(K\) connected components, the incidence design has \(K\) independent null directions and rank \(B+C-K\), where \(B\) and \(C\) are the numbers of represented batches and cohorts.
With an intercept and reference-level coding, the redundant overall direction is removed. If all represented levels are included and the graph is connected, that coded additive design has full column rank. If the graph has \(K\) components, it has \(K-1\) additional rank deficiencies. The rank should always be interpreted relative to the actual columns in the chosen design matrix: an intercept plus every cohort and every batch indicator is deliberately redundant even when the graph is connected.
Worked Example: A Fully Connected Two-by-Two Design
Consider hypothetical measurements in two cohorts and two batches. Each of the four combinations has at least one sample. Use cohort 1 and batch 1 as reference levels, and order the columns as intercept, cohort 2, and batch 2. The distinct design rows are
The determinant of the submatrix formed by the first three rows is
Because this \(3\times3\) minor is nonzero, the matrix has rank at least 3. It has only three columns, so its rank is exactly 3 and the coded design has full column rank. The graph is connected: each cohort is linked to each batch. Thus, under the additive model, the coded cohort and batch coefficients are not structurally confounded. This check alone does not establish that the additive model fits well.
Worked Example: Two Disconnected Cohort–Batch Pairs
Suppose a hypothetical study measures cohort 1 only in batch 1 and cohort 2 only in batch 2, with 12 samples in each observed cell. With cohort 1 and batch 1 as references, every row from the first cell is \([1,0,0]\), and every row from the second is \([1,1,1]\). The design has three columns, but its distinct rows span only two dimensions:
For example, multiplying \(X\) by the nonzero vector \((0,1,-1)^\mathsf{T}\) gives zero. Increasing the cohort 2 coefficient by any amount and decreasing the batch 2 coefficient by the same amount leaves all fitted values unchanged. The graph has two components, each containing one cohort and one batch. Replicating each cell 12 times does not change this rank or connect the components. The observed data identify the combined difference between the two cells, but cannot attribute it separately to cohort and batch without additional information or assumptions.
Worked Example: A Missing Cell Does Not Necessarily Disconnect the Design
Consider three hypothetical cohorts and two batches, with observations in \((C1,B1)\), \((C2,B1)\), \((C2,B2)\), and \((C3,B2)\), but none in \((C1,B2)\). The absent cell does not by itself determine connectivity: the observed edges form a path linking all five vertices. Use cohort 1 and batch 1 as reference levels, with columns ordered as intercept, cohort 2, cohort 3, and batch 2. The four distinct rows are
Subtract the first row from each of the other rows. The resulting rows are equivalent for rank calculation to
The last three rows are independent: the third contains a nonzero batch 2 entry not present in the second, and the fourth contains a nonzero cohort 3 entry. Together with the first row, they give rank 4, equal to the number of columns. The additive design is full rank despite one empty cell. The conclusion depends on the chain of observed combinations linking the cohorts and batches, not on every possible combination being observed.
Practical Checks, Alternatives, and Failure Modes
A reliable check starts with the model and the actual analysis sample. Identify which cohort and batch levels are represented after exclusions, then construct the batch-by-cohort count table. Mark each positive-count cell as an edge and find the graph's connected components. Separately compute the rank of the exact design matrix that will be fitted, using the same rows, columns, coding, and covariates as the analysis. For categorical incidence designs, connectivity gives an interpretable structural check; matrix rank also detects dependencies introduced by other columns.
State which cohort and batch levels and other covariates are included, and specify the reference coding or other parameterization.
Include only represented levels and draw an edge for every batch–cohort combination with at least one analyzed sample.
Use connectivity to diagnose the additive two-factor structure, then verify the numerical rank of the actual coded design matrix.
State whether the coded coefficients are uniquely parameterized by the design and identify any disconnected groups whose relative adjustment is not learned from the observations alone.
Exact rank is a property of the design, not of the measured feature values. In numerical software, rank is usually determined by a tolerance applied to singular values. This matters when continuous covariates or nearly redundant columns are included: a matrix can be technically full rank yet so nearly rank deficient that estimates are unstable. For a simple categorical batch-by-cohort table, the graph check avoids relying on a numerical threshold to detect structural disconnection.
A cross-tabulation is useful for seeing which combinations occur, but just counting empty cells is not enough: an empty cell can coexist with a connected design, as the third example shows. A correlation between numeric batch and cohort codes is also inadequate because arbitrary labels can change that correlation without changing the design. Rank and connectivity directly address linear dependencies in the specified model. Neither determines whether adjustment is scientifically appropriate, whether the additive model is adequate, or how large an uncertainty increase will be; those require further modeling and diagnostics.
- Common mistake: treating replication as a bridge. More samples in an existing cell improve information about that cell but do not connect it to another component. A new observed batch–cohort combination is what can create a link.
- Common mistake: calling every empty cell perfect confounding. A missing combination is not equivalent to disconnectedness. Check whether other observed combinations provide a path between the relevant groups.
- Common mistake: interpreting raw rank deficiency without checking coding. An intercept plus every level indicator is redundant by construction. Use a reference-coded design or account explicitly for that known redundancy before diagnosing additional confounding.
- Common mistake: treating full rank as proof that the adjustment is valid. Full rank means the coded coefficients are structurally identifiable under the model; it does not verify the additive assumption or rule out unmeasured differences.
Check Your Understanding
Answer each question, then compare your reasoning with the solutions below.
- There are two cohorts and two batches. The observed cells are \((C1,B1)\), \((C2,B1)\), and \((C2,B2)\). Is the graph connected? With reference coding and an intercept, how many columns are in the additive design, and what rank should it have?
- In a study with three cohorts and three batches, the graph has two connected components. What rank does the two-way incidence design have if all six levels are represented?
- A disconnected design has 20 observations in every observed cell. Can this replication alone identify the relative batch and cohort shifts between components? Explain.
- A design has an intercept, an indicator for every cohort, and an indicator for every batch. Its matrix is rank deficient. Why is that fact alone insufficient to conclude that the graph is disconnected?
Solutions. (1) Yes. The edges form the path \(C1-B1-C2-B2\), which links all four vertices. Reference coding gives \(1+(2-1)+(2-1)=3\) columns, and the connected design has rank 3. (2) Here \(B+C-K=3+3-2=4\), so the incidence design rank is 4. (3) No. Repeating observations in the same cells adds rows that repeat existing design patterns; it does not add an edge between components, so the structural ambiguity remains. (4) The full indicator sets contain a built-in dependency: the sum of cohort indicators and the sum of batch indicators both equal the intercept column (or, without an intercept, the two sums equal each other). This coding redundancy occurs even for a connected graph, so connectivity or a properly coded rank check is needed to assess additional deficiency.