Tutorials › Statistical Methods for Single-Cell RNA Sequencing › Evaluating Deconvolution With Synthetic Mixtures

Spatial Transcriptomics · Tutorial 651 of 700

Evaluating Deconvolution With Synthetic Mixtures

Learn to create controlled mixtures with known proportions and assess how accurately and reliably a deconvolution method recovers them.

Advanced 12 min read

What You'll Learn

  • Define synthetic mixtures with known cell-type proportions and an explicit count-generation mechanism.
  • Calculate per-cell-type bias, mean absolute error, and root mean squared error.
  • Distinguish calibration from precision and inspect calibration across the prediction range.
  • Evaluate estimates near zero and one without letting interior cases hide boundary failures.
  • Identify design choices that make synthetic evaluations optimistic or uninformative.

Why Evaluate With Synthetic Mixtures?

Deconvolution estimates the proportions of cell types contributing to each spatial spot. In a tissue section, the true proportions are usually unknown, so agreement with an assumed or inferred reference cannot by itself establish accuracy. Synthetic mixtures provide a controlled test: construct spots from source profiles in known proportions, run the deconvolution procedure, and compare its estimates with those known proportions.

The test answers a specific question: when the data are generated under a stated mixture design, how well does this procedure recover the known fractions? It does not establish performance for every tissue or technical condition. The value of the exercise depends on whether the synthetic data resemble the sources of variation that matter in the intended application.

Definition: For synthetic spot \(i\) and cell type \(k\), let \(p_{ik}\) be the known true proportion and \(\hat p_{ik}\) the deconvolution estimate. The estimation error is \(e_{ik}=\hat p_{ik}-p_{ik}\). A positive error means overestimation; a negative error means underestimation. Proportions are unitless, though they may also be reported as percentage points.

Constructing a Synthetic Mixture

A useful design begins by stating what the target proportion means. If \(p_{ik}\) is a cell fraction, the mixture generator must represent cell contributions in a way that corresponds to cell fractions. Mixing normalized expression profiles in those proportions assumes, for example, that each cell type contributes the same expected captured RNA per cell. If cell types have different RNA content or capture efficiency, a simple weighted average of normalized profiles may instead represent RNA contributions, not cell fractions. The mixture design should account for that difference or define its target accordingly.

One illustrative count-generation model uses a normalized expression profile \(q_{kg}\) for cell type \(k\) and gene \(g\), with \(\sum_g q_{kg}=1\). Under equal expected captured RNA contribution per cell, the expected gene share in spot \(i\) is \(\pi_{ig}=\sum_k p_{ik}q_{kg}\). Conditional on a chosen library size \(N_i\), counts can be generated as a multinomial draw. This is a controlled mechanism, not a claim that all spatial counts follow a multinomial model; overdispersed or cell-level generation may be preferable when those features are part of the intended test.

$$ (Y_{i1},\ldots,Y_{iG}) \sim \operatorname{Multinomial}(N_i;\pi_{i1},\ldots,\pi_{iG}), \qquad \pi_{ig}=\sum_k p_{ik}q_{kg} $$

For a realistic challenge, vary the known proportions across spots, include pure or near-pure spots if relevant, and vary depth and cell-type combinations. Generate multiple independent replicate data sets. Keep the source profiles used to construct mixtures separate from any data used to tune the deconvolution method; otherwise, the evaluation can reward memorization of the test mixtures. If the intended use includes batch effects, reference mismatch, or spatial structure, include controlled versions of those features and report their results separately rather than blending them into one score.

Worked Example: Generating a Two-Type Synthetic Spot

Suppose two cell types have normalized profiles over three genes. Type A has profile \((0.60,0.30,0.10)\), and type B has profile \((0.10,0.30,0.60)\). Construct a hypothetical spot with known fractions \(p_{iA}=0.25\) and \(p_{iB}=0.75\), assuming equal expected captured RNA contribution per cell.

The expected shares are the weighted profile averages:

$$ \pi_i =0.25(0.60,0.30,0.10)+0.75(0.10,0.30,0.60) =(0.225,0.300,0.475). $$

At a fixed library size of \(N_i=1{,}000\), the expected counts are \((225,300,475)\). A possible hypothetical draw is \((230,295,475)\), which sums to 1,000. The truth remains \((0.25,0.75)\): sampling variation changes the counts, not the known mixture proportions. After running a method on the generated counts, compare its estimates with those fractions. This example checks recovery under the chosen profile and sampling model; by itself, it does not test robustness to unequal RNA contribution or mismatched profiles.

