Tutorials › Statistical Methods for Single-Cell RNA Sequencing › Troubleshooting Unstable Cluster Assignments

Cluster Validity and Stability · Tutorial 291 of 700

Troubleshooting Unstable Cluster Assignments

Use assignment frequencies and cluster overlap to locate and diagnose unstable cell assignments, then identify which perturbation is associated with the instability.

Advanced 12 min read

What You'll Learn

  • Calculate cell-level assignment frequencies, including an explicit outcome for runs that omit a cell.
  • Interpret assignment entropy without confusing unconditional and conditional frequencies.
  • Use cluster overlap to diagnose splitting, merging, and fragile small groups.
  • Separate seed variation from sensitivity to preprocessing choices.
  • Recognize what stability summaries can and cannot establish.

From an instability score to a diagnosis

A summary can show that a clustering changes across runs without showing why it changes. A cell might sit between two populations, belong to a small group that is inconsistently recovered, or change assignment when preprocessing changes. Alternatively, the same input may yield different results because the clustering algorithm is stochastic. These explanations call for different checks; a single overall stability score cannot distinguish them.

The aim here is to use cell-level assignment frequencies and cluster-level overlap together, while varying one source of perturbation at a time. The resulting patterns are diagnostic evidence, not proof that a cluster is a biologically true population. Earlier material on matching clusters across resampled runs established why cluster labels must be aligned before comparing them: labels such as “cluster 1” are arbitrary and may switch between runs.

Definition: Suppose \(R\) clustering runs are compared and their cluster labels have been matched to a common set of labels \(1,\ldots,K\). For cell \(i\), let \(n_{ik}\) be the number of runs that include the cell and assign it to matched cluster \(k\). Let \(m_i=\sum_{k=1}^{K}n_{ik}\) be the number of runs that include the cell. Define the unconditional assignment frequency \(q_{ik}=n_{ik}/R\), and define the omission frequency \(q_{i0}=(R-m_i)/R\). The outcomes \(0,1,\ldots,K\) then have frequencies that sum to one. The assignment entropy is \(H_i=-\sum_{k=0}^{K}q_{ik}\log(q_{ik})\), with \(0\log(0)=0\). It measures variation across both cluster assignments and omission.

Including omission is essential when runs do not all contain the same cells: the matched-cluster frequencies alone then need not sum to one and cannot be used as a probability distribution in the entropy formula. If the question is specifically about assignment conditional on inclusion, use \(r_{ik}=n_{ik}/m_i\) for \(m_i>0\) and calculate \(H_i^{\mathrm{incl}}=-\sum_{k:r_{ik}>0}r_{ik}\log(r_{ik})\). This conditional entropy describes assignments among runs in which the cell appears; report the omission frequency separately. If \(m_i=0\), conditional assignment entropy is undefined.

Entropy is in natural-log units when \(\log\) denotes the natural logarithm. Zero entropy means all observed outcomes are the same; higher entropy means outcomes are more evenly distributed. Its maximum depends on the number of possible outcomes. For example, with two cluster outcomes and no omissions, the maximum is \(\log(2)\), attained when the two frequencies are both one-half. Entropy is not a probability that a cell is misclassified.

Why entropy responds to mixed assignments

The formula is the average surprisal of the outcomes: an outcome with frequency \(q\) contributes surprisal \(-\log(q)\), weighted by its frequency \(q\). Thus \(H=-\sum q\log(q)\). For \(L\) possible outcomes, the uniform distribution has entropy \(\log(L)\), and no distribution over those outcomes has larger entropy. One justification uses the nonnegativity of Kullback–Leibler divergence from \(q\) to the uniform distribution \(u_j=1/L\):

$$ \sum_{j:q_j>0}q_j\log\left(\frac{q_j}{1/L}\right)\geq 0 \quad\Longrightarrow\quad \sum_j q_j\log(q_j)+\log(L)\geq 0 \quad\Longrightarrow\quad -\sum_j q_j\log(q_j)\leq\log(L). $$

This bound explains why raw entropy values should not be compared casually when the number of possible outcomes differs. Entropy also does not identify the cause of variation: a balanced split between two clusters and a mixture involving omissions can both yield uncertainty, but they indicate different problems.

Worked Example: Finding a Boundary Cell

