Tutorials › Statistical Methods for Single-Cell RNA Sequencing › Joint Outlier Detection With Cell-Level QC Metrics

Quality Control, Doublets and Ambient RNA · Tutorial 25 of 700

Joint Outlier Detection With Cell-Level QC Metrics

You will learn to standardize cell-level QC metrics robustly and combine them with a correlation-aware multivariate distance for cautious outlier screening.

Intermediate 12 min read

What You'll Learn

  • Transform skewed count metrics before comparing cells.
  • Calculate median- and MAD-based standardized deviations.
  • Interpret low-count, low-gene, and high-mitochondrial deviations in context.
  • Use a robust multivariate distance that accounts for correlated metrics.
  • Recognize when reference groups, covariance estimates, or cutoffs are unsuitable.
  • Distinguish an outlier flag from a decision to exclude a barcode.

Why Combine Cell-Level QC Metrics?

A barcode with unusually few counts may also have unusually few detected genes. Those two observations are related: both partly reflect the amount of captured RNA. Counting them as two independent pieces of evidence can therefore exaggerate how unusual the barcode is. Mitochondrial fraction adds another perspective, but it too may vary with cell state, cell type, and library size. Joint outlier detection aims to summarize these metrics together while accounting for their dependence.

The goal is a screening flag, not an automatic verdict that a barcode is invalid. A flag identifies a cell whose QC profile is unusual relative to an appropriate reference. It does not establish why the profile is unusual, nor does it by itself justify removing the cell. The earlier material on per-cell counts, detected genes, and mitochondrial fraction defines these metrics; the introductory material on adaptive mitochondrial thresholds explains why a single mitochondrial cutoff can be inappropriate across different cell groups.

Robust Standardized Deviations

Counts and detected-gene numbers are often right-skewed, so a small number of high values can pull the mean and standard deviation away from the bulk of the cells. A median and median absolute deviation (MAD) are less affected by such extremes. Before calculating deviations, it is often useful to transform the count metrics. For example, define \(u_i=\log_{10}(1+\mathrm{UMI}_i)\) and \(v_i=\log_{10}(1+\mathrm{genes}_i)\) for barcode \(i\). The logarithm compresses large values while preserving their ordering.

Definition: For a metric \(x\) measured across a chosen reference set of barcodes, its median is \(\tilde{x}=\operatorname{median}(x_i)\), and its median absolute deviation is \(\mathrm{MAD}(x)=\operatorname{median}(|x_i-\tilde{x}|)\). The robust standardized deviation for barcode \(i\) is $$ z_i^{(R)}=\frac{x_i-\tilde{x}}{1.4826\,\mathrm{MAD}(x)}. $$ The factor 1.4826 makes this scale estimate comparable to the standard deviation when the reference values follow a normal distribution. A robust standardized deviation of \(-2\) means the value is two robust scale units below the reference median; it is not, by itself, a probability or a formal test result.

For mitochondrial fraction, use a consistent definition and scale. If fractions are strictly between zero and one and the range warrants it, a logit transformation can make the scale less bounded: \(w_i=\log\{f_i/(1-f_i)\}\), where \(f_i\) is the fraction. Exact zeros or ones require a prespecified adjustment, or a different transformation. One may also robustly standardize the fraction on its original scale when that scale is suitable. The choice of transformation should be made before inspecting which barcodes will be flagged and applied consistently to the reference and candidate cells.

The reference set matters. If biologically distinct cell groups have different typical QC profiles, a pooled median and MAD can make ordinary cells in one group appear unusual. Reference cells should therefore be chosen to be comparable in sample, assay, and relevant biological composition. A reference dominated by poor-quality barcodes can also shift its center and scale, masking the very outliers of interest. If a MAD is zero, the formula is undefined; do not divide by zero or silently replace it with an arbitrary number. Investigate whether the metric is constant or highly discrete, and use a suitable alternative scale or analysis.

Worked Example: A Robust Deviation for Library Size

Suppose a hypothetical reference set has median transformed UMI count \(\tilde{u}=3.70\) and \(\mathrm{MAD}(u)=0.20\). A candidate barcode has \(u_i=3.10\). The transformed count and the reference summaries use the same log scale.

