Tutorials › Statistical Methods for Single-Cell RNA Sequencing › Why MNN Correction Uses Local Geometry

Integration Methods and Their Benchmarking · Tutorial 158 of 700

Why MNN Correction Uses Local Geometry

Learn how an MNN pair’s local displacement approximates a batch effect at a shared cell state, and when that geometric interpretation is unreliable.

Advanced 11 min read

What You'll Learn

  • Express each batch’s coordinates as a shared state representation plus a batch-specific displacement and error.
  • Derive the correction vector from a cross-batch MNN pair and identify the effect of imperfect state matching.
  • Explain why local displacement can be informative even when batches have different global cell-state distributions.
  • Separate batch displacement from composition differences and batch-specific error in global means.
  • Recognize overlap, smoothness, and noise conditions that support a local geometric interpretation.
  • Compare local MNN correction with global centering and exact paired matching.

Why a Local Pair Can Be More Informative Than a Global Mean

Two batches can contain different proportions of cell states and still share some of those states. A global comparison of their coordinate means mixes two things: a shift in the measured representation for a given state, and a difference in which states were sampled. A mutual nearest neighbor (MNN) pair offers a more local comparison: if its cells represent nearly the same state, their coordinate difference can approximate the batch displacement at that state.

The geometric argument is conditional, not automatic. Nearby cells need to represent comparable biological states; the shared state-to-coordinate map should vary smoothly nearby; and technical errors should not dominate the pair difference. An MNN match is evidence of local proximity, not proof of biological equivalence.

Definition: Let \(S\) denote a cell’s underlying state and \(Z_k\) its coordinate vector in batch \(k\). A local shared-state model is \(Z_A=f(S)+\varepsilon_A\) and \(Z_B=f(S)+\delta(S)+\varepsilon_B\), where \(f\) is the shared state-to-coordinate map, \(\delta(S)\) is the batch-specific displacement at state \(S\), and \(\varepsilon_k\) is observation error in batch \(k\). For a pair with coordinates \(z_A\) and \(z_B\), define the correction applied to the batch-B cell as \(d_{B\to A}=z_A-z_B\). This sign convention moves the batch-B coordinate toward the batch-A coordinate.

The model allows different state distributions in the two batches. Write their densities as \(p_A(s)\) and \(p_B(s)\). To compare a pair locally, however, we need a state \(s\) represented in both batches, or at least cells close enough in state that the shared map and displacement change little across the pair. This is the connection between the shared-state assumption for batch alignment and the geometry of an MNN pair.

Deriving the Pairwise Correction

First consider an ideal pair whose cells have exactly the same state \(s\), with no observation error. Their coordinates are \(z_A=f(s)\) and \(z_B=f(s)+\delta(s)\). Subtracting gives \(z_A-z_B=-\delta(s)\): the correction to the batch-B coordinate is the negative of its displacement from batch A. Adding that vector to \(z_B\) returns \(f(s)\).

$$ z_B+d_{B\to A} = \{f(s)+\delta(s)\}+\{f(s)-[f(s)+\delta(s)]\} = f(s) $$

Real MNN pairs need not have identical states, and their coordinates include error. Let their states be \(s_A\) and \(s_B\), and use the model above for each cell. The observed pair vector is

$$ d_{B\to A} = z_A-z_B = f(s_A)-f(s_B)-\delta(s_B)+\varepsilon_A-\varepsilon_B. $$

The target correction at the batch-B cell’s state is \(-\delta(s_B)\). Thus the discrepancy between the observed vector and that target is

$$ d_{B\to A}-[-\delta(s_B)] = f(s_A)-f(s_B)+\varepsilon_A-\varepsilon_B. $$

This decomposition gives a precise reason for using local geometry: if \(s_A\) and \(s_B\) are close, the shared-map difference is small, so the pair vector is informative about the displacement at \(s_B\), provided the error difference is also small. For example, if \(f\) is \(L\)-Lipschitz locally, meaning \(\|f(s_A)-f(s_B)\|\leq L\|s_A-s_B\|\), then

