Comparing Cells by Their Multi-Step Transitions
Two cells can be close in an expression-space representation yet differ in how their local neighborhoods connect to the rest of a cell graph. Diffusion distance compares them through the transition distributions they generate: after a specified number of steps, how similarly are their probabilities spread across the graph? This gives a graph-based notion of similarity that incorporates indirect paths, not only a direct edge or immediate neighborhood.
The introductory material on Diffusion Maps from Eigenvectors motivates representing cells with eigenvectors of a transition operator. Here we derive the corresponding distance formula and connect it directly to the transition distributions it summarizes.
The stationary weights matter: a discrepancy in a cell with small \(\pi_k\) contributes more than an equally sized discrepancy in a common cell. This weighting is part of the definition, not an optional rescaling. The distance is dimensionless because its inputs are probabilities.
Assumptions and the Spectral Formula
For the standard spectral formula, assume the cell graph defines a finite, connected, reversible Markov chain. Reversibility means detailed balance holds: \(\pi_iP_{ik}=\pi_kP_{ki}\) for every pair \(i,k\). The probabilities \(\pi_k\) sum to one and are stationary, meaning \(\sum_i\pi_iP_{ik}=\pi_k\). Connectedness ensures that the eigenvalue \(1\) is simple. Reversibility makes \(P\) self-adjoint under the \(\pi\)-weighted inner product, so it has real eigenvalues and a complete set of eigenfunctions orthonormal under that inner product.
Write the eigenvalues as \(1=\lambda_0,\lambda_1,\ldots,\lambda_{m-1}\), where \(m\) is the number of cells, and let \(\psi_\ell\) satisfy \(P\psi_\ell=\lambda_\ell\psi_\ell\). Choose the eigenfunctions so that \(\sum_k\pi_k\psi_\ell(k)\psi_r(k)=1\) when \(\ell=r\) and \(0\) otherwise. The stationary eigenfunction is \(\psi_0(k)=1\). Under these conditions, the spectral formula is:
To justify the formula, reversibility and the stated orthonormal normalization give the transition-probability expansion \(P^t_{ik}=\pi_k\sum_{\ell=0}^{m-1}\lambda_\ell^t\psi_\ell(i)\psi_\ell(k)\). Subtract the corresponding expansion for cell \(j\), then substitute into the definition of \(D_t^2\):
The second equality uses orthonormality: the inner sum is zero for \(\ell\ne r\) and one for \(\ell=r\). The final equality drops \(\ell=0\), since \(\psi_0(i)-\psi_0(j)=1-1=0\). The square on \(\lambda_\ell^t\) is important, including when an eigenvalue is negative.
Worked Example: Comparing Two-Step Distributions
Consider three hypothetical cells with transition matrix
Each row sums to one. The stationary distribution is \(\pi=(0.25,0.50,0.25)\): for example, the probability flowing from cell 1 to cell 2 is \(0.25(0.5)=0.125\), equal to the reverse flow \(0.50(0.25)=0.125\); the same balance holds between cells 2 and 3. Thus detailed balance holds.
The two-step distribution from cell 1 is row 1 of \(P^2\). Its entries are \(0.5(0.5)+0.5(0.25)=0.375\), \(0.5(0.5)+0.5(0.5)=0.500\), and \(0.5(0)+0.5(0.25)=0.125\). From cell 3, the entries are \(0(0.5)+0.5(0.25)+0.5(0)=0.125\), \(0(0.5)+0.5(0.5)+0.5(0.5)=0.500\), and \(0(0)+0.5(0.25)+0.5(0.5)=0.375\). So the distributions are \((0.375,0.500,0.125)\) and \((0.125,0.500,0.375)\).
Their middle-cell probabilities agree. The difference at each endpoint is \(0.250\) in magnitude. Therefore
After two steps, the cells still differ in how much probability reaches the two endpoints, while their probabilities for the middle cell coincide. The stationary weighting gives each endpoint discrepancy a contribution of \(0.250\) to the squared distance.
Reading the Formula and Its Time Dependence
Each nonstationary eigenfunction measures a pattern of variation across cells. The term \(\{\psi_\ell(i)-\psi_\ell(j)\}^2\) records how differently that pattern scores the two cells; \(\lambda_\ell^{2t}\) determines how much that pattern contributes at time \(t\). When \(|\lambda_\ell|<1\), its contribution decays as \(t\) grows. The distance thus compares distributions after a chosen number of transitions, rather than asserting that cells are close in every possible sense.
In diffusion coordinates, cell \(i\) has coordinates \(\lambda_\ell^t\psi_\ell(i)\) for the nonstationary eigenfunctions. The squared Euclidean distance between these coordinates is exactly the spectral formula, provided all nonstationary components are included. Keeping only a subset gives an approximation, not generally the exact diffusion distance.
Worked Example: Checking the Spectral Calculation
For the three-cell chain above, the eigenvalues are \(1\), \(0.5\), and \(0\). A normalized eigenfunction for \(\lambda_1=0.5\) is \(\psi_1=(\sqrt{2},0,-\sqrt{2})\): its squared weighted norm is \(0.25(2)+0.50(0)+0.25(2)=1\). The eigenfunction for \(\lambda_2=0\) can be taken as \(\psi_2=(1,-1,1)\); it has weighted mean zero and squared weighted norm \(0.25+0.50+0.25=1\).
For cells 1 and 3 at \(t=2\), the \(\lambda_1\) contribution is \((0.5)^{4}(\sqrt{2}-(-\sqrt{2}))^2 =0.0625(8)=0.500\). The \(\lambda_2\) contribution is \(0^{4}(1-1)^2=0\). The resulting squared distance is \(0.500\), agreeing with the direct calculation from the two transition distributions.
At \(t=1\), the same pair has squared distance \((0.5)^2(2\sqrt{2})^2=0.25(8)=2\), hence distance \(\sqrt{2}\approx1.414\). The zero eigenvalue contributes nothing at either positive time. The larger distance at one step is consistent with the calculation: the one-step endpoint distributions, \((0.500,0.500,0)\) and \((0,0.500,0.500)\), are more different under the weighted comparison than the two-step distributions.
Worked Example: Why the Stationary Weights Matter
Compare cells 1 and 2 in the same chain after two steps. Cell 1 has distribution \((0.375,0.500,0.125)\). From cell 2, the two-step probabilities are \(0.25(0.5)+0.5(0.25)+0.25(0)=0.250\), \(0.25(0.5)+0.5(0.5)+0.25(0.5)=0.500\), and \(0.25(0)+0.5(0.25)+0.25(0.5)=0.250\). The difference is \((0.125,0,-0.125)\), so
If one instead used the unweighted Euclidean distance between these probability vectors, its squared value would be \((0.125)^2+0^2+(-0.125)^2=0.03125\). That is a different quantity: it omits the stationary correction. A small value from the unweighted calculation cannot be reported as the diffusion distance defined here.
Diagnostics, Alternatives, and Limitations
Before interpreting a calculated diffusion distance, check that the transition matrix is row-stochastic, the stationary probabilities are positive on the cells being compared, and detailed balance holds for the claimed reversible formulation. For a matrix derived from a symmetric affinity graph, the chosen normalization determines the transition matrix and its stationary distribution; these should be checked rather than assumed. A disconnected graph has multiple closed components, so the stationary eigenvalue need not be simple and cells in separate components may not communicate. A single connected-chain spectral interpretation then requires care.
A truncated spectral calculation can be checked by examining the omitted contribution:
where \(D_{t,L}^2\) retains only the first \(L\) nonstationary terms. Thus truncation underestimates the exact squared distance; it is adequate only when the omitted terms are negligible for the cell pairs and time of interest. Very small stationary probabilities can also magnify modest probability differences and make the distance sensitive to rare cells or graph irregularities.
Diffusion distance differs from ordinary Euclidean distance in a chosen expression or embedding space: it compares transition distributions and therefore reflects graph connectivity and multi-step routes. It also differs from shortest-path distance, which focuses on a least-cost route rather than the full distribution of possible walks. These alternatives answer different questions; none is a universal replacement. Diffusion distance depends on the graph, its normalization, and the chosen \(t\), and it is not by itself a measure of biological causation or a guarantee that the inferred graph represents true cell-state connectivity.
Common Mistakes
- Dropping the stationary denominator. This changes the defined metric; use \(\pi_k\) for each destination cell \(k\).
- Using \(\lambda_\ell^t\) rather than \(\lambda_\ell^{2t}\) in the squared distance. The eigenvalue factor is squared when the coordinate difference is squared.
- Keeping the stationary eigenfunction as a nonzero contribution. It is constant across cells, so its difference is zero.
- Calling a low-dimensional spectral approximation exact. Omitted components are nonnegative contributions to squared distance and may matter.
- Interpreting the result as a direct expression difference. It measures differences in multi-step transition distributions under the specified graph and time.
Check Your Understanding
Answer each question, then compare your reasoning with the solutions.
- Why does the spectral formula omit the stationary eigenfunction?
- If two transition distributions differ by \(0.10\) at a destination with stationary probability \(0.20\), what is that destination’s contribution to the squared diffusion distance?
- What does retaining fewer eigenfunctions do to the computed squared distance?
- Why is a shortest-path distance not generally the same as diffusion distance?
Solutions. (1) The stationary eigenfunction is constant, so its difference between any two cells is zero. (2) The contribution is \((0.10)^2/0.20=0.0500\). (3) It omits nonnegative terms, so the truncated squared distance is no larger than the exact one. (4) Shortest-path distance uses a least-cost route, whereas diffusion distance compares the full \(t\)-step probability distributions, including probabilities spread across multiple possible routes.