The robust scale estimate is \(1.4826(0.20)=0.29652\). Thus $$ z_i^{(R)}=\frac{3.10-3.70}{0.29652} =\frac{-0.60}{0.29652}\approx -2.024. $$

This barcode is about 2.02 robust scale units below the reference median for transformed UMI count. It is a potential low-library-size flag, not proof of poor quality. Its detected-gene count, mitochondrial fraction, and biological context should also be considered.

Combining Metrics Without Double-Counting

A simple rule might flag a barcode if any one of several robust deviations exceeds a cutoff. Such a rule is easy to interpret, but it does not describe how unusual the joint profile is, and the chance of crossing at least one cutoff increases as more metrics are checked. A multivariate distance provides a different summary: it measures distance from the typical joint profile while accounting for correlations.

Let \(z_i\) be the vector of robust standardized deviations for the selected metrics, such as transformed UMI count, transformed detected-gene count, and mitochondrial fraction. Let \(R\) be a robust estimate of their correlation matrix in the reference cells. Then define the squared robust Mahalanobis distance as follows.

Definition: If \(R\) is positive definite, the squared robust Mahalanobis distance for barcode \(i\) is $$ D_i^2=z_i^{\mathsf T}R^{-1}z_i. $$ The distance adjusts the combined deviations for the correlations in the reference data. It is nonnegative and equals zero only when all components of \(z_i\) are zero. A robust correlation estimate is important: an ordinary correlation matrix can itself be distorted by the outliers being screened.

One robust approach estimates center and covariance from a subset of the reference cells whose covariance determinant is small, as in the minimum covariance determinant (MCD) method, with suitable correction for scale. The selected subset must be large enough to estimate a nonsingular covariance matrix. Regardless of estimator, the reference must represent the cells to which it will be applied, and the resulting correlation matrix must be invertible. If two metrics are nearly redundant, the matrix may be unstable or singular; reduce redundancy, use a carefully regularized method, or analyze the metrics separately rather than trusting an unstable inverse.

Worked Example: Adjusting for Correlated Counts

Consider two hypothetical robust standardized deviations: \(z_1=-2\) for transformed UMI count and \(z_2=-2\) for transformed detected genes. Suppose their robust reference correlation is \(\rho=0.90\). The correlation matrix and its inverse are $$ R=\begin{pmatrix}1&0.90\\0.90&1\end{pmatrix}, \qquad R^{-1}=\frac{1}{1-0.90^2} \begin{pmatrix}1&-0.90\\-0.90&1\end{pmatrix}. $$

Substitution gives $$ D^2=\frac{z_1^2-2\rho z_1z_2+z_2^2}{1-\rho^2} =\frac{4-2(0.90)(4)+4}{1-0.81} =\frac{0.80}{0.19}\approx4.211. $$

If the correlation were ignored, the sum of squared deviations would be \(z_1^2+z_2^2=8\). The smaller correlation-adjusted value reflects that both metrics are low in a direction commonly shared by correlated counts and genes. They are not two independent confirmations of an outlier. This example illustrates the adjustment; it does not establish a universal cutoff for flagging.

Interpreting a Joint Flag

A distance gives an overall measure of unusualness but does not say which metric drove it or whether the cell is unusually high or low on that metric. Always examine the component deviations alongside the distance. For QC, direction matters: low counts and genes may indicate low capture, whereas unusually high mitochondrial fraction may indicate a different concern. A joint distance can also be large because of a combination of moderate deviations, even when no single component crosses a univariate cutoff.

Worked Example: A Joint QC Profile

Suppose a hypothetical reference has robust centers and scales that give a candidate barcode the following robust deviations: \(z_{\mathrm{UMI}}=-2.0\), \(z_{\mathrm{genes}}=-2.0\), and \(z_{\mathrm{mito}}=2.5\). Suppose the estimated robust correlation matrix has correlation 0.80 between the two count-related metrics and zero correlation between each of them and mitochondrial fraction: $$ R=\begin{pmatrix}1&0.80&0\\0.80&1&0\\0&0&1\end{pmatrix}. $$

