distortions PackageModern omics data have many features, and dimensionality reduction methods help create overview visualizations.
They are also used in cell atlas construction and trajectory inference.
\(\def\Dir{\text{Dir}}\) \(\def\Mult{\text{Mult}}\) \(\def\*#1{\mathbf{#1}}\) \(\def\m#1{\boldsymbol{#1}}\) \(\def\Unif{\text{Unif}}\) \(\def\win{\tilde{w}_{\text{in}}}\) \(\def\reals{\mathbb{R}}\) \(\newcommand{\wout}{\tilde w_{\text{out}}}\)
Both \(t\)-SNE and UMAP introduce distortions. For example, they may not preserve density within different regions of the plot.
Example from (Narayan, Berger, and Cho 2021).
They can also fail to preserve the topology of the underlying data…
Example from (Kobak and Linderman 2021).
These distortions are not mere technical curiosities – they significantly impact scientific interpretation (Liu, Ma, and Zhong 2025; Kobak and Linderman 2021). For example, they create misleading differences between cell types that are actually similar.
Example from (Xia, Lee, and Li 2024).
Rather than abandoning nonlinear dimensionality reduction, we augment the embeddings to characterize distortion.


This is a high-dimensional version of Tissot’s indicatrix from cartography (Laskowski 1989).
The RMetric algorithm (Perrault-Joncas and Meila 2006; McQueen et al. 2016) quantifies distortion geometrically. To motivate the algorithm, consider the distortion induced by mapping the sphere into latitude/longitude coordinates.
Parameterize points on \(\mathcal{M}\) using spherical coordinates:
\[\begin{align*} \mathbf{x}\left(p\right) = \left(\cos\varphi\cos\theta, \cos\varphi \sin\theta, \sin\varphi\right) \end{align*}\]
The associated (latitude, longitude) embedding is
\[\begin{align*} \mathbf{z}\left(p\right) = \left(\theta\left(p\right), \varphi\left(p\right)\right). \end{align*}\]
The gradients \(\nabla z^i\) of the embedding dimensions reflect distortion.
Since the level sets of \(z^\theta\) become more compressed near the poles, the gradients \(\nabla z^\theta\) become larger there.
This gradient information can be stored in the matrix \(H\) with elements,
\[\begin{align*} h^{ij} = \langle \nabla z^i, \nabla z^j \rangle_{g_{0}} \end{align*}\] where \(g_{0}\) is the metric on \(\mathcal{M}\) inherited from the ambient space.
In our example,
\[\begin{align*} H = \begin{pmatrix} 1/\cos^2\varphi & 0 \\ 0 & 1 \end{pmatrix} \end{align*}\]
For any \(f\) and \(g\), the Laplacian \(\Delta\) satisfies, \[\begin{align*} \Delta(fg) = f\,\Delta g + g\,\Delta f + 2\langle \nabla f, \nabla g \rangle_{g_{0}} \end{align*}\]
Setting \(f = z^i\), \(g = z^j\) and rearranging, \[\begin{align*} h^{ij} = \langle \nabla z^i, \nabla z^j \rangle_{g_0} = \frac{1}{2}\left[\Delta(z^i z^j) - z^i\Delta z^j - z^j\Delta z^i\right] \end{align*}\]
Since there are methods for estimating \(\Delta\) from data (Hein, Audibert, and Luxburg 2005; Coifman and Lafon 2006), we also have a practical method for approximating local distortions \(H\).
Let \(z_{k} \in \mathbb{R}^{N}\) be the \(k^{th}\) embedding dimension. Let \(L\) be the doubly-normalized graph Laplacian (Coifman and Lafon 2006). Compute
\[\begin{align*} H_{kk'}^{(\cdot)} := \frac{1}{2}\left[L\left(z_{k} \circ z_{k'}\right) - z_{k} \circ \left(L z_{k'}\right) - z_{k'} \circ \left(L z_{k}\right) \right] \in \mathbb{R}^{N} \end{align*}\]
The embedding distortion for sample \(n\) is given by \(H^{(n)} \in \mathbb{R}^{K \times K}\)
These two clusters are generated as:
\[\begin{align*} x_{i} \sim \frac{1}{2}\mathcal{N}\left(0, 10\right) + \frac{1}{2}\mathcal{N}\left(100, 1\right) \end{align*}\]
The UMAP embeddings lose information about the cluster density, but the difference is captured in the local metrics.
Since the metrics are known locally, the distortion can be inverted within a neighborhood of the cursor. For example, here we interactively adapt the embeddings in the Gaussian mixtures example.
Besides RMetric, we also visualize distortions using the scatterplot of true vs. embedding neighborhood distances.

