Tutorials › Statistical Methods for Single-Cell RNA Sequencing › Uneven Cell Density and Trajectory Geometry

Pseudotime and Trajectory Inference · Tutorial 377 of 700

Uneven Cell Density and Trajectory Geometry

Learn to separate sampling-density effects from trajectory geometry and to diagnose their consequences for principal curves, minimum spanning trees and diffusion distances.

Advanced 10 min read

What You'll Learn

  • Explain why local cell spacing depends on sampling density along a path.
  • Identify how density weighting can influence an empirical principal-curve fit.
  • Interpret long MST edges in sparse regions without treating them automatically as trajectory gaps.
  • Describe how transition normalization and stationary mass affect diffusion distances.
  • Use targeted diagnostics to distinguish density effects from changes in trajectory geometry.

Why Uneven Cell Density Matters

An inferred trajectory is built from observed cells, not from every possible state along a biological process. If many cells occupy one region of a state path and few occupy another, the geometry of the observations can therefore differ markedly from the geometry of the underlying path. A dense region may look finely resolved, while a sparse region may be represented by a few widely separated points. This matters for principal curves, minimum spanning trees (MSTs) and diffusion distances, but it does not affect all three in the same way.

The central distinction is between the path’s geometry and the distribution of sampled cells along that path. Density is not itself evidence of a branch, a state transition or a biological pause. Conversely, density can influence an estimator: an empirical fit or graph is constructed from the cells that were sampled, and those cells are not necessarily distributed uniformly along the path.

Definition: Let \(s\) denote arclength along a continuous cell-state path, and let \(f(s)\) be the probability density of sampled cells with respect to arclength. A region with larger \(f(s)\) is more densely sampled than a region with smaller \(f(s)\). The sampling density describes where observed cells lie; it does not, on its own, define the path’s geometric shape.

This distinction is useful but not absolute. The population distribution of cells can be part of the target of some methods, including the usual self-consistency definition of a principal curve. Thus, changing density while holding the support fixed may leave the underlying path unchanged but can still change a distribution-dependent fitted curve.

Local Spacing and the Principal-Curve Fit

Suppose cells are sampled independently along a smooth path, with density \(f(s)\), and consider a small region away from the ends of the path. A local approximation treats \(f(s)\) as nearly constant. In a short interval of arclength \(h\), the expected number of sampled cells is approximately \(n f(s)h\), where \(n\) is the total number of cells. The typical local spacing is therefore on the order of \(1/[n f(s)]\): it is smaller in dense regions and larger in sparse ones.

For a more precise justification in the uniform case, take \(n\) independent sample positions on a path of length \(L\). These positions divide the path into \(n+1\) intervals, including the two end intervals. By symmetry, the expected length of each interval is \(L/(n+1)\), since their lengths sum to \(L\). In a small region with approximately constant density \(f(s)\), the local rate of points per unit arclength is approximately \(n f(s)\); the corresponding local spacing is approximately its reciprocal. This is a local approximation, not an exact spacing formula for arbitrary density or near a path endpoint.

A principal curve is commonly described as a smooth curve that is self-consistent: at each location along the curve, the mean of the data points projecting to that location lies on the curve. In practice, fitting algorithms approximate this condition using the observed cells and their projections. Because the observations contribute to the fit, densely sampled regions contribute more terms to empirical summaries and fitting criteria than sparsely sampled regions unless an explicit weighting scheme changes their influence.

This does not mean that density always bends a fitted curve toward the densest region. For example, if all cells lie exactly on a straight line, changing their density along that line does not change the line’s geometry. The risk arises when there is noise, curvature, alternative plausible fits or limited data: then the empirical distribution can affect which curve best represents the observations. The earlier material on principal curves and branch failures provides the relevant geometric context; here the concern is how uneven sampling changes the evidence available to the fit.

Worked Example: Dense Regions Dominate an Unweighted Fit

Consider a hypothetical local fitting problem with two candidate curves, A and B. The fitting algorithm evaluates the sum of squared perpendicular distances from cells to each curve. There are 90 cells in a dense region and 10 in a sparse region. The average squared distances, in squared expression-space units, are:

RegionNumber of cellsCurve A: mean squared distanceCurve B: mean squared distance
Dense900.100.20
Sparse100.800.00