The count-related contribution is $$ \frac{(-2)^2-2(0.80)(-2)(-2)+(-2)^2}{1-0.80^2} =\frac{8-6.4}{0.36}\approx4.444. $$ The mitochondrial contribution is \(2.5^2=6.25\), so $$ D^2\approx4.444+6.25=10.694. $$

The profile is jointly unusual relative to this hypothetical reference, with both low count-related metrics and a high mitochondrial fraction contributing. The count-related pair contributes less than the unadjusted sum of their squares because they are correlated. The distance does not identify a cause or decide whether to exclude the barcode: review the component metrics, the reference group, and the underlying data before making a QC decision.

Assumptions, Diagnostics, and Alternatives

Robust standardization and robust distance are useful only when their reference summaries are meaningful. The main conditions to check are:

  • Comparable reference cells: The reference should reflect the assay and biological population being evaluated. Differences in cell composition or sample handling can create apparent outliers.
  • Usable metric scales: Transformations should address severe skew or boundary effects without erasing meaningful differences. The same transformation must be used for reference and candidate cells.
  • Reliable robust summaries: The reference should contain enough cells and variation to estimate medians, scales, and correlations. Zero MADs, unstable correlations, and nearly singular matrices are warning signs.
  • Understandable direction: Look at the individual deviations as well as the joint distance. A distance alone hides whether the unusual profile reflects low counts, high mitochondrial fraction, or another combination.

A chi-square calibration for \(D^2\) is available under a multivariate normal model with known center and covariance: if a \(p\)-dimensional vector follows that model, its squared Mahalanobis distance from the true center has a chi-square distribution with \(p\) degrees of freedom. In practice, QC distances use estimated, often robust, summaries and transformed metrics that need not be multivariate normal. Therefore, do not automatically interpret a chi-square tail area as a calibrated p-value. If a formal cutoff is needed, its calibration should reflect the estimation procedure and reference data; exploratory QC often uses distance plots and sensitivity checks instead.

A fixed univariate threshold is transparent and may be appropriate when a metric has a clear, justified limit, but it can miss joint patterns and can mishandle correlated metrics. An “any metric exceeds its cutoff” rule is straightforward but its overall flag rate depends on the number and dependence of metrics. A robust multivariate distance accounts for correlation, but is less directly interpretable and can be unstable with too many redundant metrics or an unsuitable reference. None of these methods replaces examining QC distributions and the scientific consequences of flagging cells.

Common Pitfall: Treating Correlated Metrics as Independent Evidence

A tempting argument is: “The barcode is low in counts and low in detected genes, so two separate metrics confirm that it is poor quality.” This overstates the evidence when the metrics are strongly correlated; low library size naturally tends to produce fewer detected genes. The correction is to examine their joint distribution, use a correlation-aware summary when appropriate, and report the direction of each component. Even a correlation-adjusted flag remains a screening result, not proof that the barcode is invalid.

Key takeaway: Robust standardized deviations describe how far each QC metric lies from a suitable reference, while a robust multivariate distance summarizes the joint profile after accounting for metric correlations. Interpret both the distance and its components, and treat flags as prompts for review rather than automatic exclusions.

Check Your Understanding

Work through each question, then compare your reasoning with the solutions below.

  1. A metric has median 12 and MAD 2. What is the robust standardized deviation for an observation of 6?
  2. Why can two low deviations for UMI count and detected genes exaggerate evidence when their correlation is strong?
  3. What problem arises if a metric has MAD equal to zero?
  4. Under what model does a squared Mahalanobis distance have a chi-square distribution, and why might that not justify a QC p-value in practice?

Solutions. (1) The robust scale is \(1.4826(2)=2.9652\), so \(z^{(R)}=(6-12)/2.9652\approx-2.024\). (2) The metrics tend to move together, so their deviations are not independent confirmations; a correlation-adjusted distance reduces this double-counting. (3) The robust standardization denominator is zero, so the deviation is undefined; investigate the metric and reference or choose a suitable alternative rather than dividing by zero. (4) With a \(p\)-dimensional multivariate normal model and known center and covariance, the squared distance has a chi-square distribution with \(p\) degrees of freedom. In QC, centers and covariances are estimated robustly and the model may not hold, so that calibration is not automatic.

Clinical Biostats