Tutorials › Statistical Methods for Single-Cell RNA Sequencing › Spatial Co-Localization of Deconvolved Cell Types

Spatial Transcriptomics · Tutorial 654 of 700

Spatial Co-Localization of Deconvolved Cell Types

You will learn to define neighborhood co-localization statistics, choose a defensible permutation scheme, and report how compositional dependence and deconvolution uncertainty qualify the result.

Advanced 13 min read

What You'll Learn

  • Define a graph-based cross-type neighborhood correlation for estimated proportions.
  • Distinguish same-spot compositional dependence from association between neighboring spots.
  • Choose a permutation null that matches the co-localization question and its exchangeability assumptions.
  • Propagate deconvolution uncertainty through the statistic rather than treating estimates as exact.
  • Diagnose sensitivity to graph choice, tissue regions, and uncertain estimates.

What Does Spatial Co-Localization Measure?

A spatial proportion map assigns an estimated cell-type composition to each spot. To ask whether two types are co-localized, we need to say precisely what “together” means: the types may occur in similar proportions within the same spots, or high proportions of one type may occur near high proportions of the other. These are different questions. Here the focus is neighborhood association: whether spots with relatively high proportions of one type tend to neighbor spots with relatively high proportions of another.

This is a descriptive spatial association, not evidence that one cell type recruits, causes, or biologically interacts with another. The estimates also have uncertainty, and proportions at each spot are constrained to sum to one. Both features affect interpretation and inference.

Definition: Let \(n\) be the number of spots and let \(\hat p_{ik}\) be the estimated proportion of cell type \(k\) at spot \(i\), with \(\hat p_{ik}\geq 0\) and \(\sum_{k=1}^K \hat p_{ik}=1\). A spatial graph has spots as nodes and specified neighborhood relations as edges. Its nonnegative weights \(w_{ij}\) describe the contribution of spot \(j\) as a neighbor of spot \(i\); set \(w_{ii}=0\). A neighborhood co-localization statistic summarizes how the estimated proportion of one type at a spot relates to the proportion of another type at its graph neighbors.

A Graph-Based Neighborhood Correlation

For each type \(k\), standardize its estimated proportions across spots using the map’s mean and population standard deviation:

$$ \bar p_k=\frac{1}{n}\sum_{i=1}^n\hat p_{ik}, \qquad s_{k,\mathrm{map}}= \sqrt{\frac{1}{n}\sum_{i=1}^n(\hat p_{ik}-\bar p_k)^2}, \qquad z_{ik}=\frac{\hat p_{ik}-\bar p_k}{s_{k,\mathrm{map}}}. $$

The subscript “map” distinguishes this descriptive across-spot spread from a sample standard deviation. If a type is constant across spots, \(s_{k,\mathrm{map}}=0\), and its standardized neighborhood association is undefined. For two types \(A\) and \(B\), define the directed, weighted neighborhood correlation as

$$ T_{A\to B} = \frac{\sum_{i=1}^n\sum_{j=1}^n w_{ij}z_{iA}z_{jB}} {\sum_{i=1}^n\sum_{j=1}^n w_{ij}}. $$

A positive value means the weighted average of edgewise standardized products is positive; this can reflect high-high and/or low-low pairs. A negative value means that average is negative, which can reflect high-low and/or low-high pairs. The sign alone does not establish a specific high-high tendency. The statistic is not necessarily bounded by \(-1\) and \(1\); it is a weighted average of products of standardized values, not an ordinary correlation computed on independent paired observations. With symmetric weights, \(T_{A\to B}\) and \(T_{B\to A}\) are equal after exchanging the type labels and summing over all directed edges. With directed or asymmetric weights, report the direction explicitly.

Worked Example: Computing a Neighborhood Statistic

Suppose four hypothetical spots have estimated proportions \(\hat p_A=(0.10,0.20,0.30,0.40)\) and \(\hat p_B=(0.20,0.30,0.40,0.50)\). The remaining type has proportions \((0.70,0.50,0.30,0.10)\), so every spot’s proportions sum to one. Suppose the graph contains the undirected edges \((1,2)\) and \((3,4)\), each with weight 1; in the statistic, each edge contributes both directed pairs.

The mean is \(0.25\) for \(A\) and \(0.35\) for \(B\), and the map standard deviation is \(0.1118\) for both: \(s_{\mathrm{map}}=\sqrt{(0.15^2+0.05^2+0.05^2+0.15^2)/4}=\sqrt{0.0125}=0.1118\). Thus each standardized map is approximately \((-1.3416,-0.4472,0.4472,1.3416)\).

There are four directed edge contributions. The products are \(z_{1A}z_{2B}=0.6000\), \(z_{2A}z_{1B}=0.6000\), \(z_{3A}z_{4B}=0.6000\), and \(z_{4A}z_{3B}=0.6000\). Therefore \(T_{A\to B}=(0.6000+0.6000+0.6000+0.6000)/4=0.6000\). This is positive neighborhood association for this graph. It does not establish that the types interact, and it does not by itself provide a significance test.

