What an Embedding Can—and Cannot—Show
A VAE embedding is a compact representation of cells under a fitted model. It can help summarize similarities, reveal patterns worth investigating, and organize downstream checks. But a point on a plot is not a direct measurement of a biological state. Its location depends on the model, the data and preprocessing, the latent representation, and often a further visualization step. Interpretation therefore requires checking what the representation preserves and how uncertain it is.
The earlier material on identifiability and disentanglement establishes an important caution: different latent coordinate systems can represent the same structure. A sign change, rotation, or other transformation can change the apparent meaning of an axis without changing the model’s essential representation. A plotted separation or an association with a gene is evidence to assess, not proof of a cell type, mechanism, or causal relationship.
These summaries answer different questions. Posterior means give a convenient set of coordinates for comparing cells. Posterior distributions indicate how precisely the encoder locates each cell, conditional on the fitted model and its assumptions. A two-dimensional display may additionally distort distances or neighborhoods. Whenever possible, assess the latent space itself as well as any visualization derived from it.
Check Neighborhood Preservation
A neighborhood-preservation check asks whether cells that are near one another in a chosen reference space remain near in the embedding, and whether the embedding introduces neighbors that were not near in that reference. The reference space must be stated: for example, a specified set of scaled gene features with a specified distance. The result is conditional on those choices; it is not a universal measure of biological truth.
For \(n\) cells, let \(r(i,j)\) be the rank of cell \(j\) among cells ordered by distance from cell \(i\) in the reference space. Let \(\hat r(i,j)\) be the corresponding rank in the embedding. Ties require a consistent ranking rule. For a chosen neighborhood size \(k\), define \(U_i^k\) as the cells among the \(k\) nearest embedded neighbors of \(i\) that are not among its \(k\) nearest reference-space neighbors. The trustworthiness score penalizes these “introduced” neighbors:
A score closer to 1 indicates fewer and less severe introduced neighbors at that \(k\). The rank penalty matters: introducing a cell that was only just outside the reference neighborhood is less serious than introducing one ranked far away. The normalization makes the score comparable across values in its defined range when \(k<n/2\). Trustworthiness alone does not penalize reference neighbors that disappear from the embedding. Continuity complements it: it penalizes cells in the reference-space \(k\)-neighborhood that are missing from the embedded \(k\)-neighborhood, using their embedded ranks in the same rank-penalty form. Report the metric, \(k\), and reference-space definition rather than calling a score simply “good.”
Worked Example: Calculating Trustworthiness at One Neighborhood Size
Suppose five hypothetical cells, A–E, are compared using a specified reference distance and an embedding distance. Set \(k=1\). The table reports, for each cell, its nearest embedded neighbor and that neighbor’s rank in the reference space.
| Cell \(i\) | Nearest embedded neighbor | Reference-space rank \(r(i,j)\) | Penalty \(\max(0,r(i,j)-1)\) |
|---|---|---|---|
| A | C | 2 | 1 |
| B | D | 3 | 2 |
| C | A | 2 | 1 |
| D | B | 4 | 3 |
| E | A | 3 | 2 |
Each embedded neighbor is outside its cell’s reference nearest-neighbor set, so these five penalties are the terms in the sum. Their sum is \(1+2+1+3+2=9\). The normalization denominator is \(n k(2n-3k-1)=5(1)(10-3-1)=30\). Therefore,
For this hypothetical ranking, the embedding has several introduced nearest neighbors, including some ranked far from the reference nearest neighbor. The score describes preservation at \(k=1\) under the stated distances; it does not establish that the reference space is biologically correct or that the embedding is useless for every purpose.
A short justification for the penalty is that the reference ranks of introduced neighbors are at least \(k+1\), so each contributes a positive amount that grows with how far away it was. If there are no introduced neighbors, the sum is zero and \(T(k)=1\). A score can also be misleading if \(k\) is chosen after inspecting results, if many distances are tied, or if the reference metric is inappropriate. Examine more than one scientifically reasonable \(k\), and compare results across plausible reference metrics.
Posterior Uncertainty Is Not Optional
A posterior-mean plot hides the spread of \(q(z_i\mid x_i)\). In a common encoder parameterization, \(q(z_i\mid x_i)\) is a multivariate normal distribution with a diagonal covariance matrix. Under that assumption, each coordinate has a posterior mean and variance, but a coordinate-wise interval does not by itself describe uncertainty in every direction or in pairwise distance. If the encoder uses a different posterior family, use its actual covariance structure rather than assuming independence across coordinates.
One practical check is to draw repeated latent vectors from each cell’s approximate posterior and recompute neighborhood ranks. Cells whose neighbors vary substantially across draws have uncertain local placement, even if their posterior means look well separated. This reflects uncertainty represented by the fitted approximate posterior; it does not automatically include uncertainty from model choice, training randomness, unmeasured confounding, or a misspecified observation model.
Worked Example: Interpreting a Posterior Coordinate
For a hypothetical cell, suppose the encoder gives \(q(z_{i1}\mid x_i)=N(1.2,0.16)\), where the second argument is the variance. The coordinate’s posterior standard deviation is \(\sqrt{0.16}=0.4\). A normal-approximation interval covering about 95% of this coordinate’s posterior mass is
The posterior probability that this coordinate is above zero is \(P_q(z_{i1}>0\mid x_i)=\Phi(1.2/0.4)=\Phi(3)\approx0.9987\). This is a statement about the encoder’s approximate posterior for this cell under the fitted model. It is not a 99.87% probability that the cell has a biological property, nor does it give the probability that the model is correct. To assess neighborhood uncertainty, one would additionally sample full latent vectors and check how often the cell’s neighbors change.
When uncertainty is large relative to distances between posterior means, a sharp cluster boundary can be an artifact of plotting point estimates. Useful diagnostics include comparing posterior standard deviations across cells, checking whether cells with high uncertainty have unstable neighbors, and showing uncertainty rather than only a single point where feasible. High uncertainty is not necessarily a model failure: some cells may genuinely be poorly localized under the fitted model. It does limit the strength of claims based on their exact position.
Gene-Level Associations Need Context
A gene-level association asks whether a chosen gene’s measured expression varies with a latent coordinate or another embedding summary. It can help describe what a coordinate is associated with, but it does not establish that the coordinate is a biological pathway, that the gene caused the position, or that the association will generalize to another sample. State which expression measurement was used, which latent summary was tested, and whether the analysis is descriptive or inferential.
Worked Example: A Descriptive Gene–Coordinate Correlation
Consider five hypothetical cells with latent coordinate values \(x=(-2,-1,0,1,2)\) and log-normalized measured expression values \(y=(1,2,2,4,6)\) for one gene. These values are illustrative, not from a real study. The means are \(\bar{x}=0\) and \(\bar{y}=3\). The centered cross-product sum is
The centered sum of squares for \(x\) is \(4+1+0+1+4=10\); for \(y\), it is \(4+1+1+1+9=16\). Thus the Pearson correlation is
In these five hypothetical cells, the gene’s measured expression is strongly positively associated with the coordinate. This is a descriptive association, not evidence that the coordinate measures a particular biological process or that the gene changes the latent position. The cells also do not constitute five independent biological replicates: a cell-level correlation cannot, by itself, justify population-level inference. In a real analysis, batch, library size, cell composition, repeated samples, and gene-selection multiplicity can all affect the observed association.
An association can arise because both the gene and the latent coordinate vary with a third factor, such as batch or cell type. It can also depend on which cells were included and on the gene-expression scale. Inspect associations within relevant groups or across biological replicates when the design allows; report the analysis choices and avoid presenting a selected set of striking genes as if it had been specified in advance. This tutorial concerns interpretation of associations, not a claim that a particular testing procedure resolves these design issues.
Compare Representations and Diagnose Failure
Different summaries answer different questions. Posterior means give one coordinate per cell and are convenient for ranking and plotting, but conceal posterior spread. Posterior samples retain uncertainty represented by the approximate posterior and can expose unstable neighborhoods, but add computational work and do not remove model misspecification. A two-dimensional visualization is easy to inspect, but can distort distances and local neighborhoods; scores computed only on that display assess the display, not necessarily the original latent space. Trustworthiness and continuity quantify complementary neighborhood errors, while gene associations provide biological context but are vulnerable to confounding and selective interpretation.
For a defensible assessment, inspect whether the conclusions are sensitive to reasonable changes in neighborhood size, distance definition, posterior draw, and visualization. Look for batch-aligned neighborhoods, abrupt boundaries among cells with broad posterior uncertainty, and gene associations driven by a small number of cells. Compare embedding-space neighborhoods with a clearly specified reference rather than assuming that either representation is the gold standard. A pattern that disappears under modest, justified perturbations deserves weaker interpretation.
Specify whether coordinates are posterior means, posterior samples, or a two-dimensional projection, and name the cells and features included.
Choose a reference distance and neighborhood sizes; calculate complementary preservation summaries and assess neighbor stability across posterior draws where possible.
For gene-level patterns, name the expression scale and coordinate, investigate plausible confounders, and distinguish descriptive patterns from biological or causal conclusions.
A common mistake is to label an axis “activation” because one gene correlates with it, or to call a visually separated group a new cell type. The reasoning is incomplete: latent axes can be reoriented, gene associations can reflect confounding, and visual separation can be altered by the projection. The correction is to report the association as an association, check it against uncertainty and neighborhood preservation, and seek independent evidence before assigning biological meaning.
Check Your Understanding
Answer each question, then compare your reasoning with the solutions below.
- At \(k=1\), what does a trustworthiness score penalize, and what does continuity assess instead?
- A cell has posterior coordinate \(N(0.3,0.49)\). What is its posterior standard deviation, and why is the posterior mean alone an incomplete summary?
- Why does a strong correlation between a gene and a latent coordinate not establish that the gene causes a biological state?
- A cluster is visible in a two-dimensional plot but has unstable neighbors across posterior samples. What should be reported cautiously?
- Why should an analysis name its reference distance and neighborhood size when reporting preservation?
Solutions. (1) Trustworthiness penalizes embedded neighbors that are not close neighbors in the reference space, with larger penalties for more distant ranks. Continuity instead penalizes reference neighbors that are missing from the embedding. (2) The standard deviation is \(\sqrt{0.49}=0.7\). The mean omits spread, so it cannot show whether the cell’s location and neighbors are uncertain. (3) The association may be confounded, for example by batch or cell composition, and correlation does not establish causal direction. (4) Report that the apparent separation is uncertain under the fitted posterior; do not treat the plotted boundary alone as evidence of a stable biological category. (5) Preservation scores depend on the reference representation, distance metric, and \(k\), so the score has no complete interpretation without those choices.