Tutorials › Statistical Methods for Single-Cell RNA Sequencing › Local and Global Geometry Across Embeddings

Dimension Reduction and Embeddings · Tutorial 222 of 700

Local and Global Geometry Across Embeddings

Learn which geometric claims are supported by PCA, t-SNE, and UMAP, and how to check whether an embedding retains the cell neighborhoods you care about.

Intermediate 11 min read

What You'll Learn

  • Distinguish local neighborhood preservation from preservation of global distances and rankings.
  • Derive how PCA changes pairwise distances when components are omitted.
  • Interpret t-SNE and UMAP objectives as emphasizing neighborhood relationships rather than a common global distance scale.
  • Calculate a simple neighborhood-overlap diagnostic and interpret its limits.
  • Identify when a close pair in an embedding needs confirmation in the original representation.

What Does an Embedding Preserve?

A two-dimensional plot makes every pair of cells look comparable: each pair has a visible distance, and groups of points appear to have an arrangement. But the algorithms that place those points do not all aim to preserve the same geometry. A close pair may be informative about local similarity under a chosen representation and distance metric, while the direction, spacing, or ordering of distant groups may be much less informative.

The question is therefore not whether an embedding preserves “the geometry” in general. It is which relationships it was designed to preserve, which it actually retains for the cells of interest, and which claims go beyond that evidence. Here, local geometry means relationships among a cell and its nearby cells, such as membership in its \(k\) nearest neighbors. Global geometry means broader relationships, including distances or distance rankings across many pairs of cells.

Definition: Let \(x_i\) denote the representation of cell \(i\) before embedding, with distances calculated using a specified metric, and let \(z_i\) denote its coordinates in the lower-dimensional embedding. A local-neighborhood claim concerns which cells are near \(x_i\) relative to other cells under the specified metric. A global-geometry claim concerns broader properties such as pairwise distances, their relative magnitudes, or the arrangement of separated parts of the plot. Neither claim is meaningful without specifying the representation and metric used for \(x_i\).

In practice, “before embedding” might mean expression-derived PC scores rather than the full gene-expression profile. The resulting conclusion is conditional on that choice: a neighborhood retained from PC scores is a neighborhood under the selected PC representation and metric. It is not automatically a claim about every aspect of the original expression data.

Different Objectives, Different Geometric Evidence

PCA, t-SNE, and UMAP should not be read as three ways to produce an interchangeable map. PCA projects observations onto a selected set of orthogonal directions chosen to capture variation. If all components are retained, the rotation itself preserves Euclidean distances. When components are omitted, distances can shrink, and some pairwise rankings can change. The retained-component plot is therefore a linear projection, not a guarantee that every distance or neighborhood is unchanged.

t-SNE represents high-dimensional pairwise similarities as probabilities and seeks low-dimensional similarities that fit them. Its objective gives particular weight to fitting the similarity structure of pairs that are close in the input representation. It is not an objective that requires all low-dimensional distances to be proportional to input distances. Thus, nearby points can help identify candidate local relationships, but the layout’s large-scale spacing is not a calibrated ruler for comparing the original distances between arbitrary pairs.

UMAP begins from fuzzy neighborhood memberships and optimizes a low-dimensional representation to fit those memberships. Its cross-entropy objective rewards agreement with the input neighborhood structure, with an optimization procedure that also accounts for pairs not represented as strong input neighbors. This gives the layout local-structure information, but it does not impose a universal scale on all distances in the plot. Some broader arrangements may be visually suggestive; they should not be treated as preserved global distances unless that property has been checked separately.

These distinctions describe the methods’ objectives, not an automatic guarantee that a particular plot has successfully retained the intended neighbors. Dimensions, parameters, input representation, and finite optimization all affect the result. The relevant evidence comes from comparing neighborhoods in the embedding with neighborhoods in the representation that was supplied to the method.

A Geometric Fact About PCA

The distance behavior of PCA can be stated exactly. Suppose two cells differ by a vector \(d=x_i-x_j\), expressed in an orthonormal PC basis. Write the coordinates of \(d\) as \(d_1,\ldots,d_D\), and retain the first \(r\) components. The squared distance before projection is the sum of squared differences across all components. After projection, only the first \(r\) terms remain.

$$ \|x_i-x_j\|^2 = \sum_{\ell=1}^{D} d_\ell^2 \qquad\text{and}\qquad \|z_i-z_j\|^2 = \sum_{\ell=1}^{r} d_\ell^2. $$

Subtracting the second expression from the first gives

$$ \|x_i-x_j\|^2-\|z_i-z_j\|^2 = \sum_{\ell=r+1}^{D} d_\ell^2 \geq 0. $$