Why Composition Changes Interpretation

At every spot, the proportions share a fixed total. Increasing one type’s proportion must be offset by a decrease in one or more other types. Consequently, correlations among the types are not free to vary as they would for unconstrained measurements. In particular, same-spot correlations can be negative partly because of the sum-to-one constraint, even if there is no biological avoidance. Neighborhood statistics do not remove this dependence: maps of different types still come from the same compositions and can share spatial patterns.

A useful distinction is between a same-spot association, such as the correlation across spots between \(\hat p_{iA}\) and \(\hat p_{iB}\), and a neighborhood association such as \(T_{A\to B}\). Neither has a causal interpretation. If the scientific question concerns relative composition, log-ratio methods can be useful, but zeros, pseudocount choices, and the definition of the reference component then matter. They answer a different question from the graph-based statistic defined above.

Key takeaway: Interpret co-localization as an association between estimated proportions at graph-linked locations. Because the proportions are compositional, a pairwise result is conditional on the other cell types and on the full estimation procedure; it is not an isolated measure of two independent abundances.

Permutation Tests: The Null Must Match the Question

A permutation test compares the observed statistic with statistics generated under a specified null arrangement. It is valid only when the rearrangements used are exchangeable under that null: under the null, each permitted rearrangement must be equally plausible, conditional on what the procedure holds fixed. The graph, weights, type definitions, and preprocessing should be fixed before the test, or their selection must be repeated within every permutation.

There is no single universally valid permutation for spatial co-localization. Randomly reallocating whole composition vectors among spots preserves each spot’s sum-to-one constraint and the observed compositions, but destroys the spatial arrangement of all types. This tests whether the observed joint composition map is unusually aligned with the graph under an exchangeable-location null. It is generally not a valid null if tissue regions, boundaries, or spatial structure make locations nonexchangeable. Permuting only one type map may break the observed within-spot compositional dependence. It can also destroy that type’s own spatial autocorrelation, making the null too simple for a question about cross-type association beyond each map’s spatial structure.

For spatially structured tissue, possible alternatives include permutations restricted within prespecified comparable regions, spatial shifts or rotations that preserve appropriate aspects of a map, or null simulations from a model that retains marginal spatial structure and the compositional constraint. Each method has assumptions. A restricted permutation requires exchangeability within each restriction group; a shift or rotation requires the tissue geometry and boundary treatment to make such transformations defensible; a model-based null depends on adequate model fit. State the null and what the procedure preserves rather than reporting “a permutation test” without qualification.

For \(M\) random permutations, if \(b\) permuted statistics are at least as extreme as the observed statistic in a prespecified one-sided test, a standard Monte Carlo estimate is \((b+1)/(M+1)\). The added one prevents a reported value of zero and accounts for the observed arrangement among the simulated reference arrangements. For a two-sided test, define extremeness in advance—for example, by comparing absolute statistics. A small p-value indicates that the observed statistic is unusual under the chosen null; it is not the probability that the null is true.

Worked Example: Interpreting a Permutation Result

In a hypothetical analysis, researchers test whether the neighborhood statistic for \(A\) and \(B\) is greater than expected under a prespecified exchangeable-location null. They permute whole composition vectors among spots, keep the graph fixed, and generate \(M=999\) random arrangements. The observed statistic is \(0.6000\), and 84 permuted statistics are at least \(0.6000\).

The Monte Carlo p-value is \((84+1)/(999+1)=85/1000=0.0850\). At \(\alpha=0.05\), this result does not meet the chosen threshold for rejecting the null. It is not correct to conclude that the cell types are not co-localized: the test provides limited evidence against this particular null, for this graph and statistic. The conclusion is also conditional on the exchangeability assumption. If tissue regions make spot locations nonexchangeable, the whole-vector permutation may not calibrate the test correctly.

Propagating Deconvolution Uncertainty

Estimated proportions are not known without error. A statistic computed from a single fitted map treats estimates as fixed and can give a misleading impression of precision, especially when deconvolution is unstable or reference profiles mismatch the tissue. If the deconvolution method supplies bootstrap, posterior, or other uncertainty draws, compute the statistic for each draw, retaining valid compositions at every spot. The resulting distribution describes how estimation uncertainty affects the effect estimate. It is not automatically a permutation null distribution.

Worked Example: Assessing Uncertainty in the Statistic

Suppose a hypothetical deconvolution analysis provides 200 plausible proportion maps, and the same graph and definition of \(T_{A\to B}\) are used for every map. The 200 statistics have median \(0.42\), with 2.5th and 97.5th percentiles \(0.05\) and \(0.71\). The interval is an uncertainty summary only if the draws adequately represent the uncertainty under the method used; it is not a confidence interval with guaranteed frequentist coverage unless that procedure justifies such coverage.

