Why work through an anchor integration?
An anchor-based integration uses selected cell pairs to estimate how one dataset should be adjusted relative to another. The calculation is local: a query cell can receive a correction based on nearby, reliable anchors rather than on one global batch shift. That flexibility is useful when technical differences vary across the representation, but it also makes the result depend on whether the anchors are credible, well distributed, and drawn from genuinely shared cell states.
This worked analysis uses two small, hypothetical datasets. It makes each decision explicit: find candidate anchors in a shared low-dimensional representation, filter candidates using neighborhood consistency, assign reliability scores, and combine nearby anchor corrections. The calculations illustrate a transparent teaching version of the procedure; software implementations can use different neighborhood and weighting details. The earlier material on anchor failures for condition-specific states motivates a final check that alignment has not mistaken a biologically unique state for a shared one.
Set up the two datasets and discover candidates
Call the reference cells \(R_1,\ldots,R_4\) and the query cells \(Q_1,\ldots,Q_4\). Assume both datasets have been normalized and represented in a common latent space for neighbor search. The following hypothetical distances are between cells from opposite datasets in that shared search representation. Smaller distances indicate closer neighbors.
| Q1 | Q2 | Q3 | Q4 | |
|---|---|---|---|---|
| R1 | 0.10 | 0.34 | 3.80 | 7.00 |
| R2 | 0.31 | 0.12 | 3.40 | 6.50 |
| R3 | 3.90 | 3.50 | 0.15 | 0.40 |
| R4 | 7.00 | 6.40 | 0.38 | 0.08 |
For a one-nearest-neighbor rule, a pair is reciprocal if each cell is the other's closest cell across datasets. \(R_1\)'s closest query cell is \(Q_1\), and \(Q_1\)'s closest reference cell is \(R_1\), so \((R_1,Q_1)\) is reciprocal. The same check gives \((R_2,Q_2)\), \((R_3,Q_3)\), and \((R_4,Q_4)\). Reciprocity supplies candidate evidence, not proof of shared biology.
Worked Example: Finding Reciprocal Candidate Anchors
Use the distance table to check the proposed pair \((R_3,Q_3)\), and decide whether \((R_3,Q_4)\) is reciprocal.
In row \(R_3\), the smallest distance is \(0.15\), to \(Q_3\). In column \(Q_3\), the distances to \(R_1,R_2,R_3,R_4\) are \(3.80,3.40,0.15,0.38\), so the smallest is also to \(R_3\). Thus \((R_3,Q_3)\) is reciprocal.
Although \(R_3\) is close to \(Q_4\) at distance \(0.40\), \(R_3\)'s closest query cell is \(Q_3\), not \(Q_4\). Therefore \((R_3,Q_4)\) is not a reciprocal one-nearest-neighbor pair. This distinction prevents a visually close but non-reciprocal pair from automatically entering the candidate set under this rule.
Filter candidates, then score the retained anchors
A candidate can be reciprocal in the search representation and still be a false match. For this example, suppose independent high-dimensional feature neighborhoods are checked before correction. The check asks whether close neighbors around the two cells provide consistent evidence of corresponding local structure. To make the toy rule explicit, each candidate receives three neighborhood-consistency checks and must pass at least two. This threshold is illustrative, not a universal setting.
Worked Example: Filtering a Candidate With Inconsistent Neighbors
Suppose the neighborhood check yields the following hypothetical results: \((R_1,Q_1)\) passes three checks, \((R_2,Q_2)\) passes two, \((R_3,Q_3)\) passes two, and \((R_4,Q_4)\) passes none. The first three candidates pass the stated threshold; the fourth fails.
For the failed pair, assume the query cell's closest feature-space neighbors correspond to a different local state than the reference cell's neighbors. This is evidence against interpreting the pair as a shared state, even though their latent-space distance \(0.08\) made them reciprocal nearest neighbors. The filtered anchor set is therefore \(a_1=(R_1,Q_1)\), \(a_2=(R_2,Q_2)\), and \(a_3=(R_3,Q_3)\).
Filtering and scoring answer different questions. Filtering removes candidates that fail a prespecified consistency rule. Scoring then represents the relative local reliability of candidates that remain; a score does not turn a failed candidate into a valid anchor. For a small, fully specified calculation, suppose local neighborhood comparisons give the retained anchors scores \(s_1=0.90\), \(s_2=0.80\), and \(s_3=0.60\), on a scale where larger values indicate stronger local support. These are hypothetical scores, not probabilities that the anchors are biologically correct.
Assume their correction vectors, expressed as reference minus query coordinates in a correction space, are \(v_1=(-1.0,0)\), \(v_2=(-1.2,0)\), and \(v_3=(-0.8,-0.2)\). The correction space need not be identical to the space used for candidate search. The vectors describe the estimated adjustment associated with each anchor; the filtering distances above should not be confused with their magnitudes.
Calculate a weighted correction
For a query cell \(q\), let \(d_{qa}\) denote its distance to anchor \(a\) in the correction-weighting neighborhood. To illustrate local distance weighting, choose a distance scale \(d_0=2.5\) and define the unnormalized weight \(u_{qa}=s_a\{\max(0,1-d_{qa}/d_0)\}^2\). This construction gives more influence to anchors that are both nearby and highly scored, and gives zero influence beyond \(d_0\). The normalized weights sum to one. This is an explicit toy kernel, rather than a claim that every implementation uses this exact formula.
Worked Example: Correcting One Query Cell
For a hypothetical query cell \(Q^*\), suppose distances to \(a_1,a_2,a_3\) are \(1.0,0.5,2.0\), respectively. Use the scores and vectors above.
The unnormalized weights are \(u_{Q^*1}=0.90(1-1.0/2.5)^2=0.90(0.6)^2=0.324\), \(u_{Q^*2}=0.80(1-0.5/2.5)^2=0.80(0.8)^2=0.512\), and \(u_{Q^*3}=0.60(1-2.0/2.5)^2=0.60(0.2)^2=0.024\). Their sum is \(0.324+0.512+0.024=0.860\). Thus the normalized weights are \(0.324/0.860=0.3767\), \(0.512/0.860=0.5953\), and \(0.024/0.860=0.02791\), to four significant figures.
The correction is \[ \hat{c}_{Q^*} =0.3767(-1.0,0)+0.5953(-1.2,0)+0.02791(-0.8,-0.2) \approx(-1.113,-0.00558). \] If \(Q^*\)'s original correction-space coordinate is \((6,2)\), its corrected coordinate is approximately \((6,2)+(-1.113,-0.00558)=(4.887,1.994)\). The units are those of the correction-space coordinates. Most of the adjustment comes from \(a_2\), because it is both closer than \(a_1\) and still well supported; \(a_3\)'s contribution is small because it is near the kernel boundary.
The normalization step has a simple justification. Since \(w_{qa}=u_{qa}/\sum_bu_{qb}\), summing over anchors gives \(\sum_aw_{qa}=\sum_au_{qa}/\sum_bu_{qb}=1\). Consequently, \(\hat{c}_q\) is a convex weighted average of the contributing correction vectors: it cannot move beyond their convex hull. This does not guarantee a biologically appropriate correction; it only describes what the weighting calculation does.
Check alignment without erasing cell states
A low batch discrepancy is not sufficient evidence of successful integration. The analysis should also check whether known biological states remain distinct. Suppose independent markers identify two shared states, \(S_1\) and \(S_2\), plus a query-only state \(C\). In a hypothetical summary, the state centroids along a biological-state coordinate are \(0\) for reference \(S_1\), \(10\) for reference \(S_2\), \(1\) for query \(S_1\), \(11\) for query \(S_2\), and \(20\) for query \(C\), both before and after the proposed batch correction.
Worked Example: Assessing State Alignment and Conservation
Before correction, the cross-dataset centroid differences for the shared states are \(1-0=1\) unit for \(S_1\) and \(11-10=1\) unit for \(S_2\). After correction, suppose the query centroids become \(0\) and \(10\), respectively. The corresponding differences are then \(0\) and \(0\) units: this summary indicates improved alignment of the shared states.
Now check biological separation. The reference distance between \(S_1\) and \(S_2\) is \(10-0=10\) units before and after correction. The query distance between \(S_2\) and the condition-specific state \(C\) is \(20-11=9\) units before correction. If the correction leaves \(C\) without a supported anchor-based shift, that distinction remains; forcing its centroid to \(10\) would instead erase the separation. The example therefore supports shared-state alignment only when considered together with preservation of the independently identified states.
In a real analysis, these centroid checks are summaries, not a complete assessment. Inspect cell-level distributions, marker patterns, neighborhood structure, and anchor coverage across states. A state represented by only a few cells may have an unstable centroid, and a good average can conceal poorly aligned subgroups. Also check whether cells in a condition-specific state received substantial correction despite weak or absent shared-state evidence.
Assumptions, diagnostics, and alternatives
The workflow assumes that the shared representation makes biologically corresponding cells sufficiently close to be found; that at least some cell states are genuinely shared across datasets; and that the features used for filtering and correction have been prepared comparably. It also assumes that the correction vectors are meaningful local estimates of technical displacement. If condition and batch are completely confounded, or if the relevant state has no counterpart, anchor evidence alone cannot identify which difference is technical and which is biological.
Useful diagnostics include the number and distribution of retained anchors, the fraction of candidate anchors rejected, score distributions, and the distances from cells to the anchors that influence them. Map anchors back to cell-state labels or independent markers where available. Large numbers of low-scoring anchors, anchors concentrated in one state, strong directional imbalance, or substantial corrections for cells far from well-supported anchors are warning signs. Sensitivity to reasonable changes in neighbor counts or filtering thresholds is also informative: highly unstable results should not be presented as a uniquely determined alignment.
Anchor-based local correction differs from applying a single global shift: separate neighborhoods can receive different weighted corrections. An unweighted average treats all contributing anchors equally and ignores the reliability and proximity distinctions used here. Leaving the query uncorrected avoids potentially false alignment but retains technical differences. Reference-based mapping can project query cells to a reference without treating every query cell as evidence for a pairwise correction; it is useful for annotation, but its output and goal are not identical to correcting a joint representation. These alternatives do not remove the need to check whether shared biological states are actually present.
Check Your Understanding
Answer each question, then compare with the solutions below.
- If a pair is reciprocal in the shared representation but fails the stated neighborhood filter, should it contribute to the correction? Explain.
- For unnormalized weights \(0.30\) and \(0.70\), what are the normalized weights?
- Why is a high anchor score not a probability that an anchor is biologically correct?
- What should be investigated if a query-only state receives large corrections toward a reference state?
Solutions. (1) No. Under the specified workflow, filtering determines which candidates are retained; reciprocity alone is not enough. (2) Their sum is \(1.00\), so the normalized weights remain \(0.30\) and \(0.70\), which sum to one. (3) The score summarizes local reliability under a chosen scoring rule; it is not calibrated as a probability of biological truth. (4) Check whether the state has a genuine counterpart, whether its apparent anchors pass neighborhood checks, and whether the correction is being extrapolated from inappropriate anchors. A condition-specific state should not be forcibly aligned merely to improve batch mixing.