So, under Euclidean distance in an orthonormal PC basis, projection cannot increase a pair’s distance; it removes the contribution from omitted directions. This fact does not say that a pair’s distance shrinks by the same proportion as another pair’s distance. If two pairs differ in how much of their separation lies in omitted components, their distance ranking can reverse. The calculation also assumes that both distances are being compared in this same coordinate system with the same Euclidean metric.

Worked Example: A PCA Projection Reverses a Pair Ranking

Consider four hypothetical cells represented by their coordinates on three orthonormal PCs. Suppose the visualization retains only PC1 and PC2. Pair A–B differs by \((2,0,0)\), while pair C–D differs by \((1,1,2)\). Calculate both distances before and after projection.

For A–B, the full squared distance is \(2^2+0^2+0^2=4\), so its full distance is \(\sqrt{4}=2\). After omitting PC3, its projected distance is \(\sqrt{2^2+0^2}=\sqrt{4}=2\).

For C–D, the full squared distance is \(1^2+1^2+2^2=6\), so its full distance is \(\sqrt{6}\approx 2.449\). After omitting PC3, its projected distance is \(\sqrt{1^2+1^2}=\sqrt{2}\approx 1.414\).

In the full representation, A–B is closer than C–D because \(2<2.449\). In the two-PC projection, C–D is closer than A–B because \(1.414<2\). The reversal is possible because C–D’s separation includes a larger contribution from the omitted component. The projected plot is still a valid view of the retained PCs; it just does not preserve this pair ranking from the full three-PC representation.

Checking Whether Neighbors Were Retained

A simple diagnostic compares the \(k\) nearest neighbors of each cell before and after embedding. Let \(N_k^X(i)\) be cell \(i\)’s \(k\) nearest neighbors under the chosen input representation and metric, and let \(N_k^Z(i)\) be its \(k\) nearest neighbors in the embedding. For a particular cell, the overlap proportion is

$$ \frac{|N_k^X(i)\cap N_k^Z(i)|}{k}. $$

This score ranges from 0 to 1 when each neighborhood contains \(k\) distinct cells. A score of 1 means the two sets agree for that cell; a score of 0 means none of the \(k\) neighbors agree. It is a useful summary, but it treats each neighbor as equally important and does not say whether a missing neighbor was barely inside the input neighborhood or much closer than the cells that replaced it. It also depends on \(k\): changing \(k\) changes the question being asked.

Worked Example: Calculating Neighborhood Overlap

Suppose that, under a specified input representation and metric, hypothetical cell A has input neighbors B and C when \(k=2\). In an embedding, its two nearest neighbors are B and D. Calculate the overlap and interpret it.

The shared set is \(\{B\}\), so \(|N_2^X(A)\cap N_2^Z(A)|=1\). The overlap proportion is \(1/2=0.5\). Thus one of A’s two input neighbors is also among its two embedding neighbors.

This result supports a limited statement: for this cell and this choice of \(k\), the embedding retains one of its two specified neighbors. It does not establish that all cells have similar overlap, that the same result holds at another \(k\), or that the plotted distance between A and B matches their input distance. A broader assessment would calculate the diagnostic for the cells relevant to the analysis and inspect whether low scores are concentrated in particular regions or types of cells.

More detailed diagnostics can account for neighbor ranks rather than only set overlap. For example, trustworthiness penalizes points that appear among a cell’s embedding neighbors despite having poor ranks in the input space. Such a diagnostic targets false neighbors; other diagnostics target input neighbors that the embedding has displaced. These checks answer different questions, so no single number certifies that an embedding preserves all geometry.

What a Close Pair Can and Cannot Support

A close pair in an embedding is a useful lead, not a stand-alone conclusion about biological identity or a guarantee of original-space proximity. For PCA, the retained coordinates give an exact distance in the retained projection, but omitted directions can still matter. For t-SNE and UMAP, proximity reflects an optimized low-dimensional arrangement of input similarities or memberships; it does not generally translate into a proportional input distance. For all three methods, the claim becomes stronger when the same pair is also close under the specified input representation and metric, and when the embedding retains relevant neighbors under an appropriate diagnostic.

A calculated comparison of t-SNE pair contributions illustrates why its objective should not be read as a distance-preservation rule. In the t-SNE objective, a pair with high input similarity \(p_{ij}\) is costly when its low-dimensional similarity \(q_{ij}\) is too small. A pair with very small \(p_{ij}\), by contrast, contributes little to the objective even if its \(q_{ij}\) is not as small.

Worked Example: Why a t-SNE Pair Contribution Is Not a Ruler

For illustration, consider two entries from hypothetical normalized similarity distributions. For one pair, let \(p_{ij}=0.08\) and \(q_{ij}=0.04\). Its term in the KL divergence is \(p_{ij}\ln(p_{ij}/q_{ij})\). For a second pair, let \(p_{ij}=0.001\) and \(q_{ij}=0.04\).

