Skip to content

11 Diagnostics and Troubleshooting

kroy3 edited this page Nov 25, 2026 · 3 revisions

Chapter 11. Diagnostics and Troubleshooting

Decant reports when its estimate is uncertain. This chapter explains each message and what to do about it.

11.1 Four checks after every run

library(Decant)
sim <- simulate_experiment(seed = 1)
res <- decant(sim$observed, sim$empty, clusters = sim$labels)

quantile(res$rho, c(0.1, 0.5, 0.9))
#>       10%       50%       90% 
#> 0.1167786 0.1993348 0.3052685 
res$soup_mismatch
#> [1] FALSE
any(res$rho_diagnostics$low_power)
#> [1] FALSE
res$rho_unidentifiable
#> [1] FALSE
  1. Is rho plausible? Single-cell data typically show 0.02 to 0.10 and single-nucleus data up to 0.30. A median far outside this range deserves a closer look.
  2. soup_mismatch should be FALSE.
  3. low_power should be FALSE for all clusters, or at least for the large ones.
  4. rho_unidentifiable must be FALSE. If it is TRUE, see 11.4.

11.2 Warning: soup/cell mismatch

X% of the soup is in N gene(s) the cells do not contain ... rho is UNDERestimated.

Meaning. A noticeable share of the soup (more than 5%) is in genes that no cell expresses. The empty droplets contain material that is not ambient RNA from these cells, for example debris, red blood cells, or a cell type that was removed by filtering.

What Decant does. It removes those genes from the soup before estimating rho.

What to do.

  • Look at the top soup genes: head(sort(res$ambient[, 1], decreasing = TRUE), 20).
  • If they belong to a cell type you filtered out, consider keeping those cells.
  • If rho still looks too low, supply an independent estimate with rho = ... (Chapter 5.6).

11.3 Warning: weakly identified clusters

N cluster(s) with weakly identified contamination: 4 (almost no absent genes; rho borrowed from the other clusters). ...

The warning has class decant_weak_identifiability, so it can be caught with withCallingHandlers() or tryCatch(); its identifiability field, and res$identifiability, hold one row per cluster:

column meaning
cosine, kappa similarity of the cluster's raw profile to the soup (weighted cosine) and the condition number (1 + c) / (1 - c); collinear is TRUE above 0.9 or 30
js Jensen-Shannon divergence between the cluster's profile and the soup
fisher_umi, n_eff information about rho per UMI, and how many genes carry it
rho_se, ci_width standard error of the cluster's rho and the width of its 95% interval
weak, weak_reason, action_taken whether rho is weakly identified, why, and what Decant did

Meaning. A cluster is weak when the estimator's own evidence is thin: almost every gene in the soup is also expressed in it, its estimate came out above 0.5 (the cells would be mostly soup), or its 95% interval is wider than 0.05. This happens with very small clusters and with cell types whose expression resembles the soup. A cluster that is merely close to the soup (collinear) but still has enough absent genes is usually estimated well and is not flagged; pass weak_rule = "any" to estimate_rho_cluster() to flag it too.

What Decant does. A cluster without usable evidence takes the rho of the other clusters, weighted by their evidence (borrowed = TRUE in res$rho_diagnostics). Its own estimate tends to run high, so it is not used at cluster level. Known limitation: the per-cell values of a borrowed cluster are still adjusted using its own (unreliable) absent genes, which can pull them up.

What to do. Merge very small clusters, or cluster at a lower resolution, and run again. Supply the raw matrix so the empty droplets measure the soup cleanly. If the cluster matters, supply rho from an independent source.

11.4 Warning: contamination not identifiable

rho could not be identified: no cluster has genes that are cleanly absent, or most cells are in clusters whose estimate is implausibly high (> 0.5). ... The estimate is NOT reliable and correction may remove real signal. Supply rho from an independent source.

Meaning. Contamination is estimated from genes that a cluster does not express. If the soup looks like the cells themselves, for example in a sample of a single cell type or cell line, there are no such genes and the contamination cannot be measured from expression. This is a limit of every expression-based method, not only Decant's. On a mouse cell line with 0.4% true contamination, DecontX reported 35% without a warning.

What Decant does. It reports the problem (res$rho_unidentifiable is TRUE, and printing the result shows a warning) but still returns a correction, which should not be trusted.

What to do. Supply the contamination yourself:

# Requires your own data
res <- decant(cells, empties, clusters = clusters, rho = 0.02)
  • Good sources for rho are a genotype-based estimate when donors are pooled (Chapter 10.2), a species-mixing control run alongside the experiment, or a value measured on comparable data from the same lab and protocol.

11.5 Common errors

Message Cause Fix
empties needs nrow(obs_total) genes Cells and empty droplets have different genes Create both with split_droplets() from the same raw matrix
length(clusters) must equal ncol(obs_total) The cluster vector does not match the cells Use one label per cell, in column order
`sample_of` is required when `empties` is a list Several soups but no sample assignment Pass sample_of (Chapter 8)
need at least 2 cells Too few cells Check the cell filtering
RunDecant() refuses the object The assay holds normalised or SCTransformed values Use the assay with raw UMI counts (assay = "RNA")

11.6 Frequently asked questions

Do I need the raw matrix? It is strongly recommended, because the empty droplets measure the soup. With filtered data only, you can approximate the soup by the pooled expression of all cells, as SoupX does in the same situation:

pooled <- Matrix::Matrix(Matrix::rowSums(sim$observed), ncol = 1, sparse = TRUE,
                         dimnames = list(rownames(sim$observed), "pooled"))
res_pooled <- decant(sim$observed, pooled, clusters = sim$labels)
  • pooled is a one-column matrix holding the summed counts of all cells. Decant treats it as a single, very deep empty droplet.
  • This soup is biased towards the abundant cell types, so treat the result as approximate.

How many empty droplets do I need? The soup should rest on at least about 50,000 UMIs (soup_umis in the split_droplets() summary). A standard 10x run has far more.

Should I correct before or after quality control? Remove empty and damaged barcodes first (cell calling), then run Decant, then do the rest of the analysis (normalisation, clustering, markers) on the corrected counts.

Can I use Decant with single-nucleus data? Yes. Contamination is usually higher, which makes correction more important. For velocity, see Chapter 10.

Why are some counts still present for marker genes in the wrong cell type? Decant removes what ambient RNA can explain. Counts far above that level, often from doublets, are left in place on purpose: they are not ambient RNA and should be handled by doublet detection.


Previous: Chapter 10, Splice-Aware and Genotype Modules | Next: Chapter 12, Validation and Benchmarks

Clone this wiki locally