To detect poorly preserved neighborhoods, we fit a running median to true vs. embedding distances, flag outliers above \(3\times \text{IQR}\), and mark points with many outlier links as “broken.”
This is the classic Swiss Roll data, but with higher density near the endpoints.
\(t\)-SNE (perplexity = 100) breaks the roll in the low-density region and artificially spreads the high density area.
This single-cell gene expression data set was used in the data visualization tutorial from the scanpy package (Wolf, Angerer, and Theis 2018). Each point is the UMAP embedding of a cell’s high-dimensional gene expression data.
Both variation in ellipses and fragmented neighborhood statistics can be used to compare competing algorithms, similarly to (Xia, Lee, and Li 2024; Venna and Kaski 2006).
This example uses data from a C. elegans cell differentiation study (Packer et al. 2019).
Both variation in ellipses and fragmented neighborhood statistics can be used to compare competing algorithms, similarly to (Xia, Lee, and Li 2024; Venna and Kaski 2006).
This example uses data from a C. elegans cell differentiation study (Packer et al. 2019).
Interactivity can reveal distortion information based on the analyst’s priorities.
Paper: https://go.wisc.edu/ptz5j5
Package: https://pypi.org/project/distortions
Sankaran, K., Zhang, S., Chenab, & Meilă, M. (2026). Interactive visualization of metric distortion in nonlinear data embeddings using the distortions package. Briefings in Bioinformatics, 27(2). doi:10.1093/bib/bbag136
The focus-plus-context principle (Heer and Card 2004) states that readers should be able to zoom into patterns of interest without losing relevant context.
Stacked barplots visualize sample-to-sample variation in microbiome community structure. They struggle to show finer taxonomic resolutions.
Figure from the microbiomeViz documentation (Barnett, Arts, and Penders 2021).
Stacked barplots visualize sample-to-sample variation in microbiome community structure. They struggle to show finer taxonomic resolutions.
Figure from the Qiime2 View documentation (Bolyen et al. 2019).
Applying focus-plus-context reveals rare taxa abundances while preserving overall structure
Figure from the phylobar documentation (Kuo et al. 2025).
This example comes from (“Understanding UMAP — Pair-Code.github.io”; Noichl). The 3D skeleton scans were produced by the Smithsonian, and we can use nonlinear dimensionality reduction to “flatten” the skeleton into 2D.
This is the embedding when applying UMAP with a 50 nearest-neighbor graph and min_dist = 0.5.
Parts of the shoulders, head, and tail are further apart in the embedding compared to the original data. Most other distortions are points that are placed too close to one another.
Parts of the shoulders, head, and tail are further apart in the embedding compared to the original data. Most other distortions are points that are placed too close to one another.
To compute \(L\), we use the estimator from (Coifman and Lafon 2006).
Build the kernel matrix \(W_{kl} = \exp(-\|X_k - X_l\|^2 / h)\), where \(h\) is a bandwidth hyperparameter.
Normalize both columns and rows. \[\begin{align*} D &= \text{diag}(W\mathbf{1}) \qquad \tilde{W} = D^{-1}WD^{-1} \\ \tilde{D} &= \text{diag}(\tilde{W}\mathbf{1}) \qquad L = \tilde{D}^{-1}\tilde{W} \end{align*}\] Column normalization accounts for differences in sampling density.
What does a small step in the embedding space correspond to in \(\mathcal{M}\)? The pushforward metric answers this,
\[\begin{align*} g_{ij} = \left\langle \frac{\partial\mathbf{x}}{\partial z^i}, \frac{\partial\mathbf{x}}{\partial z^j}\right\rangle_{\mathbb{R}^3} \end{align*}\]
This varies across \(p \in \mathcal{M}\) but we suppress it from the notation.
In the sphere example, these derivatives can be directly computed and to obtain,
\[\begin{align*} G = \begin{pmatrix} \cos^2\varphi & 0 \\ 0 & 1 \end{pmatrix} \end{align*}\] Near the equator (\(\varphi \approx 0\)), a small step in \(\theta\) covers more distance than near the north pole (\(\varphi \approx \frac{\pi}{2}\)).
First note that, \[\begin{align*} \frac{\partial\mathbf{x}}{\partial \theta} = \left(-\cos\varphi\sin\theta, \cos\varphi\cos\theta, 0\right). \end{align*}\] Therefore, \[\begin{align*} g_{11} &= \left\langle \frac{\partial\mathbf{x}}{\partial \theta}, \frac{\partial\mathbf{x}}{\partial \theta}\right\rangle_{\mathbb{R}^3} \\ &= \cos^2\varphi\sin^2\theta + \cos^2\varphi\cos^2\theta \\ &= \cos^2\varphi \end{align*}\]
By the product formula with \(z^1 = \theta\): \[\begin{align*} h^{11} = \langle \nabla \theta, \nabla \theta \rangle_{g_0} = \frac{1}{2}\left[\Delta(\theta^2) - 2\theta\Delta\theta\right] \end{align*}\]
The general formula for the Laplace-Beltrami operator is \[\Delta f = \frac{1}{\sqrt{\det G}}\sum_{i,j}\frac{\partial}{\partial z^i}\left(\sqrt{\det G}\, g^{ij}\frac{\partial f}{\partial z^j}\right).\]
Since \(\det(G) = \cos^2\varphi\) and the off-diagonal \(g^{ij}\) are zero, \[\begin{align*} \Delta f = \frac{1}{\cos^2\varphi}\frac{\partial^2 f}{\partial\theta^2} + \frac{1}{\cos\varphi}\frac{\partial}{\partial\varphi}\left(\cos\varphi\frac{\partial f}{\partial\varphi}\right) \end{align*}\]
We can plug in the choices of \(f\) that we care about, \[\begin{align*} \Delta\theta &= 0\\ \Delta(\theta^2) &= \frac{1}{\cos^2\varphi}\frac{\partial^2(\theta^2)}{\partial\theta^2} = \frac{2}{\cos^2\varphi} \end{align*}\]
and then substitute into the formula from 2 slides ago, \[\begin{align*} h^{11} = \frac{1}{2}\left[\frac{2}{\cos^2\varphi} - 2\theta \cdot 0\right] = \frac{1}{\cos^2\varphi}. \end{align*}\]
There are two classic challenges in interactive interfaces (Hutchins, Hollan, and Norman 1985),
These challenges also apply to interactive data analysis.
There are two classic challenges in interactive interfaces (Hutchins, Hollan, and Norman 1985),
These challenges also apply to interactive data analysis.
Nonlinear dimensionality reduction has become the source of widespread concern in the single-cell literature (Chari and Pachter 2023).
Alternatively, the gradients \(\nabla z^i\) of the embedding dimensions also reflect distortion.
In contrast, the gradients \(\nabla z^{\varphi}\) don’t depend on \(\varphi\).
The stability-based algorithm (Liu, Ma, and Zhong 2025) gives a similar interpretation. But the visual encoding is more subtle, and the leave-one-out approach is time consuming even with approximations.
They can make high-dimensional random walks look artificially smooth…
Example from (Wattenberg, Viégas, and Johnson 2016).
In this hydra cell differentiation dataset (Siebert et al. 2019; Xia, Lee, and Li 2024), \(t\)-SNE (perplexity = 80) collapses points along the dataset periphery and exaggerates between-cluster distances

At perplexity = 500, the clusters are more reliable, but peripheral samples are in fact closer than they appear

The local isometry visualization highlights some “threads” are more spread in the original data.
