Why Weight Corrections Locally?
An anchor pair supplies evidence about how two batches differ near a particular cell state. But an anchor that is reliable overall may be a poor guide for a query cell far from that pair. Conversely, a nearby pair may be a weak match. Weighted correction combines these two considerations: how trustworthy the anchor is and how close it is to the query cell.
The result is a query-specific correction vector: different cells can receive different weighted combinations of the same anchor corrections. The weights are a device for local interpolation, not probabilities that the anchors are true. This tutorial defines one standard kernel-weighted construction; practical implementations can differ in how they score anchors, measure distance, or choose the bandwidth.
Definition and Assumptions
Suppose an anchor pair \(l\) links a cell in a reference batch to a cell in a query batch. Let \(z_l\) be the query-side anchor's coordinate in the shared space used to assess local proximity, and let \(u_i\) be query cell \(i\)'s coordinate in that space. Let \(s_l\) be the anchor's nonnegative reliability score. The expression correction vector for anchor \(l\), denoted \(\Delta_l\), is the reference-side expression profile minus the query-side expression profile, using the same genes, order, and expression scale for both profiles. This orientation means that adding \(\Delta_l\) moves a query-batch profile toward the reference-side profile.
A common choice is the Gaussian kernel \(K(t)=\exp(-t^2/2)\). It is positive and decreases as distance increases, so an anchor receives less distance weight as its query-side cell lies farther from the query cell. The bandwidth \(h\) controls the rate of that decrease: a larger \(h\) makes distances less discriminating, while a smaller \(h\) emphasizes only nearby anchors. The reliability score and kernel value are multiplied before normalization, so either a low score or a large distance can reduce an anchor's influence.
The construction is meaningful under several conditions. Scores should be nonnegative and comparable across the anchors being combined; correction vectors must share a common orientation and expression scale; and the chosen shared space should represent the local relationships relevant to the correction. In addition, the query should have adequate nearby anchor support. If all products \(a_{il}\) are zero, the normalized weights are undefined, and the method must flag the cell or use a separately specified fallback rather than silently divide by zero.
Why the Weighted Average Is the Local Correction
One justification is to choose the correction vector closest, in weighted squared distance, to the corrections suggested by the available anchors. For a fixed query cell, consider a candidate correction \(c\) and the criterion
Assume the products \(a_{il}\) are nonnegative and their sum is positive. Expanding the squared norms gives
The last term does not depend on \(c\). Differentiating with respect to \(c\) and setting the gradient to zero yields
The quadratic coefficient \(\sum_l a_{il}\) is positive, so this stationary point is the unique minimizer. This derivation explains the weighted average; it does not establish that the anchor corrections are biologically appropriate or that the scores and distances are well calibrated. Those are substantive choices that need checking.
Calculating Weights and Corrections
Worked Example: Combining Reliability and Distance
Suppose a query cell has three candidate anchors. For a Gaussian kernel, the anchor scores and distance-kernel products give unnormalized weights \(a_{i1}=0.8308\), \(a_{i2}=0.3639\), and \(a_{i3}=0.0834\). These products reflect both the anchor scores and the query-to-anchor distances. The corresponding correction vectors for two genes are \(\Delta_1=(2,0)\), \(\Delta_2=(0,2)\), and \(\Delta_3=(-1,1)\), in expression units.
First normalize. The total unnormalized weight is \(0.8308+0.3639+0.0834=1.2781\). Thus the normalized weights are approximately \(0.8308/1.2781=0.6500\), \(0.3639/1.2781=0.2847\), and \(0.0834/1.2781=0.0653\). They sum to approximately one.
For gene 1, the correction is \(0.6500135(2)+0.284727(0)+0.065260(-1)=1.2348\) expression units, to four decimal places. For gene 2, it is \(0.6500135(0)+0.284727(2)+0.065260(1)=0.6347\) expression units. The query profile therefore receives an estimated correction of approximately \((1.2348,0.6347)\), which is added to its original two-gene profile.
The first anchor dominates because its score-distance product is largest. The third anchor still contributes, but its negative correction for gene 1 reduces the net gene 1 adjustment. A positive score alone does not guarantee a large influence: it is the product of score and distance kernel, followed by normalization, that determines influence.
Worked Example: A Nearby Anchor Can Have a Conflicting Correction
For a second query cell, suppose three anchors produce unnormalized score-kernel products that, after normalization, give weights approximately \(0.4995981\), \(0.2439468\), and \(0.2564551\). The correction vectors for two genes are \((1,0)\), \((0,2)\), and \((-2,0)\), respectively. These weights already reflect both reliability and distance; none of the anchors is discarded.
The first gene's weighted correction, calculated using the unrounded normalized weights, is approximately \(0.4995981(1)+0.2439468(0)+0.2564551(-2)=-0.0133122\) expression units. The second gene's correction is approximately \(0.4995981(0)+0.2439468(2)+0.2564551(0)=0.4878935\) expression units.
The gene 1 result is close to zero because the positive correction from the first anchor is nearly offset by the negative correction from the third. This is not evidence that the query has no batch difference: it may indicate that nearby anchors disagree, or that the anchor set spans different local directions. Looking only at the final average would hide that conflict.
Worked Example: Applying the Correction to a Profile
Consider a query cell with a two-gene profile \(x_i=(5.0,3.0)\) expression units. Suppose two anchor corrections are \(\Delta_1=(1.2,-0.4)\) and \(\Delta_2=(0.2,1.6)\), and their unnormalized score-kernel products yield normalized weights \(0.7913608\) and \(0.2086392\). The weighted correction is
\(0.7913608(1.2,-0.4)+0.2086392(0.2,1.6)=(0.9914,0.0173)\) expression units, using unrounded weights for the calculation.
Adding this to the original profile gives \(x_i^{\mathrm{corr}}=(5.0,3.0)+(0.9914,0.0173)=(5.9914,3.0173)\) expression units. Gene 2's correction is small because one anchor suggests a decrease and the other suggests an increase. This adjusted profile is the result of the specified correction rule; it is not a new raw measurement.
Diagnostics, Alternatives, and Limitations
A normalized weight vector always sums to one, but that fact alone does not show that the correction is stable. Inspect the distances, score-kernel products, and correction vectors as well as the final adjusted values. Useful checks include whether the query has genuinely nearby anchors, whether one anchor dominates, whether influential anchors agree in direction, and whether results change substantially under modest, defensible changes to the bandwidth. In a high-dimensional correction, these checks can be made gene by gene or on selected summaries of the correction vectors.
Several failure patterns deserve particular attention. If all anchors are distant, normalized weights can still look numerically well behaved even though the query is poorly covered. If correction vectors conflict, averaging may cancel them and yield a small adjustment that masks disagreement. If the selected feature space gives misleading distances, the kernel can emphasize the wrong anchors. Finally, if reliability scores are on incomparable scales, multiplying them by the kernel does not produce a meaningful balance between trust and proximity.
| Approach | What determines influence? | Main trade-off |
|---|---|---|
| Weighted correction | Anchor score multiplied by a decreasing distance kernel | Uses both reliability and locality, but depends on score and bandwidth choices |
| Equal-weight correction | All selected anchors receive the same weight | Simple, but ignores differences in reliability and local proximity |
| Nearest-anchor correction | Only the closest anchor, or a small nearest set | Highly local, but can be unstable when a single anchor is atypical |
| Distance-only correction | Distance kernel without reliability scores | Uses locality, but treats weak and strong anchors alike |
These approaches answer different operational needs; none removes the need to assess anchor quality and coverage. Weighted correction also has limits: it interpolates among supplied correction vectors rather than discovering missing states, and it can blur genuine biological differences if batch and biological variation are not distinguishable from the available data. A small correction does not prove successful integration, and a large one does not by itself prove failure. Interpret adjusted values in light of the data scale, local geometry, and the intended analysis.
Common Mistakes
- Using score or distance alone. The defined weight depends on their product \(s_lK(d_{il}/h)\), not either quantity in isolation.
- Reversing the correction direction. With \(\Delta_l=\) reference profile minus query profile, add the weighted correction to the query profile. Reversing the subtraction requires changing the sign consistently.
- Calling weights probabilities. They are normalized influence weights, not probabilities that anchor pairs are correct.
- Assuming normalization guarantees coverage. Even distant anchors can be normalized to sum to one; inspect absolute distances and local support.
- Rounding too early. Normalize and combine using unrounded values when available, then round the reported weights and corrections. Small premature rounding can change the last displayed digit.
Check Your Understanding
Answer each question, then compare your reasoning with the solutions.
- For two anchors, suppose the score-kernel products are 0.6 and 0.4, and their scalar corrections are 2 and \(-1\) expression units. What is the weighted correction?
- Why can normalized weights sum to one even when a query cell has poor anchor coverage?
- If every anchor correction vector is multiplied by \(-1\), what happens to the weighted correction, assuming the weights are unchanged?
- What does a very small bandwidth do to the relative influence of distant anchors?
Solutions. 1. The normalized weights are \(0.6/(0.6+0.4)=0.6\) and \(0.4\), so the correction is \(0.6(2)+0.4(-1)=0.8\) expression units. 2. Normalization divides each positive product by their sum, regardless of the absolute distances; distant anchors can therefore have weights summing to one despite weak local support. 3. The weighted correction changes sign, because \(\sum_l w_{il}(-\Delta_l)=-\sum_l w_{il}\Delta_l\). 4. With a small bandwidth, the kernel decreases rapidly as distance increases, so more distant anchors receive much less influence relative to nearby anchors.