Three Expression Quantities, Three Different Questions
A count matrix contains the values actually recorded for each cell and gene. A count VAE also supplies model-based quantities that can look like expression values but answer different questions. Confusing these quantities can turn a useful noise-reduction estimate into an unsupported claim that cells have similar expression.
For cell \(n\) and gene \(g\), let \(x_{ng}\) denote the observed count. In a count VAE, the decoder specifies a distribution for this count conditional on latent variables and other model inputs. Write its conditional mean as \(\mu_{ng}(z_n,l_n)\), where \(z_n\) is the cell's latent state and \(l_n\) is a library-size quantity. For example, a model may set \(\mu_{ng}(z_n,l_n)=l_n\rho_{ng}(z_n)\), with \(\rho_{ng}\) a gene proportion from the decoder. The exact parameterization depends on the model; the scale of the output must therefore be checked before it is interpreted.
If the encoder approximates the posterior distribution of the latent state by \(q_\phi(z_n\mid x_n)\), a count-scale posterior denoised estimate can be defined as \(\hat{\mu}_{ng}=\mathbb{E}_{q_\phi(z_n\mid x_n)}[\mu_{ng}(z_n,l_n)]\). In computation, this expectation is commonly approximated by averaging decoder outputs at posterior draws. If the reported target is normalized expression rather than expected counts, average the corresponding normalized decoder output instead. These are different targets when the library-size factor varies across cells.
Worked Example: A Zero Count and a Positive Posterior Estimate
Suppose a hypothetical cell has observed count \(x_{ng}=0\) for a gene. At three equally weighted draws from its approximate posterior, the decoder gives expected counts of 1, 2, and 3. The posterior denoised estimate is
The observed value remains zero. The estimate of 2 counts summarizes decoder expectations averaged over latent-state uncertainty; it does not mean that two molecules were observed. Nor does it establish that the cell truly expressed exactly two molecules. The distinction matters especially for low counts, where a zero is compatible with a positive underlying mean under a count sampling model.
Decoder Means Are Not Posterior Predictive Counts
A decoder expectation is conditional on its inputs. If those inputs are uncertain, averaging decoder means gives a posterior estimate of the conditional mean. A posterior predictive count instead represents a possible new count under the fitted model, including count-sampling variation as well as uncertainty about the latent state.
For a negative binomial observation model parameterized by mean \(\mu\) and dispersion \(\theta\), the conditional variance is \(\mu+\mu^2/\theta\). The law of total variance gives the posterior predictive variance as the average conditional variance plus the variance of the conditional means. In this expression, \(Z\) is drawn from the approximate posterior for the cell.
The first term averages negative binomial sampling variance; the second captures variation in the decoder mean across posterior draws. The posterior denoised estimate is the average mean, not a draw from this predictive distribution. Thus, it can be fractional and typically has less variability than posterior predictive counts.
Worked Example: Mean Estimate Versus Predictive Variability
For a hypothetical cell and gene, suppose two equally weighted posterior draws give decoder means 1 and 3 counts, and the negative binomial dispersion is \(\theta_g=4\). The posterior denoised estimate is
At mean 1, the conditional count variance is \(1+1^2/4=1.25\). At mean 3, it is \(3+3^2/4=5.25\). Their average is \((1.25+5.25)/2=3.25\). The two decoder means have posterior variance \(((1-2)^2+(3-2)^2)/2=1\). Therefore the posterior predictive variance is \(3.25+1=4.25\) counts squared. Reporting 2 counts as if it were a sampled count would discard this predictive variability.
Why Denoising Can Hide Cell-Level Differences
Posterior averaging can reduce noise when the model captures the relevant structure and the count observations are sparse. But the same averaging can also pull estimates toward patterns shared across cells. If a model treats genuinely different cells as if they had similar latent expression, denoised values can understate real heterogeneity. A low observed count alone does not tell us which case applies: it may reflect sampling from a modest mean, or it may be one piece of evidence for a truly low-expressing cell.
The following calculation illustrates shrinkage with a simple Poisson-Gamma model, not a VAE. It makes the mechanism explicit. Assume a cell has count \(X\mid\lambda\sim\operatorname{Poisson}(\lambda)\), with exposure fixed at one, and assign its rate the prior \(\lambda\sim\operatorname{Gamma}(a=2,b=2)\), using the shape-rate convention. The prior mean rate is \(a/b=1\). The posterior mean is pulled toward that prior mean, with the strength of the pull depending on the count.
Worked Example: Shrinkage in a Low-Count Gene
Consider three hypothetical cells with counts 0, 1, and 4 for a low-count gene. Apply the same Poisson-Gamma calculation to each cell, with \(a=2\), \(b=2\), and exposure one. Their posterior mean rates are
The observed counts have mean \((0+1+4)/3=1.667\) counts and sample variance \(\{(0-1.667)^2+(1-1.667)^2+(4-1.667)^2\}/2=4.333\) counts squared. The three posterior mean rates have mean 1.222 and sample variance \(\{(0.667-1.222)^2+(1-1.222)^2+(2-1.222)^2\}/2=0.481\) rates squared. These are not identical measurements—the latter are estimated rates—but the much smaller spread shows how strongly posterior estimates can smooth a sparse set of values.
This smoothing is useful only relative to its assumptions. If the cells truly share a common rate distribution, shrinkage can reduce the influence of noisy counts. If the count of 4 reflects a genuinely distinct high-expressing cell and the model or prior fails to represent that heterogeneity, the estimate of 2 can obscure the difference. A VAE has a richer, learned structure than this simple model, but it can still smooth away variation its latent representation or decoder does not capture.
Choosing a Quantity and Checking Its Behavior
There is no single expression quantity that is best for every task. Use observed counts when the analysis requires the recorded data or when modeling the sampling distribution directly. Use decoder expectations when the question concerns the model-implied mean at specified inputs. Use posterior denoised estimates when a model-based, uncertainty-averaged expression summary is appropriate. Use posterior predictive draws when the task requires plausible replicated counts or a check of count-level variation.
Before comparing or plotting values, establish whether they are on the count scale, a normalized scale, or another scale. For example, \(\rho_{ng}\) may represent a relative expression proportion, whereas \(l_n\rho_{ng}\) is an expected count. An expectation on one scale cannot be described as though it were on another. Also record whether the posterior estimate averages over latent draws, whether library size is fixed or uncertain, and what covariates or conditions are held constant.
Useful diagnostics include comparing observed and posterior-predictive distributions across cells, checking whether zeros and high counts are reproduced, and inspecting denoised values alongside the raw counts for selected genes. Look particularly at genes with biological reasons to vary across cell states and at small groups of cells, where pooling can dominate. If posterior estimates are nearly identical across cells while observed counts, known covariates, or independent measurements suggest structured variation, investigate model fit and the representation of that structure rather than treating smoothness as proof of accuracy.
| Quantity | What it represents | Main caution |
|---|---|---|
| Observed count \(x_{ng}\) | Recorded integer count for the cell and gene | Includes sampling variation; sparse values can be noisy |
| Decoder mean \(\mu_{ng}(z_n,l_n)\) | Model-implied expected count at specified inputs | Depends on the chosen latent state and scale |
| Posterior denoised estimate | Posterior average of a decoder expression quantity | May smooth variation not represented by the model |
| Posterior predictive count | A replicated count incorporating model and sampling variation | Is a random draw, not a denoised expression summary |
A common mistake is to say, “The denoised count is 2, so the cell had two transcripts.” The correction is that 2 may be a posterior average of expected counts; the observed count is still the recorded integer, and the estimate carries model assumptions and uncertainty. Similarly, a denoised value closer to a group average is not by itself evidence that a cell lacks a distinct expression state.
These distinctions matter whenever expression summaries are used to describe cells, compare groups, or select genes for further analysis. Denoising can make patterns easier to see, but it changes the object being examined: a model-based estimate replaces the raw observation. Keeping both quantities available, checking the scale, and examining predictive fit help prevent smoothing from being mistaken for biological uniformity.
Check Your Understanding
Answer each question, then compare your reasoning with the solutions.
- A decoder gives expected counts 0.5, 1.5, and 2.0 at three equally weighted posterior draws. What is the posterior denoised estimate, and is it an observed count?
- In a negative binomial model with mean 2 and dispersion 4, what is the conditional variance? What source of uncertainty is not included if you use only this conditional variance at one fixed latent state?
- Using the Poisson-Gamma setup above, calculate the posterior mean rate for a cell with count 2.
- Why can a smooth denoised profile fail to show genuine cell-level variation?
Solutions. (1) The estimate is \((0.5+1.5+2.0)/3=1.333\) expected counts. It is not an observed count; observed counts are recorded integers. (2) The conditional variance is \(2+2^2/4=3\) counts squared. At a fixed latent state this omits variation in the decoder mean across posterior latent draws. (3) The posterior mean is \((2+2)/(2+1)=4/3=1.333\) rate units, with exposure fixed at one. (4) If the model pools cells or cannot represent a true high- or low-expression subgroup, posterior averaging can pull estimates toward shared patterns and reduce the apparent spread.