Tutorials › Statistical Methods for Single-Cell RNA Sequencing › Uncertainty in Spatial Deconvolution

Spatial Transcriptomics · Tutorial 647 of 700

Uncertainty in Spatial Deconvolution

You will construct and interpret bootstrap and Bayesian intervals for spot proportions, while distinguishing sampling uncertainty from uncertainty that a fitted model does not capture.

Advanced 12 min read

What You'll Learn

  • Specify a multinomial mixture model for spot counts and cell-type proportions.
  • Construct a parametric bootstrap interval conditional on fixed reference profiles.
  • Derive a Bayesian interval under a simple diagnostic-marker model.
  • Interpret intervals concentrated near zero and intervals spanning most of the proportion range.
  • Diagnose weak identification, boundary effects, and uncertainty omitted by an analysis.
  • Distinguish componentwise intervals from joint uncertainty on the proportion simplex.

Why an Estimated Proportion Needs an Uncertainty Interval

A deconvolution estimate gives a fitted proportion for each cell type in a spatial spot. The estimate alone does not show how strongly the observed counts support that value. Two spots can both have an estimated proportion of 0.30, while one has sharply informative counts and the other has counts that are nearly as compatible with many different mixtures. An uncertainty interval makes this distinction visible, provided its assumptions and scope are made clear.

The earlier material on estimating proportions from count references motivates a count-mixture model. Here, the focus is uncertainty around its fitted proportions. We distinguish variation in spot counts conditional on fixed reference profiles from uncertainty in the profiles themselves. An interval that accounts for only the first source must not be described as capturing all uncertainty in the deconvolution.

Definition: For one spot, let \(y_g\) be the observed count for gene \(g\), and let \(N=\sum_g y_g\) be the total count over the modeled genes. For \(K\) cell types, let \(p_k\) be the spot proportion of type \(k\), where \(p_k\geq 0\) and \(\sum_{k=1}^K p_k=1\). Let \(q_{gk}\) be the fixed reference probability for gene \(g\) in type \(k\), with \(q_{gk}\geq0\) and \(\sum_g q_{gk}=1\). The mixture probability for gene \(g\) is \(\mu_g(p)=\sum_k p_kq_{gk}\). A basic conditional model is \(y\mid p,q\sim\operatorname{Multinomial}(N,\mu(p))\).

This model treats the \(N\) counts as draws from the mixture probabilities, conditional on the true proportions and fixed profiles. It assumes the modeled genes and reference profiles are appropriate, and that the multinomial sampling description is adequate. In particular, it does not account for variability between reference cells if \(q_{gk}\) was estimated from a finite reference sample. The constrained estimate \(\hat p\) maximizes the count likelihood subject to the nonnegative and sum-to-one constraints.

Parametric Bootstrap Intervals

A parametric bootstrap approximates the repeated-sampling variation of the estimator under the fitted model. For each bootstrap replicate, simulate a new count vector at the observed total \(N\), using the fitted mixture probabilities \(\mu_g(\hat p)\), and refit the proportions using the same constrained procedure. The resulting estimates form a bootstrap distribution. Percentiles of that distribution provide a componentwise interval for each \(p_k\).

1
Fit the model.
Estimate \(\hat p\) from the observed spot counts, using fixed reference profiles \(q\).
2
Simulate counts.
For each replicate \(b\), draw \(y^{*(b)}\sim\operatorname{Multinomial}(N,\mu(\hat p))\).
3
Refit proportions.
Apply the original constrained fitting method to each simulated vector to obtain \(\hat p_k^{*(b)}\).
4
Summarize the distribution.
For example, the 2.5th and 97.5th percentiles give a 95% percentile interval for component \(k\).

The percentile interval is an approximate frequentist interval: under repeated data generation from the assumed model and repeated application of the procedure, intervals constructed this way are intended to cover the true proportion at about the stated rate. It is not a probability statement about a fixed parameter after seeing one interval. Its calibration can be poor if the fitted model is inadequate, if the estimator behaves irregularly near a boundary, or if the reference profiles are uncertain but held fixed.

Worked Example: A Bootstrap Interval With Diagnostic Counts

Suppose a hypothetical spot contains \(N=100\) modeled molecules, each of which is assumed to identify one of two cell types without error. There are 30 type-1 molecules and 70 type-2 molecules, so \(\hat p_1=30/100=0.30\). This idealized diagnostic-marker setup reduces the count model to \(X\sim\operatorname{Binomial}(N,p_1)\). It assumes independent molecule sampling and perfectly distinguishing markers.

