This note describes the current cellAdmix admixture scoring methods: bridge scoring, membrane scoring, and coherence scoring. All three methods operate after a fitted cellAdmix run has assigned molecules to NMF factors. The scores are then used to decide which factor molecules should be treated as potential admixture in a target cell type.
The NMF stage identifies molecular factors. Some factors correspond to native cell states. Others may correspond to molecules that entered a segmented target cell from a neighboring, out-of-plane, or otherwise incorrectly segmented source cell. The scoring stage asks a separate spatial question:
For factor
The source identity of a factor and the target evidence for cleanup are related but distinct:
- Source identity asks which annotated cell type best explains the factor.
- Target evidence asks where that factor appears in an unexpected spatial pattern.
Bridge and membrane scoring produce direct target/source/factor summaries. Coherence scoring separates source/factor enrichment from target-cell-local spatial coherence.
Let:
-
$c$ denote a cell. -
$a$ denote an ordered target cell. -
$b$ denote an ordered source cell. -
$T(c)$ denote the annotated cell type of cell$c$ . -
$M_c$ denote the set of molecules assigned to cell$c$ . -
$x_i$ denote the spatial coordinate of molecule$i$ . -
$g_i$ denote the gene of molecule$i$ . -
$z_i$ denote the fitted factor label of molecule$i$ . -
$m_i$ denote the factor assignment margin for molecule$i$ , when available. -
$f$ denote a factor. -
$K$ denote the number of fitted factors.
The number of molecules in cell
The within-cell factor fraction is:
Each method produces scores for ordered triples: target_cell_type,
source_cell_type, and factor.
Most summaries report:
-
mean_score: average evidence score across selected cells or cell pairs. -
p_value: one-sided statistical evidence that observed scores exceed a null or zero baseline. -
neg_log10_p:$-\log_{10}(p)$ , where$p$ is the reportedp_value.
The final cleanup rule for a target cell type is usually based on a threshold
such as p_value < p_thresh, plus method-specific gates.
Bridge scoring looks for factor molecules in a target cell that physically touch or cross toward a neighboring source cell. It is meant to capture a classic segmentation-boundary problem: a target cell contains a factor, and factor-positive molecules sit near the molecular interface with a candidate source cell.
The bridge score combines two ideas:
- The target and source cells differ in how much they contain the factor.
- Factor-positive target molecules are located close enough to source-cell molecules that local molecular neighborhoods cross the target/source boundary.
It is therefore conservative. It needs an explicit target/source cell pair and enough local molecular contact between them.
Bridge scoring first builds ordered candidate cell pairs
Two candidate discovery modes are implemented:
molecule_global: use molecule-level spatial kNN to find cells that contact through nearby transcripts.cell_center: use cell-centroid kNN to nominate nearby cells, then perform exact pair scoring locally.
For each ordered candidate pair, bridge scoring constructs a local spatial kNN index from the molecules in both cells.
For ordered pair
The pair is skipped for factor min_factor_molecules.
For each target molecule crossing_k nearest neighbors
in the two-cell molecule set
Then:
Here, total_crossing_count, and crossing_fraction.
The bridge score is:
The current implementation uses an absolute abundance difference. Directionality
enters through the ordered crossing term
For each target/source cell-type pair and factor:
Groups with fewer than min_pairs are skipped. If the group has more than
max_cells_per_type_pair rows, a bounded subset is selected.
The summary mean score is:
If null computation is enabled, bridge scoring computes matched null scores for the same selected cell pairs. The null procedure attempts to move factor assignments or compare against replacement assignments while preserving the same local pair structure. The summary p-value is a one-sided paired Wilcoxon test:
The output includes mean_null_score, p_value, and neg_log10_p.
Membrane scoring uses a stain image, typically a membrane-like Xenium morphology channel, to ask whether factor-assigned target molecules lie along a source-facing membrane boundary. It is designed for cases where the source cell is visible or partially visible and the target cell contains source-like factor molecules near the physical boundary between cells.
For each target/source cell pair and factor, the method compares stain signal along rays from factor molecules to the target-cell centroid against control rays from other target-cell molecules at similar radial distance. This controls approximately for the fact that peripheral molecules see more membrane signal than central molecules.
Membrane scoring uses cell centroid candidates. For each active target cell, it queries nearby source cells by centroid distance. Candidate pairs may be filtered by a halo around estimated cell radii:
where
Candidates are grouped by ordered target/source cell type and capped by
candidate_pairs_per_type_pair.
The stain image is read in physical coordinates. Image intensities are sampled
by bilinear interpolation. For score computation, the image is usually robustly
normalized to
Let
In code, this is the maximum sampled line signal along the molecule-to-centroid segment.
For ordered pair
For factor molecule
The tolerance is based on:
The per-molecule membrane score is:
The pair/factor score is the mean over scored factor molecules:
The pair output also reports:
These are stored as fraction_positive and mean_directional_weight.
Pairs/factors with fewer than min_factor_molecules target molecules are
skipped.
For each target/source cell-type pair and factor:
The highest-scoring rows are kept up to max_cells_per_type_pair; groups with
fewer than min_pairs are skipped.
The summary reports:
These are stored as mean_score, q75_score, and
fraction_positive_pairs. The p-value is a one-sided Wilcoxon signed-rank test
against zero:
Thus membrane scoring asks whether source-facing factor molecules see more membrane signal than radial control molecules in the same target cells.
The factor source score is not itself a cleanup score. It asks whether the gene loading profile of a factor resembles marker expression for a particular annotated cell type. It is useful as a source prior for bridge and membrane scoring.
For each annotated cell type min_marker_logfc, optionally restricted to the top
top_markers_per_type genes), raised to specificity_power. The factor's
non-negative loading vector factor_power) is then compared
to each type's weight vector by cosine similarity:
The implementation reports, per factor × cell type, the score, its rank
among types, the factor's best_score and second_score, their difference
as margin, and an is_best flag. The source prior uses the best-scoring
cell type per factor, with margin measuring how decisive the call is.
Coherence scoring does not require an explicit source cell. Instead, it asks whether source-like factor molecules form locally coherent patches inside a target cell type. This helps when the source may be out of plane, partially visible, missing from segmentation, or otherwise not well represented by a source cell pair.
Coherence has two distinct components:
- A source/factor prior based on how enriched a factor is in each annotated source cell type.
- A target-cell-local spatial coherence score based on molecular kNN structure inside each target cell.
If a membrane image is supplied, same-factor molecular graph edges can be downweighted when they cross strong membrane signal. This does not make coherence a membrane score; it prevents the local molecular graph from connecting patches across membrane barriers too easily.
For source cell type
With pseudocount
where type_fraction, other_fraction, source_log_enrichment, and
source_probability.
By default, the R annotation layer uses source_probability to call the source
cell type for each factor. Target cleanup evidence is then evaluated
source-conditionally: the relevant row is (target type, inferred source type, factor).
For each target cell
If no membrane image is used, edge weights are based on distance or are equal weights. If membrane barrier mode is used, edge weights are multiplied by:
where
For target cell
The row is skipped if min_factor_molecules.
For each selected molecule
The local same-factor support is:
The final molecule score is:
The per-cell mean coherence score is:
The output also records:
These are stored as mean_raw_score, mean_coherence_score, and
active_fraction.
The patch score is intended to identify a compact local group of source-like factor molecules rather than just a diffuse cell-wide mean.
For each selected seed molecule
The local patch mean is:
The patch size weight is:
The per-cell patch score is:
The implementation also computes largest_patch_fraction as a diagnostic: it
is the size of the largest connected component of selected factor molecules,
using graph edges with
For each target cell, source type, and factor, coherence samples matched null
subsets with the same number of molecules as
For each null subset, coherence recomputes the mean and patch scores, producing cell-level null expectations $\bar{s}{aSf}^{\mathrm{mean,null}}$ and $\bar{s}{aSf}^{\mathrm{patch,null}}$.
The per-cell deltas are:
For each target/source cell-type pair and factor:
The summary reports mean_score, mean_null_score, mean_delta_score,
mean_patch_score, mean_null_patch_score, mean_delta_patch_score, and
mean_largest_patch_fraction.
The mean p-value tests:
The patch p-value tests:
The R annotation layer currently uses patch p-values by default when available,
equivalent to score_mode = "patch". It can also use score_mode = "mean" or
score_mode = "combined", where combined requires both mean and patch
evidence.
The plotting/correction layer collapses target/source/factor summaries into factor-level source calls and target cleanup calls.
For coherence:
- Source calls default to the source cell type with highest
source_probability. - Target cleanup calls are source-conditioned: for factor
$f$ , if source $S^$ is inferred, target evidence is evaluated from row $(T,S^,f)$. - Cleanup calls can be gated by
p_thresh,min_delta_score,min_delta_patch_score,min_largest_patch_fraction,min_cells, andmin_molecules.
For bridge and membrane:
- Source calls are inferred from target/source/factor score summaries during annotation collapse.
- Cleanup calls are based on target evidence passing the p-value threshold, excluding the inferred source cell type itself.
This distinction matters: source identity should be interpreted as a factor annotation, while cleanup calls are target-specific evidence.
Correction rules generated from any score pass a false-positive control by
default (native_check = TRUE in rules()): a counterfactual test of whether
the factor is native to the target cell type rather than admixed into it. A
factor can be genuinely expressed by a target type that is biologically
related to the inferred source — for example a malignant-cell factor in
epithelial cells — in which case removal would delete native signal.
For a rule removing factor keep = FALSE) when any of
the following holds:
- Native persistence: $\mathrm{median}{a \in D}(x{af}) > 0.1$ — the factor persists in target cells with no source contact.
-
Cross-type outlier: the fraction of source-distant
$T$ cells with$x_{af} > 0.05$ exceeds$Q_3 + 1.5,\mathrm{IQR}$ of the same rate computed over all cell types except the source (the target's own rate is included in the reference), and exceeds$0.1$ — the target expresses the factor distinctly even in isolation. - No exposure gradient: $\mathrm{mean}{a \in E}(x{af}) - \mathrm{mean}{a \in D}(x{af}) < 0$ — source proximity does not explain the signal.
- Unverifiable: the source or target type is absent from the annotation, fewer than two source-distant or source-exposed cells exist, or the factor is not expressed in either group. Rules that cannot be verified are excluded to be safe.
Flagged rules stay in the returned rule table with the reason in the
native_check column and the supporting evidence
(native_distant_median, native_exposure_gradient,
native_distant_expr_frac, group sizes); correction skips rules with
keep = FALSE. The source-exposure stratification uses the same
cell-neighborhood construction as the neighbor-enrichment score: enrichment
reads the positive direction (exposed target cells carry more of the factor),
while this check reads the negative control (unexposed cells still carry it).
Strengths:
- Directly uses molecule-level adjacency between target and source cells.
- Provides high-specificity evidence for segmentation-boundary transfer.
- Does not require stain images.
- Uses a paired null model for the same local cell-pair structure.
Weaknesses:
- Requires an explicit visible or segmented source cell.
- Can miss out-of-plane sources, partial cells, or missing source cells.
- Can be conservative when molecule crossing is sparse.
- Runtime can become high if too many target/source pairs are scored.
Strengths:
- Uses independent imaging evidence.
- Can detect source-facing boundary effects even when molecule contacts are sparse.
- Radial controls reduce simple center-versus-periphery artifacts.
- Often works well on Xenium datasets with membrane-like morphology channels.
Weaknesses:
- Requires a useful stain image and correct image registration.
- Can be less informative when source cells are out of plane or not visible.
- Can confuse true membrane enrichment with other peripheral biological compartments if controls are insufficient.
Strengths:
- Does not require an explicit source cell.
- Can detect source-like molecular patches inside target cells.
- Can optionally incorporate membrane barriers without requiring a visible source pair.
- Separates source prior and target evidence.
Weaknesses:
- Depends more strongly on factor source priors.
- Patch statistics and null models are less direct than bridge or membrane scoring.
- Can be sensitive to molecule density, cell size, and local graph parameters.
- Current null models are approximate and may need dataset-specific validation.