Tutorials › Statistical Methods for Single-Cell RNA Sequencing › A Worked MNN Integration Analysis

Integration Methods and Their Benchmarking · Tutorial 166 of 700

A Worked MNN Integration Analysis

Work through a small MNN integration, check its matches and corrections, and assess whether batch alignment improves without obscuring cell-state structure.

Advanced 11 min read

What You'll Learn

  • Inspect whether a selected feature space is suitable for local cross-batch matching.
  • Identify mutual nearest neighbors and verify reciprocal relationships using distances.
  • Calculate correction vectors and corrected coordinates for a reference-based MNN integration.
  • Compare batch alignment before and after correction using centroids and state-stratified plots.
  • Recognize why unmatched cells must not be assigned unsupported corrections.
  • Diagnose overcorrection, poor overlap, and misleading global summaries.

From feature space to an integration check

A successful integration is not simply a plot in which batch colors overlap. It should reduce technical differences between batches for comparable cell states while retaining meaningful state distinctions. A small MNN analysis makes the logic auditable: inspect the coordinates being compared, check which pairs are truly mutual nearest neighbors, apply only supported corrections, and examine batch and state structure after correction.

The examples below use hypothetical low-dimensional coordinates, not data from a real study. Each point represents one cell in a selected feature space. The coordinates are assumed to have been obtained after suitable normalization and feature selection; they are not raw gene counts. For clarity, batch A is the reference and batch B is corrected toward it. The earlier material on shared-state assumptions and MNN correction establishes why this procedure relies on comparable cell states and local geometry.

Definition: Given cells from two batches represented in the same feature space, a pair consisting of one cell from each batch is a mutual nearest-neighbor (MNN) pair if each cell is among the other cell's nearest neighbors. With \(k=1\), each must be the other's single nearest neighbor. For a matched cell \(b\) in batch B and its reference partner \(a\) in batch A, the direct correction vector is \(a-b\). Adding this vector to \(b\) moves it to \(a\)'s coordinates.

Before calculating neighbors, confirm that coordinates come from a space intended for integration: the batches must use the same features and coordinate definition, and distance must be meaningful on those coordinates. Inspect batch and cell-state plots in that space. Check whether states thought to be shared have plausible overlap, whether a technical displacement is visible, and whether biological variation appears to dominate the neighborhood structure. Labels used to assess a plot should not be treated as proof that two cells are biologically equivalent.

The MNN assumption is local: near a matched cell, the difference between batches is sufficiently regular that a correction estimated from one or more nearby cross-batch pairs is informative for that neighborhood. MNNs do not establish that all states are shared, nor do they identify a condition effect that is confounded with batch. If a state occurs in only one batch, forcing it to match can erase biology rather than remove a technical shift.

A worked integration with reciprocal matches

For a reference-based calculation, take the MNN partners as evidence for local correspondence, then calculate each supported correction from the reference coordinate minus the batch-B coordinate. A simple justification is the additive-shift model: if comparable cells have coordinates \(z+\delta_A\) in A and \(z+\delta_B\) in B, their cross-batch difference estimates \(\delta_A-\delta_B\). Adding that difference to the B coordinate removes the relative shift in this idealized model. Real data have noise and imperfect matches, so corrected coordinates need not coincide exactly.

$$ (a-b)+b=a $$

Worked Example: Matching and Correcting Four Cells

Suppose batch A is the reference and both batches contain two cells in each of two known, shared states. Their coordinates are:

$$ \begin{aligned} A_1&=(0,0), & A_2&=(2,0), & A_3&=(10,0), & A_4&=(12,0),\\ B_1&=(0.5,0.2), & B_2&=(2.1,0.1), & B_3&=(10.4,0.2), & B_4&=(12.2,0.1). \end{aligned} $$

Use Euclidean distance and \(k=1\). For \(B_1\), distances to \(A_1\) and \(A_2\) are \(\sqrt{0.5^2+0.2^2}=0.5385\) and \(\sqrt{1.5^2+0.2^2}=1.513\); the distant-state cells are farther still. Thus \(A_1\) is its nearest A cell. The distance from \(A_1\) to \(B_1\) is also \(0.5385\), less than its distances to \(B_2\), \(B_3\), and \(B_4\), so \(A_1\) and \(B_1\) are mutual nearest neighbors.