Suppose a hypothetical analysis repeats clustering 10 times on the same cells, using one fixed preprocessing pipeline but different random seeds. After matching labels, a cell is assigned to cluster A in 5 runs and cluster B in 5 runs; it is included in all 10. Neighboring cells in the same local region are assigned to A in all 10 runs.

For the cell of interest, \(q_{iA}=5/10=0.5\), \(q_{iB}=5/10=0.5\), and \(q_{i0}=0\). Its entropy is

$$ H_i=-[0.5\log(0.5)+0.5\log(0.5)]=0.6931. $$

This is the maximum possible entropy for two assignment outcomes. The neighboring cells have entropy \(-1\log(1)=0\). Because preprocessing is held fixed, this pattern is consistent with seed-sensitive assignment for a cell near a cluster boundary. It is not enough to establish that the cell is biologically intermediate: inspect its position relative to the two groups and check whether the same pattern occurs under other controlled perturbations.

Cluster overlap reveals group-level failures

Cell frequencies show which cells move, but a small group may be unstable even when most of its members do not have high entropy individually. Cluster overlap supplies a group-level view. For two runs, restrict attention to the cells present in both runs. If \(C\) and \(D\) are the sets assigned to a matched cluster in those runs, their Jaccard overlap is \(J(C,D)=|C\cap D|/|C\cup D|\). It ranges from 0, for disjoint sets, to 1, for identical sets. Restricting to shared cells avoids treating a cell absent from one run as though it had been assigned to a different cluster. Record coverage or omissions separately.

A matched cluster with low overlap may have split across multiple clusters or merged with another group. A single best match can conceal either pattern, so inspect the overlap with the next-best cluster too. Matching is useful for comparing labels, but it does not make a one-to-one match a complete description of a split or merge. For small groups, even a few changed cells can greatly alter the overlap; interpret the value alongside the cluster’s size and the cell-level frequencies.

Worked Example: Diagnosing a Fragile Small Group

In a hypothetical pair of runs, both containing 100 common cells, a rare reference cluster \(C\) contains 8 cells. The best-matching cluster \(D\) in the second run contains 4 of those cells and no other cells. Thus \(|C\cap D|=4\), and \(|C\cup D|=8+4-4=8\). The Jaccard overlap is \(4/8=0.500\).

Suppose a large cluster in the same pair has 60 cells in the first run and 58 in the second, with 55 shared members. Its union has \(60+58-55=63\) cells, so its Jaccard overlap is \(55/63=0.8730\). The rare cluster has lower overlap, but the comparison alone does not show whether its instability is unusually severe: a small number of changes has a larger proportional effect in a small group.

Now inspect assignments across 10 runs. If the rare group’s 8 reference cells are repeatedly split among several clusters, that supports a recovery or split/merge problem. If most cells remain together but one or two switch, the low overlap may largely reflect the small denominator. Check the next-best overlaps and cell-level frequencies before concluding that the group disappears.

Separate the perturbations

A useful diagnostic design changes one factor at a time, or crosses factors so their contributions can be compared. To assess stochastic variation, hold the cells and preprocessing fixed while changing random seeds. To assess preprocessing sensitivity, compare pipelines while holding seeds or other algorithm settings as comparable as possible. If data resampling is part of the design, distinguish cells omitted by a resample from cells assigned to a different cluster. Frequencies describe the perturbation scheme actually used; they are not automatically population probabilities.

Consider a crossed design with two preprocessing pipelines, each run with three seeds. For a particular cell, suppose the cell is assigned to cluster A in all three runs under pipeline P1 and cluster B in all three runs under pipeline P2. Pooling all six runs gives \(q_{iA}=3/6=0.5\) and \(q_{iB}=3/6=0.5\), hence \(H_i=0.6931\). But within each pipeline the cell has zero entropy. The pooled instability is therefore associated with the preprocessing choice, not with seed variation within either pipeline. This is why pooled assignment frequencies should be read alongside stratified frequencies.

Cluster-overlap summaries can make the same distinction at the group level: compare runs within a pipeline and then compare the matched groups between pipelines. High within-pipeline overlap but low between-pipeline overlap points to preprocessing sensitivity. Low overlap among different seeds under the same pipeline points to seed sensitivity. If both are low, both factors may matter, or the clustering may respond to their interaction.

Worked Example: Separating Seed and Preprocessing Effects