Summarizing Error Without Hiding Its Direction

For each cell type, calculate performance across the \(n\) synthetic spots. The mean bias measures signed error, mean absolute error (MAE) measures average error magnitude, and root mean squared error (RMSE) penalizes large errors more heavily. Report these separately by cell type before giving any overall summary: a single pooled value can hide a type that is consistently difficult to recover.

$$ \operatorname{Bias}_k=\frac{1}{n}\sum_{i=1}^n(\hat p_{ik}-p_{ik}), \qquad \operatorname{MAE}_k=\frac{1}{n}\sum_{i=1}^n|\hat p_{ik}-p_{ik}|, \qquad \operatorname{RMSE}_k=\sqrt{\frac{1}{n}\sum_{i=1}^n(\hat p_{ik}-p_{ik})^2} $$

All three measures are expressed in fraction units. Multiply by 100 to express them in percentage points. For example, a bias of \(0.04\) means estimates exceed truth by 4 percentage points on average. Bias near zero is not evidence of small errors: positive and negative errors can cancel.

Worked Example: Calculating Bias, MAE, and RMSE

For one cell type, suppose three hypothetical spots have true fractions \((0.10,0.40,0.80)\) and estimates \((0.20,0.50,0.70)\). The errors are \(0.10,0.10,-0.10\).

The mean bias is \((0.10+0.10-0.10)/3=0.0333\), or an average overestimate of 3.33 percentage points. The MAE is \((0.10+0.10+0.10)/3=0.100\), or 10 percentage points. The RMSE is \(\sqrt{(0.10^2+0.10^2+(-0.10)^2)/3}=\sqrt{0.0100}=0.100\), also 10 percentage points. The signed bias is smaller because the underestimate in the third spot partly cancels the overestimates in the first two.

Why Bias and RMSE Tell Different Stories

The distinction follows from an exact decomposition. Let \(e_i=\hat p_{ik}-p_{ik}\) for one cell type and let \(\bar e=(1/n)\sum_i e_i\). Write each error as \(e_i=(e_i-\bar e)+\bar e\). Squaring and averaging gives the empirical mean squared error:

$$ \frac{1}{n}\sum_i e_i^2 =\frac{1}{n}\sum_i(e_i-\bar e)^2+\bar e^2 +\frac{2\bar e}{n}\sum_i(e_i-\bar e) =\frac{1}{n}\sum_i(e_i-\bar e)^2+\bar e^2 $$

The last equality holds because \(\sum_i(e_i-\bar e)=0\). Thus RMSE squared equals the empirical variance of the errors, using divisor \(n\), plus squared bias. A method can have near-zero bias but substantial variability, or consistent estimates with a small spread but appreciable bias. Reporting more than one metric makes those patterns visible.

Worked Example: Zero Bias Does Not Mean Accurate Spots

Consider four hypothetical spots with true fractions \((0.80,0.60,0.20,0.00)\) and estimates \((0.70,0.70,0.10,0.10)\). The errors are \((-0.10,0.10,-0.10,0.10)\).

Bias is \((-0.10+0.10-0.10+0.10)/4=0\). But MAE is \((0.10+0.10+0.10+0.10)/4=0.100\), and RMSE is \(\sqrt{4(0.10^2)/4}=0.100\). The method has no average signed error across these spots, yet every estimate is 10 percentage points from truth. The estimate for the truly absent type is also a false positive of 0.10 in that spot.

Calibration and Boundary-Specific Checks

A method is calibrated over a range when spots assigned similar estimated fractions have, on average, similar true fractions. For example, estimates near 0.30 should correspond to an average true fraction near 0.30. Assess this by plotting true fractions against estimates and, when there are enough spots, grouping estimates into prespecified or clearly reported bins. In a calibration plot, the ideal reference is the identity line. Calibration is not the same as precision: averaging within a bin can conceal large spot-level errors.

Boundary cases deserve their own summaries because overall averages are often dominated by interior fractions. Define the boundary groups before examining results—for example, near-zero truth as \(p_{ik}\leq0.05\) and near-one truth as \(p_{ik}\geq0.95\). Within each group, report the number of spots and relevant errors, such as mean bias, MAE, and the distribution of estimates. For near-zero truth, also report how often the method returns an estimate above a prespecified practical threshold. For near-one truth, inspect how often it substantially underestimates. Thresholds should reflect the application and be fixed before comparing methods.