For a parametric bootstrap, generate \(X^*\sim\operatorname{Binomial}(100,0.30)\) and calculate \(\hat p_1^*=X^*/100\) in each replicate. In a hypothetical run of 10,000 replicates, suppose the 2.5th and 97.5th percentiles are 0.21 and 0.39. The bootstrap 95% interval is therefore approximately 0.21 to 0.39, or 21% to 39% of the spot.

The scale is plausible from the binomial standard error at the fitted value:

$$ SE(\hat p_1)\approx\sqrt{\frac{\hat p_1(1-\hat p_1)}{N}} =\sqrt{\frac{0.30(0.70)}{100}} =0.0458. $$

A rough normal interval, \(0.30\pm1.96(0.0458)\), is 0.210 to 0.390, close to the reported bootstrap percentiles. This agreement is a check on the arithmetic, not proof that the normal approximation is suitable in every setting. The bootstrap interval here reflects count sampling under perfect marker identification; it does not include uncertainty in reference profiles or departures from the idealized model.

Bayesian Intervals and Boundary Concentration

A Bayesian analysis combines a likelihood with a prior distribution for the proportions. The posterior distribution describes uncertainty about the proportions conditional on the observed data, the likelihood, and the prior. For the general multinomial mixture, a Dirichlet prior on \(p\) can be used, but the posterior is generally not a Dirichlet distribution: the mixture likelihood depends on \(p\) through \(\mu_g(p)=\sum_kp_kq_{gk}\). Posterior intervals can be obtained from numerical integration or posterior simulation.

A simple special case illustrates the calculation exactly. With two perfectly distinguishing marker categories, the type-1 count \(X\) has a binomial likelihood. If \(p_1\sim\operatorname{Beta}(a,b)\), then the posterior is \(\operatorname{Beta}(a+X,b+N-X)\). A 95% equal-tailed credible interval is the interval between the 2.5th and 97.5th posterior quantiles. Under the stated model and prior, it contains 95% of the posterior probability; it is not a frequentist coverage guarantee.

Worked Example: A Bayesian Interval for a Type Proportion

In a hypothetical spot, 30 of 100 perfectly diagnostic molecules indicate type 1. Use a uniform prior, \(p_1\sim\operatorname{Beta}(1,1)\). The likelihood is proportional to \(p_1^{30}(1-p_1)^{70}\), so the posterior is:

$$ p_1\mid X=30\sim\operatorname{Beta}(1+30,1+70) =\operatorname{Beta}(31,71). $$

The posterior mean is \(31/(31+71)=31/102=0.304\). The 2.5th and 97.5th percentiles are approximately 0.219 and 0.396, giving a 95% credible interval from 21.9% to 39.6%. Conditional on this likelihood and the uniform prior, the posterior probability that \(p_1\) lies between those endpoints is 0.95. The result depends on the ideal diagnostic-marker model and the chosen prior; neither is made true by calculating the interval.

An interval concentrated near zero is not the same as an estimate known to be exactly zero. With a continuous prior, the posterior probability of the exact point \(p_1=0\) is zero, although most posterior mass can be very close to zero. A boundary estimate can also arise in constrained maximum likelihood. In either case, report the interval and its assumptions rather than interpreting a fitted zero as proof that the cell type is absent.

Worked Example: Interpreting an Interval Near Zero

Suppose a second hypothetical diagnostic-marker spot has \(N=100\) molecules and no type-1 molecules. With the same uniform prior, the posterior is \(\operatorname{Beta}(1,101)\), with mean \(1/102=0.00980\). Its cumulative distribution function is \(F(p)=1-(1-p)^{101}\). Solving \(F(p)=u\) gives the quantile \(p_u=1-(1-u)^{1/101}\).

Thus the equal-tailed 95% credible interval is approximately:

$$ \left[ 1-0.975^{1/101},\;1-0.025^{1/101} \right] \approx[0.000250,\;0.0358]. $$

Under this model and prior, the data support a small type-1 proportion, with 95% posterior probability between about 0.025% and 3.58%. The interval does not establish that the true proportion is exactly zero. It also does not protect against markers that fail to distinguish the types or against uncertainty in the reference profiles.

Why Intervals Can Be Wide

A wide interval can reflect limited counts, weakly distinguishing reference profiles, or both. When two types have similar gene profiles, many mixtures produce similar expected counts. More counts can reduce sampling variation, but cannot by themselves fully resolve profiles that are nearly indistinguishable. The interval should therefore be read as a property of the data together with the model, not as a standalone measure of biological certainty.

Worked Example: Weak Markers Produce a Wide Interval

