Why Spatial Effects Can Be Difficult to Separate
A spatial expression pattern may reflect location, tissue identity, technical batch, or the mix of cells captured at each spot. These explanations can coincide: for example, one tissue region may occupy only one side of a section, be processed in a separate batch, and contain a different cell composition. A regression model can include all these variables, but including them in a formula does not guarantee that the data can distinguish their contributions.
The key question is whether there are comparable observations across the covariates being adjusted for. If expression is observed at both near and far positions within the same tissue region, the data may support a within-region spatial contrast. If all near observations come from one region and all far observations from another, a spatial contrast is inseparable from a region contrast without additional assumptions or data.
For a spot \(i\), let \(Y_i\) denote an expression outcome, \(x_i\) a spatial predictor such as distance from a boundary, and \(R_i\) an indicator for a tissue region. A simple model is
Here \(\beta_x\) is the modeled change in mean expression per unit increase in \(x_i\), holding region fixed, and \(\beta_R\) is the modeled difference between regions at the same \(x_i\). These interpretations require the model to be appropriate, including its assumed functional form. They are not automatically causal interpretations. For inferential uncertainty, the error structure and standard errors must also account for relevant dependence, such as spatial correlation.
Overlap and Identifiability
For categorical covariates, a useful first check is whether the spatial predictor varies within each covariate level. For continuous covariates, check whether the ranges of the variables being compared overlap, rather than relying on a single overall correlation. A regression coefficient can be uniquely computed under a specified parametric model even when some comparisons require extrapolation; in that situation, identification comes from the model form, not from observed comparisons in the missing regions of the covariate space.
The linear-model condition is that the design matrix has full column rank: no included predictor column is an exact linear combination of the others. If location and region indicators are identical, their columns duplicate each other and the model cannot uniquely estimate both coefficients. Near-duplication does not necessarily prevent a numerical estimate, but it can make that estimate highly sensitive to small changes in the data.
The same issue applies to batch and cell composition. If each batch contains only one tissue region, a region contrast is also a batch contrast. If a cell-type proportion changes only with location, a model cannot use observed data to distinguish a location association from a composition association at the same covariate values. Earlier material on separating expression changes from composition changes motivates including composition when appropriate, but inclusion alone does not create the comparisons needed to estimate separate effects.
Worked Example: Location and Region Are Exactly Confounded
Suppose four hypothetical spots have transformed expression values \(Y_i\), spatial position \(x_i\), and region indicator \(R_i\), with \(R_i=0\) for region A and \(R_i=1\) for region B.
| Spot | Region | \(x_i\) | \(Y_i\) |
|---|---|---|---|
| 1 | A | 0 | 2 |
| 2 | A | 0 | 2 |
| 3 | B | 1 | 5 |
| 4 | B | 1 | 5 |
Fit \(Y_i=\beta_0+\beta_x x_i+\beta_R R_i+\varepsilon_i\). For region A, the fitted mean must be \(\beta_0=2\). For region B, the fitted mean must satisfy \(\beta_0+\beta_x+\beta_R=5\). Substituting \(\beta_0=2\) gives
This equation does not determine the two coefficients separately. For example, \((\beta_x,\beta_R)=(3,0)\) and \((0,3)\) both fit all four observations exactly. In the design matrix, the \(x_i\) and \(R_i\) columns are identical. Thus, the observed three-unit difference is estimable as a combined contrast, but it cannot be assigned uniquely to location or region. A software package that drops one column or reports a coefficient should not be interpreted as having resolved the scientific ambiguity.
How Omitting a Covariate Can Distort a Spatial Association
When a confounder is omitted rather than included, its association with the spatial predictor can be transferred into the fitted spatial slope. For a simple derivation, suppose the true centered relationship is
where \(z_i\) is an omitted covariate and the conditional mean of \(\varepsilon_i\) given \(x_i,z_i\) is zero. Regressing \(Y_i\) on \(x_i\) alone gives a slope equal to the covariance of \(x_i\) and \(Y_i\), divided by the variance of \(x_i\). Substituting the true model and using covariance linearity yields
The omitted-variable contribution is zero if \(z\) has no association with \(x\), or if \(z\) has no effect on the outcome in this model. Otherwise, the unadjusted slope combines the spatial association and the contribution associated with \(z\). This formula describes a simple linear setting; it does not make a causal interpretation valid by itself.
Worked Example: A Pooled Spatial Difference Exaggerated by Region
Consider hypothetical proximal and distal spots in two regions. The table gives the number of spots and the mean transformed expression in each group. Suppose the group means follow an additive model with no region-by-position interaction.
| Region | Position | Number of spots | Mean expression |
|---|---|---|---|
| A | Proximal | 9 | 2 |
| A | Distal | 1 | 4 |
| B | Proximal | 1 | 6 |
| B | Distal | 9 | 8 |
Within region A, the distal-minus-proximal difference is \(4-2=2\) expression units. Within region B, it is \(8-6=2\) expression units. But the pooled proximal mean is
and the pooled distal mean is
The unadjusted pooled difference is therefore \(7.6-2.4=5.2\) expression units, although the within-region difference is 2 units in each region. A regression with a distal indicator and a region B indicator recovers the additive-model coefficients: baseline mean \(2\), distal coefficient \(2\), and region B coefficient \(4\). There is overlap because both positions occur in both regions, so within-region comparisons are observed. The pooled contrast is misleading because proximal and distal groups have different region compositions.
This calculation does not establish that position causes expression to change. It shows that, under the stated additive model and with the available overlap, adjustment can distinguish the within-region association from the difference in regional composition.
Diagnostics and Practical Responses
Diagnose confounding before interpreting a fitted spatial coefficient. A useful sequence is to inspect the actual comparisons available, then check whether the model can estimate the requested coefficients, and finally assess how dependent the result is on modeling choices.
Plot spatial position and expression with region and batch marked. A map can reveal that a batch or region occupies a distinct area and has no spatially comparable observations elsewhere.
Cross-tabulate categorical position groups with region and batch. For continuous position, compare its observed range within each region or batch. Empty combinations identify absent comparisons; sparse combinations flag weak support.
Look for duplicated or redundant columns, rank deficiency, very small singular values, and inflated standard errors. A coefficient that changes markedly when one spot or covariate is removed may be weakly identified.
Report whether the estimate is based on within-region comparisons, on extrapolation from a chosen model, or on a combined contrast that cannot be decomposed. Do not describe an unsupported separation as a data-identified effect.
Residual plots and model-fit summaries remain useful, but they do not establish overlap. A model can fit observed values well while leaving location and region inseparable. Likewise, accounting for spatially correlated errors may improve uncertainty estimates, but it does not repair a design in which the predictors are redundant.
When overlap is absent or poor, possible responses include reporting a combined association, restricting the target comparison to the region and position ranges that overlap, or collecting data with region and batch represented across comparable locations. If a model imposes a common slope or other structure that permits extrapolation, report that assumption explicitly and assess whether conclusions change under plausible alternatives. For cell composition, acknowledge that proportions may themselves be estimated with uncertainty; treating them as perfectly measured covariates can overstate how completely composition has been controlled.
Worked Example: Batch Cannot Be Separated From Region
In a hypothetical section, all four region A spots were processed in batch 1 and had expression values 3, 4, 3, and 4. All four region B spots were processed in batch 2 and had values 7, 8, 7, and 8. The sample means are
The observed difference is \(7.5-3.5=4.0\) expression units. However, the data contain no region A observations from batch 2 and no region B observations from batch 1. In a model with separate region and batch indicators, those indicator columns are identical for these observations. The four-unit contrast is therefore attributable only to the combined region-and-batch grouping from these data; the separate contributions are not identified.
The variation within each group does not solve the problem: it describes variability among spots within a combined group, not a comparison of regions at the same batch or batches within the same region. A study design with both regions represented in both batches would provide the missing comparisons. Until then, a separate region effect requires an additional assumption or external information, not merely another regression fit.
Common Mistakes and Limitations
- Wrong reasoning: “I included region and batch as covariates, so the spatial coefficient is adjusted and therefore separated.” Correction: Adjustment only separates coefficients when the observed design supports those contrasts, or when clearly stated model assumptions supply the missing information.
- Wrong reasoning: “The software returned a finite coefficient, so it is identified by the data.” Correction: Software may remove a redundant predictor, impose a constraint, or return a numerically unstable solution. Check the design and identify which contrast the reported value represents.
- Wrong reasoning: “A nonsignificant coefficient shows there is no spatial effect.” Correction: Weak overlap can produce large uncertainty; lack of evidence for a separated effect is not evidence that the effect is zero.
- Wrong reasoning: “The adjusted coefficient is causal because region was included.” Correction: Regression adjustment does not by itself establish causation. Causal interpretation requires appropriate design and assumptions about confounding, measurement, and the meaning of the intervention or contrast.
Even with overlap, the estimated contrast can be sensitive to the choice of spatial predictor, the assumed functional form, interactions, measurement error, and spatial dependence. With weak overlap, uncertainty summaries based on a single model may not fully convey the extent to which the answer relies on extrapolation. The defensible conclusion should match the comparisons actually represented in the data.
Check Your Understanding
Answer each question, then compare with the solutions below.
- If a spatial predictor and a region indicator are identical for every spot, what can a model containing both predictors estimate?
- In the pooled example, why is the unadjusted distal-minus-proximal difference not the within-region contrast?
- What does it mean if a model is full rank but one region has almost no observations at distal positions?
- If region and batch are perfectly aligned, does adding both indicators to the regression separate their effects? Explain.
- Name two diagnostics that can reveal poor overlap or weak identifiability.
Solutions. (1) It can estimate the combined contrast associated with the identical columns, but not allocate that contrast uniquely between spatial position and region. (2) The pooled groups have different proportions of regions A and B, whose mean expression levels differ; the pooled contrast mixes the within-region position difference with that composition difference. (3) The model may have a unique numerical estimate, but the distal comparison in that region is weakly supported and may rely on extrapolation or restrictive model assumptions. (4) No. The indicator columns are redundant, so the separate region and batch coefficients are not identified from those observations. (5) Examples include plotting position by region or batch, tabulating covariate combinations, checking design-matrix rank, inspecting singular values, and assessing coefficient stability when observations are removed.