All 200 values are positive, so the estimated direction of neighborhood association is stable across these draws. However, values range substantially, and the lower percentile is close to zero: the magnitude is uncertain. This summary does not provide a calibrated p-value. To combine uncertainty and testing, the null-generation procedure must also account for the estimation process—for example, by repeating the relevant fitting and uncertainty steps within a defensible null simulation. Reporting a permutation p-value conditional on one fitted map alongside an uncertainty interval can be informative, but the two quantities answer different questions.

Justifying the Standardization and the Main Diagnostics

Standardization makes the statistic comparable across cell types with different average proportions and different across-spot spreads. In particular, if \(s_{k,\mathrm{map}}>0\), then \(z_{ik}\) has mean zero and mean squared value one:

$$ \frac{1}{n}\sum_i z_{ik}=0, \qquad \frac{1}{n}\sum_i z_{ik}^2 = \frac{\sum_i(\hat p_{ik}-\bar p_k)^2/n}{s_{k,\mathrm{map}}^2} =1. $$

This puts the two maps on a common scale, but it does not make the edge-paired values independent or ensure that \(T_{A\to B}\) lies between \(-1\) and \(1\). Spatially overlapping neighborhoods and shared spots create dependence among edge contributions. This is why a standard independent-pairs correlation test is not an appropriate substitute for a spatially justified null calibration.

Before interpreting a result, check the map, the graph, and the null. Look for a small number of extreme spots dominating the edge products; compare the graph with plausible alternative neighborhood scales; inspect whether the association is driven by a tissue region, boundary, or gradient; and check whether rare types have near-zero map variance or highly uncertain estimates. Sensitivity to graph scale is important: changing which spots count as neighbors changes the scientific meaning of the statistic. If the statistic changes sign or magnitude across reasonable choices, report that instability rather than selecting the most favorable graph.

1
Specify the association.
Name the two types, whether the question is directional, the statistic, and the neighborhood graph and weights.
2
Choose the null.
State what is held fixed and what may be rearranged. Check that exchangeability or the assumptions of a spatial null model are plausible for the tissue.
3
Assess uncertainty and sensitivity.
Propagate deconvolution uncertainty when available, examine influential spots and regions, and compare justified neighborhood choices.
4
Report in context.
Give the statistic, the null and permutation scheme, the p-value if calibrated, and limitations. Describe spatial association, not biological causation.

Common Pitfalls and Alternatives

ApproachWhat it summarizesMain caution
Same-spot correlationWhether two estimated proportions vary together across spotsDoes not measure neighborhood association; compositional constraints affect interpretation.
Graph-based neighborhood statisticAssociation between one type’s standardized map and another type at neighboring spotsDepends on graph definition and needs a null that respects spatial structure.
Whole-composition permutationWhether the joint composition arrangement is unusual on a fixed graphPreserves each composition but generally destroys all spatial structure; requires exchangeable locations.
Spatial model-based nullAssociation relative to a specified model for spatial dependenceCan preserve more structure, but conclusions depend on model adequacy.
  • Confusing same-spot and neighborhood association. A same-spot correlation is not evidence that neighboring spots have similar compositions. Define which locations are paired.
  • Ignoring closure. A negative same-spot association can arise from the sum-to-one constraint; it is not, by itself, evidence of biological exclusion.
  • Permuting without checking exchangeability. A small p-value from an invalid rearrangement scheme is not reliable evidence. Account for tissue regions and spatial dependence in the null.
  • Treating the fitted map as truth. If estimates are uncertain, a single statistic hides that uncertainty. Report an uncertainty summary and keep it distinct from the permutation p-value.

Check Your Understanding

Answer each question, then compare with the solutions below.

  1. What does a positive \(T_{A\to B}\) indicate, and what does it not establish?
  2. Why can a negative same-spot correlation between two proportions occur without biological avoidance?
  3. A test permutes whole composition vectors among all spots. Name one feature it preserves and one assumption that may fail.
  4. Across 499 permutations, 24 statistics are at least as extreme as the observed statistic in a one-sided test. Calculate the Monte Carlo p-value.
  5. Why should the spread of statistics across deconvolution draws not automatically be called a permutation p-value?

Solutions. (1) Positive \(T_{A\to B}\) means the weighted average of edgewise standardized products is positive, which can reflect high-high and/or low-low pairs. It does not establish a specific high-high tendency, causation, or interaction. (2) The proportions sum to one, so an increase in one component requires a decrease in another or others. (3) Whole-vector permutation preserves each observed spot composition and therefore its sum-to-one constraint; it assumes locations are exchangeable under the null, which may fail with tissue regions or spatial structure. (4) The estimate is \((24+1)/(499+1)=25/500=0.0500\). (5) Deconvolution draws represent uncertainty in estimated maps, whereas a permutation distribution represents outcomes under a specified null arrangement; the two distributions have different meanings.

Clinical Biostats