Consider a hypothetical two-type spot with \(N=100\) molecules measured at one marker. A molecule is marker-positive with probability 0.45 in type 2 and 0.55 in type 1. If \(p\) is the type-1 proportion, the positive-count probability is \(\theta(p)=0.45+0.10p\). This assumes independent Bernoulli marker counts and known, fixed marker probabilities. The observed positive count is 50, so the fitted value is \(\hat\theta=0.50\), giving \(\hat p=(0.50-0.45)/0.10=0.50\).

The marker is weakly informative because changing \(p\) from 0 to 1 changes the positive probability by only 0.10. To check how compatible the endpoints are with the data, compare their binomial log likelihoods with the maximum at \(\theta=0.50\). The likelihood-ratio statistic at either endpoint is:

$$ 2\left[50\log\left(\frac{0.50}{\theta}\right) +50\log\left(\frac{0.50}{1-\theta}\right)\right] \quad\text{with }\theta=0.45\text{ or }0.55 \approx1.005. $$

For comparison, the usual 95% one-parameter likelihood-ratio cutoff is approximately 3.84. Both endpoints are therefore retained by this approximate likelihood-ratio check; since the likelihood is maximized at \(p=0.50\), the resulting interval is the full feasible range, 0 to 1. This deliberately simple example shows that an interior estimate does not imply a precise estimate. A narrow interval would overstate the information in these weak marker counts.

Diagnostics, Comparisons, and Limitations

Check how uncertainty was generated before interpreting its width. A parametric bootstrap with fixed profiles captures variability in spot counts under the fitted mixture, but not variability in estimated profiles. A bootstrap that also resamples reference cells and recomputes the profiles can reflect some reference-sampling uncertainty, provided the resampling scheme matches the reference design and the entire fitting procedure is repeated. A Bayesian analysis can represent uncertainty through a posterior and a prior, but its result depends on both. Neither method automatically accounts for misspecified count variation or unmodeled biological variation.

Useful diagnostics include inspecting the bootstrap estimates or posterior draws for pile-ups at zero or one, checking whether optimization repeatedly reaches a boundary, and examining whether intervals remain wide across the feasible range. For a likelihood-based analysis, a flat profile likelihood signals weak information about a proportion. Also check whether the simulated or fitted counts reproduce the broad features assumed by the model. A narrow interval is not reassuring if the model fails these checks.

Componentwise intervals need not add to one: separate marginal intervals for \(K\) proportions do not form a single joint 95% region on the simplex. Their endpoints are not a set of simultaneous estimates. When joint uncertainty matters, use the joint bootstrap distribution or posterior draws and summarize that distribution directly. All intervals remain conditional on the modeling choices; a confidence or credible interval cannot repair an unsupported reference or an inadequate likelihood.

Common mistake: “The fitted proportion is zero, so the cell type is absent,” or “the 95% interval has a 95% chance of containing the true proportion.” A boundary estimate is a constrained fit, not proof of absence. A frequentist interval describes repeated-procedure coverage under its assumptions; a Bayesian credible interval gives posterior probability conditional on its model and prior. State which interval is being reported and what uncertainty it includes.
Key takeaway: Uncertainty in spatial deconvolution is meaningful only in relation to the model and resampling or prior assumptions that produced it. Report the interval, its interpretation, and whether it includes spot-count sampling alone or also reference-profile uncertainty.

Check Your Understanding

Answer each question, then compare your reasoning with the solutions.

  1. A spot has 40 type-1 molecules among 200 perfectly diagnostic molecules. What is the fitted type-1 proportion and the plug-in binomial standard error?
  2. In a parametric bootstrap, reference profiles are held fixed. Name one source of uncertainty the resulting interval captures and one it omits.
  3. With a continuous prior, a posterior interval lies between 0.001 and 0.04. Does this assign positive posterior probability to the exact value zero?
  4. Two estimated proportions each have a marginal 95% interval. Do these intervals necessarily define a joint 95% region for the pair?

Solutions. (1) \(\hat p_1=40/200=0.20\). The plug-in standard error is \(\sqrt{0.20(0.80)/200}=0.0283\), or about 2.83 percentage points, under the independent binomial model. (2) It captures spot-count sampling variation conditional on the fitted profiles; it omits variation in profiles estimated from finite reference samples. (3) No. A continuous prior assigns zero posterior probability to any one exact point, including zero, even when posterior mass is concentrated near zero. (4) No. The marginal intervals each describe one component separately; their joint coverage is not generally 95%, and their endpoints do not encode the dependence imposed by proportions summing to one.

Clinical Biostats