For the unweighted empirical sum, Curve A has total squared distance \(90(0.10)+10(0.80)=9+8=17\). Curve B has total \(90(0.20)+10(0.00)=18+0=18\). The criterion therefore favors Curve A, even though it fits the sparse region much worse.

If instead the goal were to give the two regions equal weight, their average regional losses would be \( (0.10+0.80)/2=0.45\) for A and \( (0.20+0.00)/2=0.10\) for B. That alternative target favors B. Neither calculation is universally correct: the choice depends on whether the goal is to represent the observed cell distribution or to give different parts of the path comparable influence. The example shows why the weighting target should be explicit.

Density Effects on Minimum Spanning Trees

An MST connects the observed cells with minimum total edge weight, without cycles. For a cell graph whose edge weights are Euclidean distances, the tree is shaped by the point cloud and by the chosen candidate edges. Uneven density changes the scale of local distances: dense regions usually contain many short candidate edges, while sparse regions are more likely to require longer edges to connect their cells to the rest of the graph.

A long MST edge is therefore not, by itself, proof of a biological gap. It may simply bridge a sparsely sampled stretch of a continuous path. On the other hand, sparse sampling also gives the graph fewer observations with which to establish the route through that stretch. If different portions of a curved path are close in the measured space, a short edge between nearby but nonconsecutive portions may compete with the longer edge that follows the actual path. The resulting tree can take a shortcut or attach cells in an unintended order.

The edge weights and candidate-neighbor construction matter. A graph built from a restricted neighborhood may omit a potentially misleading long edge; a graph that permits all pairwise edges may include it. The earlier material on choosing MST edge weights and pruning spurious branches is relevant to those design decisions. Neither choice removes the basic limitation that a sparse region contains less information about the path between its observed cells.

Worked Example: A Long Edge Can Reflect Sparse Sampling

Suppose five hypothetical cells lie on a continuous, straight state path, with measured coordinates \(0,\ 0.1,\ 0.2,\ 1.2,\) and \(2.2\) in arbitrary expression-space units. With Euclidean edge weights and all pairwise edges available, the MST connects adjacent coordinates. Its edge lengths are \(0.1,\ 0.1,\ 1.0,\) and \(1.0\), for a total length of \(2.2\).

The two length-1.0 edges span the sparsely sampled portion of the path; they are ten times the length of either edge in the dense cluster near zero. Yet the coordinates lie on one continuous line, so the long edges do not imply a true discontinuity. The tree has no observations between 0.2 and 1.2, or between 1.2 and 2.2, and cannot determine from these five points alone whether intermediate states were unobserved or absent.

A useful diagnostic is to compare long edges with the local edge-length distribution and the neighborhood scale used to build the graph. An unusually long edge deserves inspection, but its interpretation requires other evidence, such as the geometry of nearby cells and stability under reasonable graph choices. Edge length alone is not a test of biological continuity.

Density and Diffusion Distance

A diffusion distance compares cells by how different their transition-probability profiles are after a specified number of steps. Its behavior depends both on the affinity graph and on how the transition operator is normalized. For a connected, reversible Markov chain with transition matrix \(P\) and stationary distribution \(\pi\), the diffusion distance at integer time \(t\) can be written

$$ D_t^2(i,j)=\sum_k \frac{\left(P^t(i,k)-P^t(j,k)\right)^2}{\pi_k}. $$

Here \(P^t(i,k)\) is the probability of reaching cell \(k\) from cell \(i\) in \(t\) steps, and \(\pi_k\) is the stationary probability of cell \(k\). The inverse-\(\pi_k\) factor means that differences in transition probability toward low-stationary-mass cells can contribute substantially. In a graph whose stationary mass reflects local cell density, dense regions can have a different influence from sparse ones.

The exact density effect is not universal. It depends on the affinity kernel, the neighborhood scale and the normalization used to construct \(P\). Row normalization makes each row sum to one, but does not generally make the stationary distribution uniform. Other normalizations can alter how strongly sampling density enters the operator. Thus, one should not interpret a diffusion distance as a density-free measure of physical or biological path length. It is a measure of separation under a specified transition model.

Worked Example: Stationary Mass Changes a Diffusion Distance

Consider a hypothetical three-cell graph with transition matrix

$$ P= \begin{pmatrix} 0.8 & 0.2 & 0 \\ 0.1 & 0.8 & 0.1 \\ 0 & 0.2 & 0.8 \end{pmatrix}. $$

