Why Estimate Contamination for Each Cell?
Ambient RNA is RNA present outside intact cells that can be captured in cell barcodes along with a cell’s own transcripts. The earlier material on ambient RNA profiles describes the distribution of genes in this background. Knowing that profile does not by itself tell us how much ambient RNA is present in a particular cell barcode: two cells can have different ambient contributions even when they share the same sample-level profile.
A cell-specific estimate is useful because the same number of ambient counts can represent different contamination fractions in cells with different total counts. The goal here is to estimate that fraction using genes treated as markers of ambient RNA for the cell—that is, genes assumed to contribute no endogenous counts in that cell. This assumption makes a simple estimator possible, but it is also the main vulnerability of the method.
A Count Mixture Model
Let \(Y_{ig}\) be the observed count for gene \(g\) in cell \(i\), and let \(N_i=\sum_g Y_{ig}\) be that cell’s total observed count across the genes being modeled. Let \(a_g\) be the ambient RNA profile: the fraction of ambient counts expected to come from gene \(g\), with \(a_g \geq 0\) and \(\sum_g a_g=1\). Let \(\theta_{ig}\) be the endogenous expression profile for cell \(i\), also expressed as gene proportions summing to one.
A basic mixture model says that, conditional on the total \(N_i\), the probability that an observed count comes from gene \(g\) is a weighted average of its endogenous and ambient proportions:
This model treats the observed counts as draws from one combined gene profile. It assumes that the ambient profile \(a_g\) is appropriate for the cell’s sample, that the endogenous and ambient sources mix in the stated proportions, and that the count model is an adequate approximation. It also treats \(a_g\) as known for the derivation below, although in practice it has been estimated and therefore has uncertainty.
For a chosen set of marker genes \(M\), assume that the cell has no endogenous expression of any gene in that set: \(\theta_{ig}=0\) for every \(g \in M\). Define the ambient probability mass of the set as \(A_M=\sum_{g\in M}a_g\), and its observed count as \(K_i=\sum_{g\in M}Y_{ig}\). Under the model, the probability that a count falls in the marker set is \(\rho_i A_M\). Thus, conditional on \(N_i\), \(K_i\) has a binomial distribution with \(N_i\) trials and success probability \(\rho_i A_M\).
Derivation and Uncertainty
Write \(r_i=\rho_i A_M\). The marker count has likelihood proportional to \(r_i^{K_i}(1-r_i)^{N_i-K_i}\). For \(0<K_i<N_i\), the log-likelihood, apart from a constant, is
Differentiating and setting the derivative to zero gives \(K_i/r_i-(N_i-K_i)/(1-r_i)=0\), so \(K_i(1-r_i)=r_i(N_i-K_i)\), and therefore \(r_i=K_i/N_i\). Since \(r_i=\rho_i A_M\), the unconstrained estimate is \(K_i/(N_iA_M)\). The parameter restriction \(0\leq\rho_i\leq1\) means the fitted value must be capped at one if the unconstrained estimate exceeds one. An estimate at that boundary is a warning that the model and observed marker counts may not agree; it does not establish that the barcode is entirely ambient.
The binomial variance also gives a useful approximate standard error. Since \(\hat{\rho}_i=K_i/(N_iA_M)\), its variance under the model is \(\rho_i(1-\rho_iA_M)/(N_iA_M)\). Replacing the unknown \(\rho_i\) with its estimate gives:
This approximation describes sampling variation in marker counts while treating the ambient profile and marker assumptions as correct. It can be unreliable near the boundaries or when expected marker counts are very small. It does not account for uncertainty in the estimated ambient profile or for endogenous expression mistakenly assigned to the marker set.
Worked Example: Estimating a Fraction From a Marker Set
Suppose a hypothetical cell has \(N_i=5{,}000\) observed counts. A set of marker genes has ambient mass \(A_M=0.08\), and the cell has \(K_i=32\) observed counts in that set. Assume, for this calculation, that the marker genes have zero endogenous expression in this cell.
Under the ambient profile, the marker set would account for \(0.08\) of ambient counts. The estimated ambient contribution to the cell’s total counts is therefore:
The estimate is an 8.0% ambient count fraction. Equivalently, the observed marker fraction is \(32/5{,}000=0.0064\), and \(0.0064/0.08=0.080\). The approximate standard error is:
A rough normal-approximation interval would be \(0.080 \pm 1.96(0.0141)\), or approximately 0.052 to 0.108. This is only an approximate sampling interval under the stated model; it does not include uncertainty in the ambient profile or possible violations of the zero-endogenous-expression assumption.
Worked Example: Combining Several Marker Genes
For another hypothetical cell, suppose three marker genes have ambient probabilities 0.05, 0.04, and 0.03. Their combined ambient mass is \(A_M=0.05+0.04+0.03=0.12\). The cell has \(N_i=4{,}000\) observed counts, of which \(K_i=24\) fall in the marker set. Assume all three genes are endogenously absent in this cell.
The combined estimator uses the total marker count and total ambient mass:
The estimated ambient fraction is 5.0%. The expected marker count at this estimate is \(N_i\hat{\rho}_iA_M=4{,}000(0.050)(0.12)=24\), matching the observed total by construction. The approximate standard error is:
Combining markers can provide more information than relying on one gene when the combined ambient mass is larger. It does not remove the need for the assumptions: if even one marker is expressed endogenously in this cell, its counts can inflate the estimate.
Sequencing Depth and Cell-to-Cell Differences
The estimate is a fraction, so it is not determined by the raw marker count alone. At a fixed contamination fraction and ambient mass, a cell with more total counts is expected to have more marker counts. Conversely, a small marker count can still imply substantial contamination if the marker set has very low ambient mass. The denominator \(N_iA_M\) captures both total count depth and how common the marker set is in ambient RNA.
Worked Example: Comparing Two Cells
Consider two hypothetical cells using a marker set with ambient mass \(A_M=0.10\). Cell A has \(N_A=2{,}000\) counts and \(K_A=20\) marker counts. Cell B has \(N_B=10{,}000\) counts and \(K_B=30\). Assume the marker set is endogenously absent in both cells.
For cell A, \(\hat{\rho}_A=20/[2{,}000(0.10)]=20/200=0.100\), or 10.0%. For cell B, \(\hat{\rho}_B=30/[10{,}000(0.10)]=30/1{,}000=0.030\), or 3.0%. Although cell B has more marker counts in absolute terms, its much larger total count makes its estimated ambient fraction lower.
The approximate standard errors are \(SE(\hat{\rho}_A)\approx\sqrt{0.100(1-0.100(0.10))/200}=0.0222\) and \(SE(\hat{\rho}_B)\approx\sqrt{0.030(1-0.030(0.10))/1{,}000}=0.00547\). Cell A’s estimate is less precise because its expected marker information, \(N_AA_M\), is smaller. These calculations compare estimated fractions; they do not by themselves establish a biological difference between the cells.
Diagnostics, Alternatives, and Limitations
A marker-based estimate is conditional on both the ambient profile and the chosen marker set. Useful checks include whether estimates are within the allowed range, whether individual marker genes broadly agree with the aggregate estimate, and whether estimates change substantially when one marker is omitted. A mismatch between the observed gene-by-gene marker counts and the pattern predicted by \(a_g\) can indicate that the ambient profile is inappropriate, that a marker is endogenously expressed, or that the simple mixture model is inadequate.
A very small \(A_M\) makes the estimate unstable: few ambient counts are expected in the marker set, so small changes in \(K_i\) can produce large changes in \(\hat{\rho}_i\). Low-depth cells have a related problem because they provide fewer counts for estimating the marker fraction. If \(K_i=0\), the point estimate is zero, but this does not prove that the cell contains no ambient RNA; finite sampling can yield no marker counts even when \(\rho_i>0\).
The central failure mode is endogenous expression in a gene treated as ambient-only. If the true endogenous marker-set mass is \(\Theta_{iM}=\sum_{g\in M}\theta_{ig}>0\), the expected observed marker fraction is \((1-\rho_i)\Theta_{iM}+\rho_iA_M\). Dividing that fraction by \(A_M\) attributes the endogenous contribution to ambient RNA and tends to overestimate \(\rho_i\). A related problem occurs if the ambient profile is mismatched: an \(A_M\) that is too small inflates the estimate, while an \(A_M\) that is too large deflates it.
A single-marker estimate is easy to compute but can be highly sensitive to sampling noise or gene-specific model mismatch. Aggregating several credible markers can stabilize the estimate by pooling counts. Broader mixture approaches can use assumptions about endogenous expression across many genes rather than relying on a marker set alone, but they introduce additional modeling choices and are not interchangeable with this simple estimator. In every case, the estimate remains model-dependent; it is not a direct observation of which individual molecules came from ambient RNA.
Check Your Understanding
Use the marker-set model for these questions. Solutions follow each question so that the calculations can be checked.
- A cell has \(N_i=3{,}000\), \(K_i=18\), and \(A_M=0.06\). What is the estimated contamination fraction?
- Why can a cell with more marker counts have a lower estimated contamination fraction than another cell?
- If \(K_i=0\), does the estimate establish that the cell has no ambient RNA? Explain.
- What direction of bias is expected if a marker gene has positive endogenous expression but is treated as ambient-only?
- A marker set has ambient mass \(A_M=0.02\), but \(K_i/(N_i)=0.03\). What does the unconstrained estimate imply, and how should it be interpreted?
Solutions. (1) \(\hat{\rho}_i=18/[3{,}000(0.06)]=18/180=0.100\), or 10.0%. (2) The estimate divides marker counts by both total counts and ambient marker mass; a larger \(N_i\) can make a larger raw \(K_i\) correspond to a smaller marker fraction. (3) No. Zero observed marker counts give a zero point estimate, but finite sampling can produce zero counts when the true fraction is positive. (4) The endogenous marker counts are incorrectly attributed to ambient RNA, tending to bias the estimate upward. (5) The unconstrained estimate is \(0.03/0.02=1.5\), outside the allowed range. The constrained maximum-likelihood estimate is 1, but the boundary result signals that the marker observations and assumptions deserve scrutiny; it is not evidence that the barcode is truly all ambient.