For the other cells, the nearest cross-batch distances are \(A_2\)–\(B_2\): \(\sqrt{0.1^2+0.1^2}=0.1414\); \(A_3\)–\(B_3\): \(\sqrt{0.4^2+0.2^2}=0.4472\); and \(A_4\)–\(B_4\): \(\sqrt{0.2^2+0.1^2}=0.2236\). In each case, the corresponding cell is also the nearest in the reverse direction. The four MNN pairs are therefore \(A_1\)–\(B_1\), \(A_2\)–\(B_2\), \(A_3\)–\(B_3\), and \(A_4\)–\(B_4\). The relatively large gap to the next candidate within each state makes these matches unambiguous in this constructed example.

The correction vectors for the four B cells are:

$$ \begin{aligned} A_1-B_1&=(0-0.5,\ 0-0.2)=(-0.5,-0.2),\\ A_2-B_2&=(2-2.1,\ 0-0.1)=(-0.1,-0.1),\\ A_3-B_3&=(10-10.4,\ 0-0.2)=(-0.4,-0.2),\\ A_4-B_4&=(12-12.2,\ 0-0.1)=(-0.2,-0.1). \end{aligned} $$

Adding each vector gives corrected B coordinates \((0,0)\), \((2,0)\), \((10,0)\), and \((12,0)\). All four corrections are directly supported by MNN pairs; none has been inferred for an unmatched cell.

Evaluate batch alignment and state structure

Use plots with more than one coloring. Coloring cells by batch helps reveal residual batch separation; coloring the same coordinates by cell state helps show whether states remain distinct. Compare pre- and post-correction views in the feature space used for matching, and, when useful, inspect a separate visualization of the cells. A low-dimensional visualization can distort distances, so it is a diagnostic view rather than a replacement for checks in the integration coordinates.

Simple coordinate summaries can complement those plots. A batch centroid is the average coordinate for cells in that batch. Comparing centroids gives a compact summary of overall displacement, but it cannot show whether one state remains misaligned or whether different states were incorrectly merged. State-specific centroids and within-state patterns add context. In a real analysis, known state labels may be available from independent annotation; otherwise, use biologically interpretable markers and treat their interpretation cautiously.

Worked Example: Comparing Batch and State Summaries

Use the corrected coordinates from the four-cell example. Before correction, batch A has centroid \((6,0)\). Batch B has centroid \((6.3,0.15)\), because its x-coordinate sum is \(25.2\) and its y-coordinate sum is \(0.6\), each divided by four. The distance between batch centroids is:

$$ \sqrt{(6.3-6)^2+(0.15-0)^2} =\sqrt{0.1125} =0.3354. $$

After correction, batch B's centroid is \((6,0)\), so the centroid distance is \(0\) in this constructed data set. This indicates that the overall batch displacement has disappeared here; it does not, by itself, prove that a real integration is successful.

Check state separation as well. Before correction, the two A-state centroids are \((1,0)\) and \((11,0)\). The two B-state centroids are \((1.3,0.15)\) and \((11.3,0.15)\). The distance between the B-state centroids is \(\sqrt{(11.3-1.3)^2+(0.15-0.15)^2}=10\), the same as the A-state separation. After correction, the B-state centroids equal the corresponding A centroids, and state separation remains \(10\). Thus both batch alignment and preservation of this particular state separation are supported by the coordinate calculations. The example is deliberately clean: in real data, assess distributions and neighborhoods, not centroids alone.

Worked Example: A Nonreciprocal Candidate and an Unmatched Cell

Consider a separate one-dimensional example with reference cells \(A_1=0\), \(A_2=1\) and batch-B cells \(B_1=0.2\), \(B_2=10\). For \(k=1\), \(B_1\)'s distances to \(A_1\) and \(A_2\) are \(0.2\) and \(0.8\), so its nearest A cell is \(A_1\). Also \(A_1\)'s nearest B cell is \(B_1\), at distance \(0.2\), rather than \(B_2\), at distance \(10\). Thus \(A_1\)–\(B_1\) is an MNN pair.