The chain is reversible with stationary distribution \(\pi=(0.25,\ 0.50,\ 0.25)\). For example, the probability flow between the first and second cells balances because \(0.25(0.2)=0.50(0.1)=0.05\); the second and third cells balance in the same way. After one step, the transition profiles from cells 1 and 3 differ by \((0.8,\ 0,\ -0.8)\). Therefore,

$$ D_1^2(1,3) =\frac{0.8^2}{0.25}+\frac{0^2}{0.50}+\frac{(-0.8)^2}{0.25} =2.56+0+2.56=5.12, \qquad D_1(1,3)=\sqrt{5.12}\approx 2.263. $$

The middle cell has twice the stationary mass of either endpoint, but the difference in the two endpoint profiles is zero at that cell. The endpoints’ differing probabilities occur at cells with lower stationary mass and are consequently weighted more heavily. This illustrates the formula’s weighting; it does not establish that every dense region will shrink every diffusion distance. Changing the graph or normalization changes the transition profiles and stationary distribution, and hence can change the result.

Diagnostics and Method Comparisons

Density effects are most concerning when a method’s apparent geometry changes substantially under reasonable changes to sampling or construction choices. Useful checks include plotting cells along the inferred ordering, examining local neighbor distances, and comparing results across neighborhood scales or density-aware weighting choices. For a principal curve, inspect fit residuals and whether dense regions dominate the fitted path. For an MST, inspect unusually long edges and possible shortcuts between nearby parts of a curved path. For diffusion distances, record the kernel, normalization and diffusion time; compare the inferred structure across defensible settings rather than treating one distance as an intrinsic quantity.

MethodHow uneven density can matterWhat to inspect
Principal curveObserved-cell weighting can give dense regions greater influence on an empirical fit.Regional fit residuals, curvature, and sensitivity to weighting.
MSTLocal edge lengths vary with spacing; sparse stretches may require long edges, and nearby path segments may be connected by shortcuts.Long edges, candidate-neighbor rules, and stability under plausible graph choices.
Diffusion distanceTransition profiles and stationary mass depend on the graph and its normalization.Kernel and normalization choices, neighborhood scale, diffusion time, and density patterns.

Each method also has a different limitation. A principal curve summarizes data with a smooth curve and can be sensitive to the distribution it summarizes. An MST gives a tree connecting observed cells but does not fill in unobserved states or establish that each edge follows a biological process. A diffusion distance summarizes connectivity through a chosen transition operator, not direct arclength along a unique path. These are complementary representations, not interchangeable estimates of one guaranteed geometric truth.

A common mistake is to interpret a dense cluster as a biological state in which cells must remain longer, or to interpret a long sparse-region edge as evidence of a true trajectory break. The correction is to separate what the data directly show—cell locations and their sampling frequency—from what the inferred geometry assumes. Density can reflect biological abundance, sampling design, capture efficiency or other factors; geometry alone does not identify which explanation applies.

Key takeaway: Uneven density changes the resolution of observed paths and can influence fitted curves, tree edges and diffusion metrics. Diagnose the effect using local spacing, regional fit behavior and sensitivity to graph construction and normalization; do not equate density or edge length with biological time or discontinuity.

Check Your Understanding

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

  1. If local sampling density along a path doubles while the total sample size and local approximation remain fixed, what happens to the approximate local cell spacing?
  2. A principal-curve fit has a lower total squared error for Curve A, but Curve B has lower average error when dense and sparse regions receive equal weight. What does this say about the fitting target?
  3. Why is a long MST edge in a sparse region not sufficient evidence of a true trajectory gap?
  4. In the diffusion-distance formula, what role does the stationary probability \(\pi_k\) play?

Solutions. (1) Since approximate spacing is proportional to \(1/[n f(s)]\), doubling \(f(s)\) halves the local spacing. (2) The unweighted fit favors the observed cell distribution, in which the dense region contributes more observations; equal regional weighting defines a different target and can favor B. Neither criterion is automatically correct without specifying the aim. (3) A continuous path can be sparsely sampled, leaving long edges between observed cells; the edge gives no direct evidence about unobserved intermediate states. (4) It weights squared differences between transition profiles by \(1/\pi_k\), so differences at low-stationary-probability cells can contribute more to the distance.

Clinical Biostats