$$ \left\|d_{B\to A}+\delta(s_B)\right\| \leq L\|s_A-s_B\|+\|\varepsilon_A-\varepsilon_B\|. $$

The bound separates two sources of error: imperfect state matching and observation error. It does not say that a close pair must be a valid match. If distinct biological states happen to lie close in the chosen coordinates, the premise that pair proximity reflects state similarity can fail.

Justification: The local correction-vector interpretation follows by subtracting the two batch coordinate models. Its accuracy improves when the paired states are close under a locally smooth shared map and the pair’s error difference is small. It estimates a local displacement; it does not establish that one constant displacement applies to every state.

Worked Examples

Worked Example: A Close Pair With a Small State Mismatch

Suppose coordinates and states are two-dimensional, \(f(s)=s\), and the batch-B displacement is \(\delta(s)=(1,-2)\). A batch-A cell has state \(s_A=(3,1)\), while its hypothetical MNN partner in batch B has state \(s_B=(3.1,1)\). Assume both errors are zero. Find the pair correction and compare it with the ideal correction at \(s_B\).

The coordinates are \(z_A=(3,1)\) and \(z_B=s_B+\delta(s_B)=(4.1,-1)\). Therefore

$$ d_{B\to A}=z_A-z_B=(3-4.1,\ 1-(-1))=(-1.1,2). $$

The ideal correction at the batch-B state is \(-\delta(s_B)=(-1,2)\). The observed vector differs by \((-0.1,0)\), whose Euclidean length is \(0.1\). This is exactly the shared-map difference \(f(s_A)-f(s_B)=(-0.1,0)\). Adding the observed correction to \(z_B\) gives \((4.1,-1)+(-1.1,2)=(3,1)\): it aligns the pair to the batch-A partner, but differs slightly from the batch-B cell’s shared-map coordinate \((3.1,1)\) because the states were not identical.

Worked Example: Different State Proportions, Similar Local Displacement

Consider a one-dimensional shared map \(f(s)=s\), two possible states \(s=0\) and \(s=10\), and a constant batch-B displacement \(\delta(s)=2\). In batch A, suppose 90% of cells have state 0 and 10% have state 10. In batch B, suppose those proportions are reversed. Assume zero errors and that local pairs can be made at each shared state.

The batch-A mean coordinate is \(0.9(0)+0.1(10)=1\). The batch-B mean is \(0.1(2)+0.9(12)=11\), so the global mean difference, batch B minus batch A, is \(11-1=10\). Yet at either state the within-state batch displacement is only 2. The MNN correction to a batch-B cell at either state is \(-2\), not \(-10\).

The difference arises because the global mean also reflects the change in state proportions. At state 0, the pair coordinates are 0 and 2; at state 10, they are 10 and 12. Both pair differences are 2 even though the batches’ overall means are far apart. This illustrates why local comparisons can be useful when global distributions differ, provided there is genuine overlap at the states being compared.

Worked Example: Accounting for Batch-Specific Mean Error

Suppose the two batches have the same state distribution and a constant batch-B displacement of \(0.5\) coordinate units. Let the expected coordinate error be \(E_A[\varepsilon_A]=0.2\) units in batch A and \(E_B[\varepsilon_B]=-0.1\) units in batch B. Find the expected global mean difference, batch B minus batch A.

Because the state distributions are identical, the shared-map terms cancel. The displacement contributes \(0.5\), while the difference in expected errors contributes \(-0.1-0.2=-0.3\). Hence

$$ E_B[Z]-E_A[Z] = 0.5+(-0.3) = 0.2\text{ coordinate units}. $$

The mean difference is not \(0.5\), even though the biological state distributions match, because the batch-specific error means differ. A pairwise observed vector can likewise be affected by \(\varepsilon_A-\varepsilon_B\). Attributing all observed differences to a biological or technical displacement requires assumptions about error, not merely a geometric match.