In a hypothetical crossed analysis, two pipelines are each run with four seeds on the same 200 cells. After matching labels, the median Jaccard overlap for a cluster across seed pairs is 0.92 within pipeline P1 and 0.90 within P2. Comparing the corresponding clusters between pipelines gives a Jaccard overlap of 0.48. A cell under investigation is assigned to cluster 1 in all four P1 runs and cluster 2 in all four P2 runs.

Within P1 and within P2, this cell’s assignment entropy is zero: each pipeline gives a consistent assignment across seeds. Pooling the eight runs gives frequencies \(q_{i1}=4/8=0.5\) and \(q_{i2}=4/8=0.5\), so \(H_i=0.6931\). The contrast between high within-pipeline overlap and lower between-pipeline overlap, together with the cell’s pipeline-specific assignments, is evidence that the chosen preprocessing affects the cluster structure. It does not establish which pipeline is correct. Check whether the differences plausibly arise from choices such as feature selection or normalization, and whether the affected cells are concentrated in particular regions or groups.

Diagnostic workflow and failure modes

1
Check comparability.
Confirm that labels are matched, identify which cells are eligible in each run, and distinguish a missing cell from a cell assigned elsewhere.
2
Locate uncertain cells.
Calculate assignment frequencies and entropy, including omission as an outcome. Examine whether uncertain cells are isolated, concentrated near group boundaries, or shared across a whole group.
3
Inspect group structure.
Compare cluster overlaps on common cells, cluster sizes, and the best and next-best matches. Look for splits, merges, and small groups whose membership changes substantially.
4
Attribute the perturbation.
Compare within-seed, within-preprocessing, and between-preprocessing patterns separately. Do not infer a cause from a pooled frequency alone.

A frequent mistake is to divide assignment counts by the number of runs that included a cell, then interpret the resulting entropy as unconditional stability. That calculation is valid only as entropy conditional on inclusion. The correction is to include omission as an outcome for unconditional entropy, or to label the result explicitly as conditional and report omission separately.

Other warning signs include interpreting a low Jaccard overlap without checking cluster size, treating matched labels as evidence that groups are biologically equivalent, and reading assignment entropy as a calibrated probability of error. If many cells are omitted, compare omission rates across runs and groups; if the included cells differ systematically, conditional frequencies may describe a selected subset. Finally, repeated algorithm runs are not independent biological replicates. Stability supports reproducibility under specified perturbations, not biological truth or causal interpretation.

Alternative summaries answer different questions. Co-association measures how often pairs of cells cluster together and can reveal shared structure without requiring a single cell-to-cluster frequency display. Variation of information compares whole partitions, while cluster overlap focuses on corresponding groups. Neither replaces assignment frequencies for locating individual unstable cells. Use summaries that match the diagnostic question and examine disagreements rather than expecting all measures to rank runs identically.

Key takeaway: Diagnose instability by pairing cell-level assignment frequencies with group-level overlap, and stratify summaries by the perturbation being investigated. Include omissions in unconditional outcome frequencies; use conditional frequencies only when their conditioning on inclusion is explicit.

Check Your Understanding

Answer each question, then compare with the brief solutions.

  1. Across 8 runs, a cell is included 6 times, assigned to cluster A four times and cluster B twice. What are its unconditional outcome frequencies, including omission?
  2. For the cell in question 1, calculate unconditional entropy and conditional-on-inclusion entropy.
  3. Two runs share 50 cells. A cluster has 10 members in the first run, 8 in the second, and 6 in common. Calculate its Jaccard overlap.
  4. A cell has zero entropy within each of two pipelines but high entropy when runs from both are pooled. What does this suggest, and what should be checked next?

Solutions. (1) \(q_{iA}=4/8=0.5\), \(q_{iB}=2/8=0.25\), and \(q_{i0}=2/8=0.25\); these sum to 1. (2) Unconditional entropy is \(-[0.5\log(0.5)+0.25\log(0.25)+0.25\log(0.25)]=1.040\). Conditional frequencies are \(4/6=2/3\) and \(2/6=1/3\), giving entropy \(-[(2/3)\log(2/3)+(1/3)\log(1/3)]=0.6365\). (3) The union has \(10+8-6=12\) cells, so overlap is \(6/12=0.500\). (4) The assignments are consistent within each pipeline but differ between them, suggesting preprocessing sensitivity. Check the pipeline-specific cluster overlaps and the choices that differ; pooled entropy alone does not identify which pipeline is preferable.

Clinical Biostats