Fast LOcal Tangent Space Alignment Method
An implementation of the Local Tangent Space Alignment method (Zhang & Zha, 2004), a spectral method for dimensionality reduction. It is one of the few methods that can unroll the “swiss roll” data set and its variants without major distortion. I consider this implementation “Fast” because of its use of approximate nearest neighbors. Internally it works with sparse matrices and does not require calculating all eigenvectors, so can scale to large datasets.
Installation
# install.packages("pak")
pak::pak("jlmelville/flotsam")Input and neighborhoods
ltsa() accepts a numeric matrix or a data frame; non-numeric data-frame columns are ignored. The size of the k-nearest neighbor graph that determines neighborhood size is controlled by n_neighbors and must be at least ndim + 2. By default, approximate nearest neighbor search is carried out, which has a stochastic component, so for reproducibility use set.seed and set n_threads = 1 or use nn_method = "exact" although this may only be feasible for smaller datasets (in terms of number of observations or features).
To reuse a neighbor graph, pass an index matrix or a sparse adjacency matrix to nn_method. Sparse graphs must have the same number of neighbors in every row.
Example
library(flotsam)
# Create a "swiss roll": 2D rectangle rolled up in 3D
n <- 1000
max_z <- 10
# phi represents the position along the roll
phi <- stats::runif(n, min = 1.5 * pi, max = 4.5 * pi)
x <- phi * cos(phi)
y <- phi * sin(phi)
z <- stats::runif(n, max = max_z)
swiss_roll <- data.frame(x, y, z)
# See side section to prove it's rolled
plot(swiss_roll$x, swiss_roll$y, col = phi)
# unroll it
swiss_unrolled <- ltsa(swiss_roll, verbose = TRUE)
plot(swiss_unrolled, col = phi)


Current Status
September 28 2026 Version 0.0.0.9003 adds support for sparse adjacency matrices as neighbor graphs.
See Also
- Rdimtools also contains an R implementation of LTSA.
- Eigenanalysis is carried out with either RSpectra or irlba.
- Approximate nearest neighbor analysis via rnndescent.
Further Reading
A fairly arbitrary selection of papers that contained at least one thing I found interesting while writing this package.
Zhang, Z., & Zha, H. (2004). Principal manifolds and nonlinear dimensionality reduction via tangent space alignment. SIAM journal on scientific computing, 26(1), 313-338. https://doi.org/10.1137/S1064827502419154
Xiang, S., Nie, F., Pan, C., & Zhang, C. (2011). Regression reformulations of LLE and LTSA with locally linear transformation. IEEE Transactions on Systems, Man, and Cybernetics, Part B (Cybernetics), 41(5), 1250-1262. https://doi.org/10.1109/TSMCB.2011.2123886
Sun, W., Halevy, A., Benedetto, J. J., Czaja, W., Li, W., Liu, C., … & Wang, R. (2013). Nonlinear dimensionality reduction via the ENH-LTSA method for hyperspectral image classification. IEEE Journal of Selected Topics in Applied Earth Observations and Remote Sensing, 7(2), 375-388. https://doi.org/10.1109/JSTARS.2013.2238890
Hong, D., Yokoya, N., & Zhu, X. X. (2017). Learning a robust local manifold representation for hyperspectral dimensionality reduction. IEEE Journal of Selected Topics in Applied Earth Observations and Remote Sensing, 10(6), 2960-2975. https://doi.org/10.1109/JSTARS.2017.2682189
Zhang, S., Ma, Z., & Tan, H. (2017). On the Equivalence of HLLE and LTSA. IEEE transactions on cybernetics, 48(2), 742-753. https://doi.org/10.1109/TCYB.2017.2655338