For the first pair, the contribution is \(0.08\ln(0.08/0.04)=0.08\ln(2)\approx 0.05545\). For the second, it is \(0.001\ln(0.001/0.04)=0.001\ln(0.025)\approx -0.003689\). Individual terms can be negative; the divergence as a whole is nonnegative.

The contrast shows that the objective’s response depends on the pair’s input similarity, not just on a geometric distance in the map. In particular, this calculation does not give a rule for interpreting the distance between two plotted groups as an input-space distance. The full objective involves all pairs, and these selected terms are only an illustration of its weighting.

The same caution applies to UMAP: a fuzzy membership expresses the strength of a local relationship in the input neighborhood representation, not a promise that every plotted distance has a common interpretation across the map. In either method, a close plotted pair is best treated as a candidate local relationship to examine, rather than proof that the entire plot preserves pairwise distances.

Diagnostics, Comparisons, and Limitations

A practical comparison begins by writing down the input representation and metric, then naming the geometric claim of interest. If the question concerns a cell’s nearest neighbors, compare those neighbors directly for the chosen \(k\). If the question concerns relative distances across many pairs, calculate those distances or rankings in both representations rather than inferring them from visual spacing. When comparing PCA, t-SNE, and UMAP, evaluate each method against the same input representation and metric; otherwise, differences can arise from the input definition as well as from the embedding.

MethodPrimary geometric targetInterpretation to handle cautiously
PCAVariation along retained orthogonal directions; distances in the retained projection are well definedInput-space distances and neighbor rankings when omitted components contribute unequally
t-SNEAgreement between high-dimensional and low-dimensional pairwise similarities, emphasizing local similaritiesDistances and spacing across the map as measures of original-space separation
UMAPAgreement between input fuzzy neighborhood memberships and low-dimensional membershipsA universal distance scale or guaranteed preservation of every input neighbor

Diagnostics are most useful when they match the claim. Neighbor overlap can reveal whether a particular local neighborhood was retained; rank-sensitive checks can reveal whether apparent neighbors were distant in the input ranking. Pairwise-distance or rank comparisons are more relevant to global claims. Visual inspection alone cannot establish these properties. A method may preserve many neighborhoods on average while losing the particular neighborhood that matters for an analysis.

There are also limits to what geometry can establish. A preserved neighborhood means proximity under the selected representation and metric; it does not, by itself, establish a cell type, developmental relationship, or causal process. Conversely, a low neighborhood score may reflect projection or optimization, but it can also expose a mismatch between the chosen representation, metric, and scientific question. The map should therefore be interpreted alongside the input-space evidence and the purpose for which the embedding was made.

Common Mistake

Wrong reasoning: “These two groups are far apart on the t-SNE or UMAP map, so their cells must be much more different than two groups that look closer.” This treats plotted distances as if the method preserved one global scale of input-space distance.

Correction: The methods optimize neighborhood-based similarity structures, not a common proportional distance scale for every pair. Check the relevant cells’ distances or ranks in the input representation, and state explicitly whether a conclusion concerns input-space proximity, embedding proximity, or a measured neighborhood-preservation result. A visual layout can suggest comparisons to test; it cannot substitute for them.

Key takeaway: Interpret a cell’s embedding neighbors as candidate local relationships, then check them against the same input representation and metric used to define the analysis. Do not infer map-wide distances or rankings from visual spacing alone.

Check Your Understanding

Answer each question using the distinction between input-space geometry and embedding geometry.

  1. A PCA plot retains two of three orthonormal PCs. Can the projected distance between a pair exceed its full three-PC Euclidean distance? Why?
  2. For a cell with \(k=4\), three embedding neighbors are also input neighbors. What is its neighborhood-overlap proportion?
  3. Why does a high t-SNE input similarity for a pair make a small low-dimensional similarity more consequential than the same mismatch for a very low-similarity pair?
  4. Name one check more appropriate for a claim about local neighbors and one more appropriate for a claim about global pairwise distances.

Solutions. (1) No. The projected squared distance omits nonnegative squared differences, so it cannot exceed the full squared distance. (2) The overlap is \(3/4=0.75\), meaning three of the four specified input neighbors are retained in the embedding neighborhood. (3) The KL contribution for a pair is \(p_{ij}\ln(p_{ij}/q_{ij})\); a mismatch for a large \(p_{ij}\) receives greater weight than a comparable low-dimensional mismatch for a very small \(p_{ij}\). (4) Compare \(k\)-nearest-neighbor sets or use a rank-sensitive neighborhood diagnostic for a local claim; compare pairwise distances or their rankings in the two spaces for a global claim.

Clinical Biostats