Worked Example: Calibration and Near-Zero Errors

Suppose four hypothetical estimates for one type are \(0.10,0.20,0.70,0.80\), with corresponding truths \(0.00,0.30,0.60,0.90\). Group the first two estimates as a low bin and the last two as a high bin.

In the low bin, mean estimate is \((0.10+0.20)/2=0.15\), and mean truth is \((0.00+0.30)/2=0.15\). In the high bin, mean estimate is \((0.70+0.80)/2=0.75\), and mean truth is \((0.60+0.90)/2=0.75\). Both bins lie on the calibration identity at their averages. However, each individual error has magnitude \(0.10\), so calibration at these two bin averages does not imply exact spot-level recovery. In the near-zero case, the spot with truth \(0.00\) has estimate \(0.10\); if a practical false-positive threshold were set at \(0.05\), it would exceed that threshold. This boundary result should be reported alongside the calibration summary.

Diagnostics, Comparisons, and Limitations

Useful diagnostics include plots of estimates against truth with the identity line, error against truth, and error against library size. Stratify or facet results by cell type and by generation condition, such as depth or reference source. A trend in residuals across truth values may indicate shrinkage toward the center or compression near zero and one. A depth trend suggests performance depends on sampling. Large errors concentrated in particular cell-type combinations suggest that the challenge is not captured by an overall score.

Synthetic mixtures made by combining profiles from observed single cells retain some empirical expression patterns, but can still be optimistic if the same cells or highly similar profiles are used for fitting and testing. Parametric simulations make it easier to vary assumptions and isolate a failure mechanism, but results depend on the chosen model. Physical mixtures can include laboratory effects absent from digital mixtures, yet their true cell fractions and mixing process may be less exact. These approaches answer related but distinct questions; report how the mixtures were produced rather than treating them as interchangeable evidence.

A synthetic evaluation is limited by its generator. If the generator omits reference mismatch, background RNA, unequal capture, or technical variation, good recovery under that design does not show robustness to those conditions. Conversely, a deliberately difficult simulation is informative only if the difficulty is relevant and its source is documented. Evaluate multiple designs, show per-type results, and avoid selecting only favorable metrics. When estimates are constrained to valid proportions, errors across types are linked; a high estimate for one type can force lower estimates for others. Interpret per-type results in that context rather than treating them as independent outcomes.

Common mistake: “The average bias is almost zero, so the deconvolution is accurate.” This is incorrect because overestimates and underestimates can cancel. Report bias together with magnitude measures such as MAE or RMSE, inspect estimates against truth, and examine boundary cases separately.
1
Specify the target and generator.
State whether truth is a cell fraction or another contribution fraction, and document how profiles, counts, and technical variation are generated.
2
Protect the evaluation set.
Separate mixtures used for tuning from held-out synthetic mixtures and repeat the evaluation across independent generated data sets.
3
Compare estimates with truth.
Calculate bias, MAE, and RMSE by cell type; inspect calibration and errors by truth range, depth, and generation condition.
4
Report boundaries and limitations.
Summarize near-zero and near-one performance with prespecified thresholds, and state which relevant features the generator does not represent.

Check Your Understanding

Answer each question, then compare with the solutions below.

  1. For errors \(-0.08\) and \(0.08\), what is the bias and what is the MAE? Why should both be reported?
  2. A synthetic design mixes normalized cell-type profiles using cell fractions. What assumption is needed for the resulting mixture weights to represent cell fractions?
  3. In a calibration bin, the mean estimate is 0.25 and mean truth is 0.20. State the direction and size of the average discrepancy.
  4. Why is a near-zero boundary summary useful when the overall MAE is small?

Solutions. (1) Bias is \((-0.08+0.08)/2=0\); MAE is \((0.08+0.08)/2=0.08\). The errors cancel in the signed average, while MAE shows an average error magnitude of 8 percentage points. (2) The generator must represent equal expected captured RNA contribution per cell, or otherwise adjust for differing RNA contribution or capture so that the mixture weights correspond to cell fractions. (3) Estimates exceed truth on average by \(0.25-0.20=0.05\), or 5 percentage points, in that bin. (4) Many well-estimated interior spots can dominate an overall MAE while absent or nearly absent cell types are systematically assigned positive fractions; the boundary summary reveals that specific failure mode.

Clinical Biostats