Why Unequal Global Distributions Matter

The local argument should not be confused with a claim that the global means directly estimate the batch displacement. Under the model, let \(p_A\) and \(p_B\) be the state densities in batches A and B, and let expectations of errors be taken under their respective batches. Then

$$ E_B[Z]-E_A[Z] = \int f(s)\{p_B(s)-p_A(s)\}\,ds + \int \delta(s)p_B(s)\,ds + E_B[\varepsilon_B]-E_A[\varepsilon_A]. $$

The first integral is the contribution of differing state distributions to the shared representation. The second is the average batch-B displacement over the states represented in batch B. The final term is the difference in expected observation errors. Even if the error means are equal, the first term need not vanish when the batches have different state distributions. Conversely, equal state distributions do not make the error term disappear unless the expected errors are equal.

An MNN pair compares nearby points rather than the two global means. This makes the pair less directly sensitive to differing overall proportions, but it does not eliminate the need for shared support: if a state occurs only in one batch, there is no cross-batch local comparison for that state.

Conditions, Diagnostics, and Alternatives

The local geometric interpretation is most credible when the following conditions are reasonably supported:

  • Shared-state overlap: both batches contain cells from the biological states being aligned. A nearest neighbor from a different state is not a substitute for overlap.
  • Local smoothness: \(f\) changes gradually over the distance separating paired states, and \(\delta(s)\) does not change abruptly within the local region.
  • Meaningful coordinates: closeness in the analyzed representation is relevant to cell-state similarity. Poorly chosen coordinates can make unrelated states appear close.
  • Manageable error: measurement noise and batch-specific error do not overwhelm the state signal or dominate pairwise differences.

Warning signs include pairs that are far apart in the relevant representation, local neighborhoods containing visibly different cell types, or correction directions that vary sharply among nearby matches without a plausible state-dependent explanation. A lack of cross-batch neighbors for a region is also informative: it may indicate missing overlap rather than a displacement that can safely be inferred. These checks diagnose whether the local argument is plausible; they do not prove the shared-state assumption.

Global centering is simpler, but it uses a single mean difference and can mistake composition changes for batch displacement. Exact paired matching would make the state comparison clearer if the same biological unit were measured in both batches, but such pairs are generally unavailable for individual cells. MNNs instead provide approximate local comparisons. Their advantage is locality; their limitation is reliance on the representation, overlap, and quality of the matches.

Common pitfall: “The batch means differ by 10 units, so every batch-B cell should be shifted by 10 units.” This reasoning confuses a global mean difference with a within-state displacement. The global difference can include composition and expected-error differences as well as batch displacement. Use the pair’s local geometry to motivate a local correction, and assess whether the pair plausibly represents a shared state.

Check Your Understanding

Answer each question, then compare your reasoning with the solutions below.

  1. If \(z_A=(2,5)\) and \(z_B=(4,4)\), what correction vector moves the batch-B coordinate toward batch A?
  2. In the local model, which two terms make the observed pair correction differ from the ideal \(-\delta(s_B)\)?
  3. Suppose both batches have the same state distribution and equal expected errors. What contribution remains in the expected global mean difference?
  4. Why can a global mean difference be large even when local MNN pairs have small coordinate differences?

Solutions. (1) \(d_{B\to A}=z_A-z_B=(2-4,5-4)=(-2,1)\); adding it to \(z_B\) gives \((2,5)\). (2) The difference \(f(s_A)-f(s_B)\) due to imperfect state matching and the error difference \(\varepsilon_A-\varepsilon_B\). (3) The average displacement \(\int\delta(s)p_B(s)\,ds\); the shared-map and expected-error differences cancel under these conditions. (4) Different state proportions can change the global mean even if cells at shared local states are close, and batch displacement may also vary by state.

Clinical Biostats