What Label-Transfer Accuracy Measures
Integration methods are often used to align cells across batches or datasets. One way to assess whether an integrated representation retains information about cell identity is to use it for label transfer: labels from a reference dataset are used to predict labels for query cells. The benchmark then compares those predictions with independently established query labels. The resulting accuracy measures performance of the complete transfer procedure on that benchmark; it is not a direct measurement of integration quality alone.
The distinction matters because transfer also depends on the reference, the prediction rule, the label definitions, and the query cells. A method may appear accurate because the query contains mostly an easy, common cell type, or because reference information leaked into prediction. A useful benchmark therefore states which cells and labels are being evaluated, how transfer is performed, and how class frequencies and annotation uncertainty are handled.
This calculation assumes that the evaluation labels are a suitable benchmark for the target labels, that the transfer procedure has not used those labels to make its predictions, and that each evaluated cell is counted once. The labels must also have consistent meanings across reference and query. If one dataset uses a broad label and the other uses fine subtypes, a mismatch may reflect different definitions rather than an integration failure.
A clean design keeps query labels out of model fitting, feature selection, tuning, and transfer decisions. Reference labels may be used to train the transfer rule, but query labels should be held back for evaluation. If cells from the same donor or sample are dependent, cell-level accuracy still describes the observed cells, but treating every cell as independent can make uncertainty appear smaller than it is. Where uncertainty intervals are needed, resampling donors or samples is generally more defensible than resampling individual cells alone.
Class Imbalance and Balanced Accuracy
Overall accuracy weights each cell equally. Consequently, it weights a class in proportion to its frequency in the query set. That is appropriate when the target is the fraction of cells correctly labeled in a query population with that particular composition. It can be inadequate when the benchmark should give rare and common classes equal importance.
For class \(j\), its recall (also called sensitivity) is the proportion of cells with reference label \(j\) that were assigned label \(j\). Balanced accuracy is the unweighted mean of those class-specific recalls:
The row total in the denominator is the number of query cells in class \(j\). Balanced accuracy gives each represented class equal weight, regardless of how many cells it contributes. It is not a replacement for overall accuracy: the two answer different questions. If the target is performance on the observed cell mixture, report overall accuracy; if equal class importance is intended, also report balanced accuracy and the class-specific recalls.
Worked Example: Common and Less Common Cell Types
Suppose a hypothetical query contains 80 cells in three independently assigned classes. Its confusion matrix is:
| Reference label | Predicted A | Predicted B | Predicted C | Row total |
|---|---|---|---|---|
| A | 45 | 4 | 1 | 50 |
| B | 8 | 10 | 2 | 20 |
| C | 3 | 2 | 5 | 10 |
There are \(45+10+5=60\) correct predictions, so overall accuracy is \(60/80=0.750\), or 75.0%. The class-specific recalls are \(45/50=0.900\) for A, \(10/20=0.500\) for B, and \(5/10=0.500\) for C. Therefore:
The overall result is 75.0%, but the equal-class summary is 63.3%. This difference arises because class A is half the query and has much higher recall than B or C. Neither number is an arithmetic error: overall accuracy describes the observed mixture, while balanced accuracy gives each of the three classes one-third of the weight.
A short justification makes the weighting explicit. Write \(n_j=\sum_k C_{jk}\) for the number of query cells in class \(j\). Overall accuracy can be rewritten as:
Thus, overall accuracy is a weighted mean of recalls, with class weights \(n_j/n\). Balanced accuracy replaces those observed class weights with equal weights \(1/K\). This explains why the metrics can diverge when class frequencies and recall differ.
Uncertain Reference Labels
A reference label is not always a certain truth. An annotation may be ambiguous, supported by limited markers, or assigned at a resolution coarser than the biological variation in the data. Reporting a single hard label as unquestionable ground truth can make a disagreement look like a transfer error even when the annotation itself is uncertain.
When annotation uncertainty is represented as a probability distribution, let \(q_{ij}\) be the probability or adjudicated weight that query cell \(i\) belongs to class \(j\), with \(q_{ij}\geq 0\) and \(\sum_{j=1}^{K}q_{ij}=1\). If the transferred label is \(\hat y_i\), an expected accuracy is the mean weight assigned by the annotation distribution to that transferred class:
This quantity is an expected match under the supplied label distributions, not a statement that those distributions are known objective probabilities. Its interpretation depends on how the uncertainty weights were constructed. If only hard labels are available, do not invent probability weights; instead, report sensitivity to defensible alternative annotations or separately evaluate a set of high-confidence labels.
Worked Example: Expected Accuracy With Ambiguous Annotations
In a hypothetical set of four query cells, the transfer rule predicts A, B, B, and C. Independent annotation review gives probabilities of the predicted label equal to 0.80, 0.60, 0.25, and 0.90, respectively. The expected number of matches is the sum of these four weights:
The expected accuracy is \(2.55/4=0.6375\), or 63.75%. This is not the ordinary fraction of hard labels matched. For comparison, if each cell were assigned its most probable annotation class, the first, second, and fourth predictions would match, while the third would not; hard-label accuracy would be \(3/4=0.750\). The two results answer different questions, so the benchmark should state which annotation representation it uses.
If the transfer method produces class probabilities rather than only a winning label, accuracy discards the confidence information: predictions with probabilities 0.51 and 0.99 for the selected class count equally when both are correct. A probability-based score can be reported as a supplement when uncertainty in the predictions is itself relevant, but it should not be conflated with label accuracy. When the reference labels are uncertain too, both sources of uncertainty should be described rather than treating the transferred probabilities as if they resolved annotation ambiguity.
Query States Missing From the Reference
A label-transfer rule cannot reliably assign a reference class to a biological state that is not represented by any reference cell. In a closed-set procedure that must choose one of the available labels, it will still output a label, possibly with high confidence. That output does not demonstrate that the query state is represented or correctly identified.
Separate support from correctness. A query cell is supported for closed-set transfer when its independently established label is present among the reference classes. The supported fraction is the number of supported query cells divided by the total number evaluated. Accuracy conditional on support is the fraction correctly labeled among supported cells. These quantities describe different aspects of the benchmark and should be reported together when query states are missing from the reference.
Worked Example: Separating Accuracy From Reference Coverage
Suppose a hypothetical query has 30 annotated cells: 24 belong to states represented in the reference and 6 belong to state D, which is absent from the reference. A forced closed-set transfer correctly labels 21 of the 24 supported cells. Its supported fraction is \(24/30=0.800\), and its accuracy conditional on support is \(21/24=0.875\). If all 30 cells were instead scored as though their labels were available reference classes, the 6 D cells could not be correctly assigned by that closed-set rule; the resulting \(21/30=0.700\) would combine transfer accuracy on represented states with the presence of an unsupported state.
If the intended task includes detecting unsupported states, the transfer procedure needs a reject or “unknown” option and the benchmark needs a separate evaluation of that decision. For example, if it rejects 5 of the 6 D cells, its sensitivity for rejecting these unsupported cells is \(5/6=0.833\). If it also rejects 2 of the 24 supported cells, it retains \(22/24=0.917\) of supported cells. Those rates do not by themselves tell how accurately the accepted supported cells were labeled; that should be calculated separately. Reporting all of these avoids disguising an open-set detection problem as ordinary accuracy.
Benchmark Design, Diagnostics, and Alternatives
A defensible comparison uses the same reference-query split, label definitions, and evaluation set for each integration method. The transfer procedure should also be specified: for example, the representation supplied to it, the prediction rule, and any rejection threshold. If these choices differ between methods, an accuracy difference cannot be attributed to integration alone. Where a query label helped select parameters or choose the best result, the evaluation is no longer an independent assessment of that choice.
Inspect the confusion matrix rather than relying only on one summary. It shows which classes are confused, whether errors are concentrated in one class, and whether a class has too few query cells for a stable recall estimate. Also check that every reported class has a nonzero denominator; recall for a class absent from the query is undefined, not zero. An absent class should not be silently included in the balanced-accuracy average.
| Summary | What it emphasizes | Main limitation |
|---|---|---|
| Overall accuracy | Fraction correct in the observed query mixture | Common classes dominate when class frequencies are unequal |
| Balanced accuracy | Mean recall across represented classes | Ignores class prevalence and can be unstable for small classes |
| Class-specific recall and confusion matrix | Errors by reference class and predicted class | Requires interpretation across multiple entries rather than one score |
| Coverage with conditional accuracy | Separates reference support from performance on supported cells | Does not evaluate unknown-state detection unless rejection is explicitly assessed |
Several failure modes deserve particular attention. If reference and query cells are not kept separate during fitting, apparent performance can be inflated by information leakage. If a broad reference label is compared with fine query labels, label granularity can create artificial errors. If class frequencies differ substantially, overall accuracy alone can conceal poor performance for less common classes. If labels are uncertain, a hard-label score can overstate the certainty of the benchmark. Finally, cell-level results may be dominated by a donor with many cells; summarize or resample at the donor or sample level when the scientific target is performance across donors or samples.
No single accuracy measure establishes that integration has preserved all relevant biology. High label-transfer accuracy shows that the chosen labels remain predictable under the specified transfer setup; it does not establish that every biological distinction is preserved, that batch effects have been removed appropriately, or that a transferred label is causally or biologically definitive. Interpret the metric alongside the benchmark target and the other evidence used to assess integration.
Common Mistake
Check Your Understanding
Answer each question, then compare your reasoning with the solutions.
- A query has 90 cells in class A and 10 in class B. The transfer rule correctly labels 81 A cells and 4 B cells. Calculate overall and balanced accuracy.
- Why is recall undefined for a class that has no query cells, rather than equal to zero?
- Four cells receive predictions A, A, B, and C. Their annotation weights for the predicted classes are 0.7, 0.4, 0.8, and 0.5. Calculate expected accuracy.
- A reference contains A and B but not D. Explain why the fraction of query cells in D should be reported separately from accuracy conditional on represented states.
- Name one design choice that could make label-transfer accuracy an unfair comparison of two integration methods.
Solutions. (1) There are \(81+4=85\) correct predictions among 100 cells, so overall accuracy is \(85/100=0.850\). Recalls are \(81/90=0.900\) for A and \(4/10=0.400\) for B; balanced accuracy is \((0.900+0.400)/2=0.650\). (2) Recall divides correct predictions by the number of query cells in that class. With no such cells, the denominator is zero, so the quantity is undefined; there is no evidence about recall for that class in this query. (3) Expected accuracy is \((0.7+0.4+0.8+0.5)/4=2.4/4=0.600\). (4) D is unsupported by the reference, so a forced closed-set prediction cannot demonstrate correct identification of D. Reporting its fraction distinguishes the prevalence of unsupported states from transfer performance among states the reference can represent. (5) Examples include using different query splits, label definitions, or transfer rules for the two methods, or allowing query labels to influence tuning for only one method. Such differences confound the comparison with factors beyond integration.