The tempting alternative \(A_2\)–\(B_1\) is not mutual: although \(A_2\) is closer to \(B_1\) than to \(B_2\) (distances \(0.8\) and \(9\)), \(B_1\)'s nearest A cell is \(A_1\), not \(A_2\). Cell \(B_2\) is not part of an MNN pair either. Its nearest A cell is \(A_2\), but \(A_2\)'s nearest B cell is \(B_1\), not \(B_2\).

Only \(B_1\) receives a direct correction from this \(k=1\) MNN calculation: \(A_1-B_1=0-0.2=-0.2\), moving \(B_1\) to \(0\). The procedure has not provided a direct correction vector for \(B_2\). It would be incorrect to assign \(B_2\) the vector \(A_2-B_2=1-10=-9\), because \(A_2\) and \(B_2\) are not mutual neighbors. Nor does this local calculation establish a corrected centroid for all of batch B: any treatment of \(B_2\) requires an explicitly justified method beyond this direct match.

Diagnostics, alternatives, and limits

A practical analysis should record the selected feature space, distance definition, neighbor parameter, reference batch, matched pairs, and corrections. Inspecting this record helps distinguish a genuine integration issue from a plotting artifact. Common warning signs include:

  • Few or unstable matches. If plausible shared states have no reciprocal neighbors, investigate feature selection, scaling, overlap, and the choice of \(k\). More neighbors can increase coverage, but can also connect cells across state boundaries.
  • Matches across implausible states. Review distances and state or marker patterns. A visually attractive alignment is not evidence that a match is biologically appropriate.
  • Residual batch structure. Batch-colored plots or state-stratified coordinate summaries may show that some local regions remain displaced.
  • Erased state structure. If distinct state groups collapse after correction, or marker patterns no longer separate them, the correction may be too aggressive or the matches may be wrong.
  • Unmatched cells treated as corrected. A cell without a supported MNN does not acquire a direct MNN correction merely because a nearby cell has one. Report its status and specify any additional method used to handle it.

The main alternative summaries answer different questions. No correction preserves the observed coordinates but leaves technical displacement. A single global translation can align batch centroids, but may misalign states when the technical shift varies locally; it can also disguise offsetting state-specific errors. Local MNN correction adapts to matched neighborhoods, but depends on adequate shared-state overlap and reliable local geometry. Increasing \(k\) or averaging several local vectors may stabilize a correction when those neighbors are credible, yet can blur boundaries or mix distinct states. No one plot or summary establishes that these assumptions hold.

The correction is not a test of whether batch effects exist, and closer batches do not imply that biological differences are absent. In particular, if batch and biological condition are confounded, an integration cannot recover a condition effect that the design does not identify. Treat post-correction coordinates as a representation for suitable downstream tasks, not as a reason to discard the original measurements or the study design.

Key takeaway: A defensible MNN analysis makes its geometry inspectable: verify the feature space, check reciprocity, calculate corrections only from supported pairs, and evaluate batch alignment alongside cell-state structure. Unmatched cells and residual uncertainty should remain visible in the interpretation.

Check Your Understanding

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

  1. For a matched reference cell at \((3,2)\) and a batch-B cell at \((4,1)\), what is the direct correction vector and the corrected coordinate?
  2. In the one-dimensional example, why is \(A_2\)–\(B_1\) not an MNN pair even though \(A_2\) is closer to \(B_1\) than to \(B_2\)?
  3. Why is a zero post-correction distance between batch centroids insufficient evidence that cell-state structure was preserved?
  4. A batch-B cell has no reciprocal neighbor at \(k=1\). What can be concluded about its direct MNN correction, and what should not be claimed?

Solutions. (1) The correction is \((3,2)-(4,1)=(-1,1)\); adding it gives \((4,1)+(-1,1)=(3,2)\). (2) Reciprocity fails because \(B_1\)'s nearest A cell is \(A_1\), not \(A_2\); both directions must identify the pair. (3) Centroids summarize overall location and can coincide even when state-specific distributions are displaced or distinct states have been merged. Check state-colored plots and state-stratified summaries as well. (4) This calculation supplies no direct MNN correction vector for that cell. Do not assign it a vector from a nonreciprocal pair or claim that the direct MNN procedure has corrected it; describe any other handling separately and justify it.

Clinical Biostats