| Title: | Package for 2D embeddings |
|---|---|
| Description: | Contains different methods to generate embeddings like UMAP, tSNE, PHATE, PacMap and diffusion maps. Morever, has methods to generate nearest neighbour graphs and now also some clustering algorithms that are based on embedding methods (EVoC) and more general clustering methods like k-means. |
| Authors: | Gregor Lueg [aut, cre], Grant Neilson [aut] |
| Maintainer: | Gregor Lueg <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.3.8 |
| Built: | 2026-10-07 06:24:42 UTC |
| Source: | https://github.com/GregorLueg/manifoldsR |
Get the cluster membership at the best persistence score
best_membership(x) ## S3 method for class 'Evoc' best_membership(x)best_membership(x) ## S3 method for class 'Evoc' best_membership(x)
x |
An |
A named list with elements labels (integer vector of cluster
assignments, -1 for noise), membership (numeric vector of strengths),
layer (which layer index was selected), and persistence (the score).
Calculates the adjusted Rand index between two sets of cluster assignments.
calc_ari(members_a, members_b)calc_ari(members_a, members_b)
members_a |
Integer vector. Membership/assignment of the first clustering algorithm. |
members_b |
Integer vector. Membership/assignment of the second clustering algorithm. |
Adjusted Rand index
Calculate the cluster inertia
calc_inertia(x, data) ## S3 method for class 'KMeansCluster' calc_inertia(x, data)calc_inertia(x, data) ## S3 method for class 'KMeansCluster' calc_inertia(x, data)
x |
|
data |
Numerical matrix. The original data used to generate the k-means clusters. Shape of samples x features |
The cluster inertia
If the membership has only one group, the function will return NaN for
mean_silhouette and silhouette_scores.
calc_silhouette_score(data, membership)calc_silhouette_score(data, membership)
data |
Numerical matrix. Samples x features. The matrix that was used to generate the clustering. |
membership |
Integer vector. Membership/assignment of the clustering algorithm. |
A list with the following items:
mean_silhouette - The average Silhouette scores across all the data points.
silhouette_scores - The individual Silhouette scores of all the data points.
Performs densMAP dimensionality reduction on the input data. densMAP is UMAP with an added density-preserving term, so a tight cluster stays tight and a diffuse one stays diffuse. Plain UMAP gives you no such guarantee: relative sizes in the embedding mean nothing. This function provides a user-friendly interface with input validation before calling the Rust implementation.
densmap( data, knn = NULL, n_dim = 2L, k = 15L, min_dist = 0.5, spread = 1, knn_method = c("kmknn", "balltree", "hnsw", "annoy", "nndescent", "exhaustive", "ivf"), nn_params = params_nn(), umap_params = params_umap(), dens_params = params_densmap(), seed = 42L, use_high_precision = NULL, .verbose = TRUE )densmap( data, knn = NULL, n_dim = 2L, k = 15L, min_dist = 0.5, spread = 1, knn_method = c("kmknn", "balltree", "hnsw", "annoy", "nndescent", "exhaustive", "ivf"), nn_params = params_nn(), umap_params = params_umap(), dens_params = params_densmap(), seed = 42L, use_high_precision = NULL, .verbose = TRUE )
data |
Numerical matrix or data frame. The data to embed of shape samples x features. Will be coerced to a matrix. |
knn |
Optional |
n_dim |
Integer. Number of dimensions in the embedding space.
Defaults to |
k |
Integer. Number of nearest neighbours to consider for manifold
approximation. Larger values result in more global structure being
preserved. Defaults to |
min_dist |
Numeric. Minimum distance between points in the embedding.
Controls how tightly points are packed. Smaller values result in more
clustered embeddings. Must be >= 0. Defaults to |
spread |
Numeric. Effective scale of embedded points. Determines the
scale at which embedded points will be spread out. Defaults to |
knn_method |
Character. (Approximate) Nearest neighbour method to use.
One of |
nn_params |
Named list. Nearest neighbour search parameters, see
|
umap_params |
Named list. UMAP algorithm parameters, see
|
dens_params |
Named list. Density-preservation parameters, see
|
seed |
Integer. Random seed for reproducibility. Defaults to |
use_high_precision |
Optional boolean. Gives fine-grained control over
|
.verbose |
Logical. Controls verbosity. Defaults to |
Setting lambda to 0 in params_densmap() recovers plain
umap() exactly. The density term is only active over the final frac of
the epochs, which is why it costs comparatively little.
A numerical matrix with dimensions samples x n_dim containing the densMAP embedding.
Narayan, Berger & Cho, Nat. Biotechnol., 2021
Performs den-SNE dimensionality reduction on the input data. den-SNE is t-SNE with an added density-preserving term, so a tight cluster stays tight and a diffuse one stays diffuse. Plain t-SNE gives you no such guarantee: relative sizes in the embedding mean nothing. This function provides a user-friendly interface with input validation before calling the Rust implementation.
densne( data, knn = NULL, n_dim = 2L, perplexity = 20, approx_type = c("bh", "bh_qd", "fft", "fft_3k"), knn_method = c("kmknn", "balltree", "hnsw", "annoy", "nndescent", "exhaustive", "ivf"), nn_params = params_nn(), tsne_params = params_tsne(), dens_params = params_densne(), seed = 42L, use_high_precision = NULL, .verbose = TRUE )densne( data, knn = NULL, n_dim = 2L, perplexity = 20, approx_type = c("bh", "bh_qd", "fft", "fft_3k"), knn_method = c("kmknn", "balltree", "hnsw", "annoy", "nndescent", "exhaustive", "ivf"), nn_params = params_nn(), tsne_params = params_tsne(), dens_params = params_densne(), seed = 42L, use_high_precision = NULL, .verbose = TRUE )
data |
Numerical matrix or data frame. The data to embed of shape samples x features. Will be coerced to a matrix. |
knn |
Optional |
n_dim |
Integer. Number of dimensions in the embedding space.
Currently only |
perplexity |
Numeric. Perplexity parameter, related to the number of
nearest neighbours used in manifold learning. Typical values are between
5 and 50. Defaults to |
approx_type |
Character. Approximation method for computing repulsive
forces. One of |
knn_method |
Character. (Approximate) Nearest neighbour method to use.
One of |
nn_params |
Named list. Nearest neighbour search parameters, see
|
tsne_params |
Named list. t-SNE algorithm parameters, see
|
dens_params |
Named list. Density-preservation parameters, see
|
seed |
Integer. Random seed for reproducibility. |
use_high_precision |
Optional boolean. Gives fine-grained control over
|
.verbose |
Logical. Controls verbosity. Defaults to |
The number of neighbours will be 3 * perplexity, as this is a
usual default in tSNE. Setting lambda to 0 in params_densne() recovers
plain tsne() exactly. The default lambda is twenty times smaller than the
densMAP one, matching the reference implementations.
A numerical matrix with dimensions samples x n_dim containing the den-SNE embedding.
Narayan, Berger & Cho, Nat. Biotechnol., 2021
Performs diffusion maps dimensionality reduction on the input data. This function provides a user-friendly interface with input validation before calling the Rust implementation.
diffusion_maps( data, knn = NULL, n_dim = 2L, k = 5L, knn_method = c("kmknn", "balltree", "hnsw", "annoy", "nndescent", "exhaustive", "ivf"), nn_params = params_nn(), dm_params = params_diffusion_maps(), seed = 42L, use_high_precision = NULL, .verbose = TRUE )diffusion_maps( data, knn = NULL, n_dim = 2L, k = 5L, knn_method = c("kmknn", "balltree", "hnsw", "annoy", "nndescent", "exhaustive", "ivf"), nn_params = params_nn(), dm_params = params_diffusion_maps(), seed = 42L, use_high_precision = NULL, .verbose = TRUE )
data |
Numerical matrix or data frame. The data to embed of shape samples x features. Will be coerced to a matrix. |
knn |
Optional |
n_dim |
Integer. Number of dimensions in the embedding space.
Defaults to |
k |
Integer. Number of nearest neighbours to consider for the
affinity graph. Defaults to |
knn_method |
Character. (Approximate) Nearest neighbour method to use.
One of |
nn_params |
Named list. Nearest neighbour search parameters, see
|
dm_params |
Named list. Diffusion maps algorithm parameters, see
|
seed |
Integer. Random seed for reproducibility. Defaults to |
use_high_precision |
Optional boolean. Gives fine-grained control over
|
.verbose |
Logical. Controls verbosity. Defaults to |
A numerical matrix with dimensions samples x n_dim containing the diffusion maps embedding.
Performs EVoC (Embedding Vector Oriented Clustering) on the input data. Combines a UMAP-like node embedding with HDBSCAN-style density-based clustering and multi-layer persistence analysis.
evoc( data, knn = NULL, n_neighbours = 15L, knn_method = c("kmknn", "hnsw", "annoy", "nndescent", "balltree", "ivf", "exhaustive"), nn_params = params_nn(), evoc_params = params_evoc(), return_knn = FALSE, seed = 42L, use_high_precision = NULL, .verbose = TRUE )evoc( data, knn = NULL, n_neighbours = 15L, knn_method = c("kmknn", "hnsw", "annoy", "nndescent", "balltree", "ivf", "exhaustive"), nn_params = params_nn(), evoc_params = params_evoc(), return_knn = FALSE, seed = 42L, use_high_precision = NULL, .verbose = TRUE )
data |
Numerical matrix or data frame. The data to cluster, of shape samples x features. Will be coerced to a matrix. |
knn |
Optional |
n_neighbours |
Integer. Number of nearest neighbours for graph
construction. Defaults to |
knn_method |
Character. (Approximate) Nearest neighbour method to use.
One of |
nn_params |
Named list. Nearest neighbour search parameters, see
|
evoc_params |
Named list. EVoC algorithm parameters, see
|
return_knn |
Logical. Whether to return the kNN graph. If |
seed |
Integer. Random seed for reproducibility. Defaults to |
use_high_precision |
Optional boolean. Gives fine-grained control over
|
.verbose |
Logical. Controls verbosity. Defaults to |
An Evoc S3 object (see print.Evoc, best_membership,
get_layer).
Lays out the kNN graph of the data with ForceAtlas2, the way
scanpy's draw_graph does: the kNN graph is turned into the UMAP fuzzy
union graph and every edge pulls, every node pair pushes (1/d, with masses
1 + degree), plus gravity towards the origin. Repulsion runs on a
Barnes-Hut tree. Already have a graph? Use forceatlas2_from_graph().
forceatlas2( data, knn = NULL, k = 15L, knn_method = c("kmknn", "balltree", "hnsw", "annoy", "nndescent", "exhaustive", "ivf"), nn_params = params_nn(), fa2_params = params_fa2(), seed = 42L, use_high_precision = NULL, .verbose = TRUE )forceatlas2( data, knn = NULL, k = 15L, knn_method = c("kmknn", "balltree", "hnsw", "annoy", "nndescent", "exhaustive", "ivf"), nn_params = params_nn(), fa2_params = params_fa2(), seed = 42L, use_high_precision = NULL, .verbose = TRUE )
data |
Numerical matrix or data frame. The data to embed of shape samples x features. Will be coerced to a matrix. |
knn |
Optional |
k |
Integer. Number of nearest neighbours. Defaults to |
knn_method |
Character. (Approximate) Nearest neighbour method to use.
One of |
nn_params |
Named list. Nearest neighbour search parameters, see
|
fa2_params |
Named list. ForceAtlas2 parameters, see |
seed |
Integer. Random seed for reproducibility. Defaults to |
use_high_precision |
Optional boolean. Gives fine-grained control over
|
.verbose |
Logical. Controls verbosity. Defaults to |
A numerical matrix with dimensions samples x 2 containing the ForceAtlas2 layout.
Jacomy, et al., PLoS ONE, 2014
Lays out any undirected graph with ForceAtlas2, for example an
SNN graph or a graph from another package. Edge weights come from the
weight edge attribute; without one, every edge weighs 1. Self-loops are
dropped. Only the optimisation parameters in fa2_params are used; the
graph and initialisation ones do not apply here.
forceatlas2_from_graph( graph, init = NULL, fa2_params = params_fa2(), seed = 42L, use_high_precision = NULL, .verbose = TRUE )forceatlas2_from_graph( graph, init = NULL, fa2_params = params_fa2(), seed = 42L, use_high_precision = NULL, .verbose = TRUE )
graph |
An undirected |
init |
Optional numerical matrix of dimensions |
fa2_params |
Named list. ForceAtlas2 parameters, see |
seed |
Integer. Random seed for reproducibility. Defaults to |
use_high_precision |
Optional boolean. Gives fine-grained control over
|
.verbose |
Logical. Controls verbosity. Defaults to |
A numerical matrix with dimensions vcount(graph) x 2 containing
the ForceAtlas2 layout, rows in vertex order.
Jacomy, et al., PLoS ONE, 2014
This function generates a kNN graph based on a given numeric matrix. Seven different algorithms are implemented with different speed and accuracy trade-offs:
"hnsw" - Hierarchical Navigable Small Worlds vector search with
slower index generation (which ammortises on larger data sets) and high
precision.
"annoy" - Approximate Nearest Neighbours Oh Yeah algorithm, faster
to index but querying on large data sets can be slow.
"nndescent" - Rust-based implementation of the PyNNDescent
algorithm, a good all-rounder that performs well on very large data sets.
"balltree" - Ball tree structure for exact search with a
configurable budget.
"ivf" - Inverted file index that leverages k-means clustering
and probing a few of the clusters.
"exhaustive" - Exact nearest neighbour search.
"kmknn" - Fast exact nearest neighbour search using triangle
inequality
generate_knn_graph( data, k, knn_method = c("kmknn", "hnsw", "annoy", "nndescent", "balltree", "ivf", "exhaustive"), nn_params = params_nn(), seed = 42L, .verbose = TRUE )generate_knn_graph( data, k, knn_method = c("kmknn", "hnsw", "annoy", "nndescent", "balltree", "ivf", "exhaustive"), nn_params = params_nn(), seed = 42L, .verbose = TRUE )
data |
Numeric matrix. The embedding or feature matrix to compute neighbours on. Rows are observations, columns are features. |
k |
Integer. The number of nearest neighbours to compute. |
knn_method |
Character. The algorithm to use for nearest neighbour
search. One of
|
nn_params |
List. Output of |
seed |
Integer. For reproducibility. Defaults to |
.verbose |
Boolean. Controls verbosity. |
A nearest neighbours class object with 1-indexed neighbour indices
and distances. Distances are on the scale of the metric they are named
after, so dist_metric = "euclidean" returns Euclidean distance, not the
squared Euclidean the backends sort on internally.
Get cluster centroids
get_centroids(x) ## S3 method for class 'KMeansCluster' get_centroids(x)get_centroids(x) ## S3 method for class 'KMeansCluster' get_centroids(x)
x |
A |
Numeric matrix of shape k x features.
Get the distances as a flat vector
get_dist_flat(x) ## S3 method for class 'NearestNeighbours' get_dist_flat(x)get_dist_flat(x) ## S3 method for class 'NearestNeighbours' get_dist_flat(x)
x |
|
The distances in a flat format like
c(dist1.1, dist1.2, ... , dist2.1, dist2.2, ... dist3.1, dist3.2)
Get the indices as a matrix
get_dist_mat(x) ## S3 method for class 'NearestNeighbours' get_dist_mat(x)get_dist_mat(x) ## S3 method for class 'NearestNeighbours' get_dist_mat(x)
x |
|
The indices in samples x neighbours format
Get the indices as a flat vector
get_idx_flat(x) ## S3 method for class 'NearestNeighbours' get_idx_flat(x)get_idx_flat(x) ## S3 method for class 'NearestNeighbours' get_idx_flat(x)
x |
|
The indices in a flat format like
c(idx1.1, idx1.2, ... , idx.2.1, idx2.2, ... idx3.1, idx3.2)
Get the indices as a matrix
get_idx_mat(x) ## S3 method for class 'NearestNeighbours' get_idx_mat(x)get_idx_mat(x) ## S3 method for class 'NearestNeighbours' get_idx_mat(x)
x |
|
The indices in samples x neighbours format
Get a specific EVoC layer
get_layer(x, i) ## S3 method for class 'Evoc' get_layer(x, i)get_layer(x, i) ## S3 method for class 'Evoc' get_layer(x, i)
x |
An |
i |
Integer. Layer index to retrieve. |
A named list with labels, membership, and persistence for
the requested layer.
Get the kNN graph from an Evoc object
get_nearest_neighbours(x) ## S3 method for class 'Evoc' get_nearest_neighbours(x)get_nearest_neighbours(x) ## S3 method for class 'Evoc' get_nearest_neighbours(x)
x |
An |
A NearestNeighbours object, or NULL if the kNN was not stored.
Performs k-means clustering on the input data. Supports both full Lloyd's iterations (with SIMD/GEMM acceleration) and mini-batch k-means for large data sets.
kmeans_cluster( data, k, method = c("full", "minibatch"), kmeans_params = params_kmeans(), seed = 42L, .verbose = TRUE )kmeans_cluster( data, k, method = c("full", "minibatch"), kmeans_params = params_kmeans(), seed = 42L, .verbose = TRUE )
data |
Numerical matrix or data frame. The data to cluster, of shape samples x features. Will be coerced to a matrix. |
k |
Integer. Number of clusters to create. Must be >= 2. |
method |
Character. Clustering method. One of |
kmeans_params |
Named list. K-means parameters, see |
seed |
Integer. Random seed for reproducibility. Defaults to |
.verbose |
Logical. Controls verbosity. Defaults to |
A named list with:
Numeric matrix of shape k x features containing the final cluster centroids.
Integer vector of length samples with cluster assignments (1-indexed).
A unified wrapper function for generating various types of synthetic data to test manifold learning techniques and demonstrate differences.
manifold_synthetic_data( type = c("swiss_role", "biased_swiss_role", "clusters", "trajectory", "hierarchical"), n_samples, dim = 32L, seed = 42L, parameters = NULL )manifold_synthetic_data( type = c("swiss_role", "biased_swiss_role", "clusters", "trajectory", "hierarchical"), n_samples, dim = 32L, seed = 42L, parameters = NULL )
type |
Character. Type of synthetic data to generate. One of:
|
n_samples |
Integer. Number of data points to generate. |
dim |
Integer. Dimensionality of the ambient space. Used for all types
except |
seed |
Integer. Seed for reproducibility. Defaults to |
parameters |
A named list of type-specific parameters, constructed via
|
A list with the following elements:
data - Numeric matrix of shape n_samples x dim
membership - Integer vector of cluster/branch assignments (NULL
for "swiss_role")
Get cluster assignments
membership(x) ## S3 method for class 'KMeansCluster' membership(x)membership(x) ## S3 method for class 'KMeansCluster' membership(x)
x |
A |
Integer vector of length samples with cluster assignments (1-indexed).
Generate a new NearestNeighbours
new_nearest_neighbour(indices, dist, k, n) generate_nearest_neigbours_class(indices, dist, k, n)new_nearest_neighbour(indices, dist, k, n) generate_nearest_neigbours_class(indices, dist, k, n)
indices |
Integer. Nearest neigbours in flat storage format. Need to be sorted! |
dist |
Numeric. Nearest neighbour distances in flat storarge format. Need to be sorted! On the scale of the metric they were generated with, i.e. Euclidean rather than squared Euclidean. |
k |
Integer. Number of k-neighbours per sample. |
n |
Integer. Number of samples. |
Initialised NearestNeighbours class.
Performs PaCMAP dimensionality reduction on the input data. This function provides a user-friendly interface with input validation before calling the Rust implementation.
pacmap( data, knn = NULL, n_dim = 2L, knn_method = c("kmknn", "balltree", "hnsw", "annoy", "nndescent", "exhaustive", "ivf"), nn_params = params_nn(), pacmap_params = params_pacmap(), seed = 42L, use_high_precision = NULL, .verbose = TRUE )pacmap( data, knn = NULL, n_dim = 2L, knn_method = c("kmknn", "balltree", "hnsw", "annoy", "nndescent", "exhaustive", "ivf"), nn_params = params_nn(), pacmap_params = params_pacmap(), seed = 42L, use_high_precision = NULL, .verbose = TRUE )
data |
Numerical matrix or data frame. The data to embed of shape samples x features. Will be coerced to a matrix. |
knn |
Optional |
n_dim |
Integer. Number of dimensions in the embedding space.
Defaults to |
knn_method |
Character. (Approximate) Nearest neighbour method to use.
One of |
nn_params |
Named list. Nearest neighbour search parameters, see
|
pacmap_params |
Named list. PaCMAP algorithm parameters, see
|
seed |
Integer. Random seed for reproducibility. Defaults to |
use_high_precision |
Optional boolean. Gives fine-grained control over
|
.verbose |
Logical. Controls verbosity. Defaults to |
A numerical matrix with dimensions samples x n_dim containing the PaCMAP embedding.
For use with manifold_synthetic_data().
params_clusters(n_clusters = 15L)params_clusters(n_clusters = 15L)
n_clusters |
Integer. Number of clusters to generate. Defaults to |
A named list with the following elements:
n_clusters - Integer. Number of clusters to generate. Defaults to
15L.
The density-preservation knobs on top of the usual UMAP
parameters. densMAP adds -lambda * Corr(log Ro, log Re) to the UMAP loss,
where Ro is the local radius in the input space and Re the matching
radius in the embedding. Setting lambda to 0 recovers plain UMAP.
params_densmap(lambda = 2, frac = 0.3, var_shift = 0.1)params_densmap(lambda = 2, frac = 0.3, var_shift = 0.1)
lambda |
Numeric. Weight of the density term. |
frac |
Numeric. Fraction of the total epochs, at the end of the run,
over which the density term is active. Defaults to |
var_shift |
Numeric. Additive shift on the variance of the embedding
log-radii. Defaults to |
A named list with the following elements:
lambda - Numeric. Weight of the density term. 0 disables it. The
default is the densMAP reference value. Defaults to 2.0.
frac - Numeric. Fraction of the total epochs, at the end of the run,
over which the density term is active. Defaults to 0.3.
var_shift - Numeric. Additive shift on the variance of the embedding
log-radii. Defaults to 0.1.
Narayan, Berger & Cho, Nat. Biotechnol., 2021
The density-preservation knobs on top of the usual t-SNE
parameters. den-SNE adds -lambda * Corr(log Ro, log Re) to the t-SNE loss,
where Ro is the local radius in the input space and Re the matching
radius in the embedding. Setting lambda to 0 recovers plain t-SNE.
params_densne(lambda = 0.5, frac = 0.3, var_shift = 0.1)params_densne(lambda = 0.5, frac = 0.3, var_shift = 0.1)
lambda |
Numeric. Weight of the density term. |
frac |
Numeric. Fraction of the total epochs, at the end of the run,
over which the density term is active. Defaults to |
var_shift |
Numeric. Additive shift on the variance of the embedding
log-radii. Defaults to |
A named list with the following elements:
lambda - Numeric. Weight of the density term. 0 disables it. The
default is higher than the den-SNE reference value (original: 0.1).
Defaults to 0.5.
frac - Numeric. Fraction of the total epochs, at the end of the run,
over which the density term is active. Defaults to 0.3.
var_shift - Numeric. Additive shift on the variance of the embedding
log-radii. Defaults to 0.1.
Narayan, Berger & Cho, Nat. Biotechnol., 2021
Wrapper function to generate diffusion maps parameters
params_diffusion_maps( bandwidth_scale = 1, thresh = 1e-04, graph_symmetry = c("additive", "multiplicative", "mnn", "none"), alpha_norm = 1, t_max = 100L, t_custom = NULL, n_landmarks = 2048L, landmark_method = c("spectral", "random", "density"), n_svd = NULL )params_diffusion_maps( bandwidth_scale = 1, thresh = 1e-04, graph_symmetry = c("additive", "multiplicative", "mnn", "none"), alpha_norm = 1, t_max = 100L, t_custom = NULL, n_landmarks = 2048L, landmark_method = c("spectral", "random", "density"), n_svd = NULL )
bandwidth_scale |
Numeric. Multiplicative factor applied to the adaptive
kernel bandwidth. Defaults to |
thresh |
Numeric. Sparsity threshold applied to kernel entries. Defaults
to |
graph_symmetry |
String. Method used to symmetrise the affinity graph.
One of |
alpha_norm |
Numeric. Anisotropic density-correction exponent. |
t_max |
Integer. Maximum diffusion time considered during automatic
selection via Von Neumann entropy knee point detection. Defaults to |
t_custom |
Integer or |
n_landmarks |
Integer or |
landmark_method |
String. Method used to select landmarks. One of
|
n_svd |
Integer or |
A named list with the following elements:
bandwidth_scale - Numeric. Multiplicative factor applied to the
adaptive kernel bandwidth. Defaults to 1.0.
thresh - Numeric. Sparsity threshold applied to kernel entries.
Defaults to 1e-04.
graph_symmetry - String. Method used to symmetrise the affinity graph.
One of c("additive", "multiplicative", "mnn", "none"). Defaults to
"additive".
alpha_norm - Numeric. Anisotropic density-correction exponent. 0
gives the normalised graph Laplacian, 0.5 the Fokker-Planck operator, 1
the Laplace-Beltrami operator. Defaults to 1.0.
t_max - Integer. Maximum diffusion time considered during automatic
selection via Von Neumann entropy knee point detection. Defaults to 100L.
t_custom - Integer or NULL. Fixed diffusion time. If set, overrides
automatic time selection. Defaults to NULL.
n_landmarks - Integer or NULL. Number of landmarks for compressed
diffusion. If NULL, the full N x N diffusion operator is used. Defaults to
2048L.
landmark_method - String. Method used to select landmarks. One of
c("spectral", "random", "density"). Defaults to "spectral".
n_svd - Integer or NULL. Number of SVD components used in landmark
construction. If NULL, the library selects a sensible default. Defaults to
NULL.
Wrapper function to generate EVoC parameters
params_evoc( noise_level = 0.5, n_epochs = 50L, embedding_dim = NULL, neighbour_scale = 1, symmetrise = TRUE, min_samples = 5L, base_min_cluster_size = 5L, approx_n_clusters = NULL, min_similarity_threshold = 0.2, max_layers = 10L )params_evoc( noise_level = 0.5, n_epochs = 50L, embedding_dim = NULL, neighbour_scale = 1, symmetrise = TRUE, min_samples = 5L, base_min_cluster_size = 5L, approx_n_clusters = NULL, min_similarity_threshold = 0.2, max_layers = 10L )
noise_level |
Numeric. Noise level for the embedding gradient. |
n_epochs |
Integer. Number of embedding optimisation epochs. Defaults to
|
embedding_dim |
Integer or |
neighbour_scale |
Numeric. Multiplier on effective neighbours for fuzzy
graph construction. Defaults to |
symmetrise |
Boolean. Whether to symmetrise the fuzzy graph. Defaults to
|
min_samples |
Integer. Minimum samples for core distance in MST density
estimation. Defaults to |
base_min_cluster_size |
Integer. Base minimum cluster size for the
finest layer. Defaults to |
approx_n_clusters |
Integer or |
min_similarity_threshold |
Numeric. Jaccard similarity threshold for
filtering redundant layers. Defaults to |
max_layers |
Integer. Maximum number of cluster layers to return.
Defaults to |
A named list with the following elements:
noise_level - Numeric. Noise level for the embedding gradient. 0.0 =
aggressive, 1.0 = conservative. Defaults to 0.5.
n_epochs - Integer. Number of embedding optimisation epochs. Defaults
to 50L.
embedding_dim - Integer or NULL. Embedding dimensionality. If
NULL, uses min(max(n_neighbours / 4, 4), 16). Defaults to NULL.
neighbour_scale - Numeric. Multiplier on effective neighbours for
fuzzy graph construction. Defaults to 1.0.
symmetrise - Boolean. Whether to symmetrise the fuzzy graph. Defaults
to TRUE.
min_samples - Integer. Minimum samples for core distance in MST
density estimation. Defaults to 5L.
base_min_cluster_size - Integer. Base minimum cluster size for the
finest layer. Defaults to 5L.
approx_n_clusters - Integer or NULL. If set, binary-searches for
approximately this many clusters (single layer output). Defaults to NULL.
min_similarity_threshold - Numeric. Jaccard similarity threshold for
filtering redundant layers. Defaults to 0.2.
max_layers - Integer. Maximum number of cluster layers to return.
Defaults to 10L.
The graph, initialisation and optimisation knobs for
ForceAtlas2. local_connectivity, bandwidth, init and randomised only
apply when the graph is built from the data via forceatlas2();
forceatlas2_from_graph() ignores them.
params_fa2( local_connectivity = 1, bandwidth = 1e-05, n_epochs = 500L, scaling_ratio = 2, gravity = 1, strong_gravity = FALSE, lin_log = FALSE, dissuade_hubs = FALSE, edge_weight_influence = 1, jitter_tolerance = 1, theta = 1.2, init = c("spectral", "pca", "random"), randomised = FALSE )params_fa2( local_connectivity = 1, bandwidth = 1e-05, n_epochs = 500L, scaling_ratio = 2, gravity = 1, strong_gravity = FALSE, lin_log = FALSE, dissuade_hubs = FALSE, edge_weight_influence = 1, jitter_tolerance = 1, theta = 1.2, init = c("spectral", "pca", "random"), randomised = FALSE )
local_connectivity |
Numeric. Number of nearest neighbours assumed to be
at distance zero. Defaults to |
bandwidth |
Numeric. Convergence tolerance for smooth kNN distance
binary search. Defaults to |
n_epochs |
Integer. Number of optimisation epochs. Defaults to |
scaling_ratio |
Numeric. Repulsion strength. Larger values spread the
layout. Defaults to |
gravity |
Numeric. Pull towards the origin. Keeps disconnected
components from drifting off. Defaults to |
strong_gravity |
Boolean. Distance-independent gravity, scaled by
|
lin_log |
Boolean. Logarithmic attraction (LinLog). Gives tighter
communities. Defaults to |
dissuade_hubs |
Boolean. Divide the attraction by the node mass. Pushes
hubs to the periphery. Defaults to |
edge_weight_influence |
Numeric. Exponent applied to the edge weights.
|
jitter_tolerance |
Numeric. Tolerated swinging. Larger is faster but
less precise. Defaults to |
theta |
Numeric. Barnes-Hut opening parameter on Gephi's scale. |
init |
String. Embedding initialisation method. One of |
randomised |
Boolean. Use randomised SVD for PCA initialisation.
Defaults to |
A named list with the following elements:
local_connectivity - Numeric. Number of nearest neighbours assumed to
be at distance zero. Defaults to 1.0.
bandwidth - Numeric. Convergence tolerance for smooth kNN distance
binary search. Defaults to 1e-05.
n_epochs - Integer. Number of optimisation epochs. Defaults to 500L.
scaling_ratio - Numeric. Repulsion strength. Larger values spread the
layout. Defaults to 2.0.
gravity - Numeric. Pull towards the origin. Keeps disconnected
components from drifting off. Defaults to 1.0.
strong_gravity - Boolean. Distance-independent gravity, scaled by
scaling_ratio. Defaults to FALSE.
lin_log - Boolean. Logarithmic attraction (LinLog). Gives tighter
communities. Defaults to FALSE.
dissuade_hubs - Boolean. Divide the attraction by the node mass.
Pushes hubs to the periphery. Defaults to FALSE.
edge_weight_influence - Numeric. Exponent applied to the edge weights.
0 ignores the weights. Defaults to 1.0.
jitter_tolerance - Numeric. Tolerated swinging. Larger is faster but
less precise. Defaults to 1.0.
theta - Numeric. Barnes-Hut opening parameter on Gephi's scale. 0
gives the exact repulsion. Defaults to 1.2.
init - String. Embedding initialisation method. One of c("spectral", "pca", "random"). Defaults to "spectral".
randomised - Boolean. Use randomised SVD for PCA initialisation.
Defaults to FALSE.
Jacomy, et al., PLoS ONE, 2014
For use with manifold_synthetic_data().
params_hierarchical( n_supergroups = 3L, n_subclusts = 3L, supergroup_spread = 15, subcluster_spread = 2, point_std = 0.4 )params_hierarchical( n_supergroups = 3L, n_subclusts = 3L, supergroup_spread = 15, subcluster_spread = 2, point_std = 0.4 )
n_supergroups |
Integer. Number of top-level groups. Defaults to |
n_subclusts |
Integer. Number of subclusters per supergroup. Defaults to
|
supergroup_spread |
Numeric. Spread of supergroup centres in the ambient
space. Defaults to |
subcluster_spread |
Numeric. Spread of subcluster centres around their
supergroup centre. Defaults to |
point_std |
Numeric. Within-subcluster Gaussian noise. Defaults to
|
A named list with the following elements:
n_supergroups - Integer. Number of top-level groups. Defaults to 3L.
n_subclusts - Integer. Number of subclusters per supergroup. Defaults
to 3L.
supergroup_spread - Numeric. Spread of supergroup centres in the
ambient space. Defaults to 15.0.
subcluster_spread - Numeric. Spread of subcluster centres around their
supergroup centre. Defaults to 2.0.
point_std - Numeric. Within-subcluster Gaussian noise. Defaults to
0.4.
Wrapper function to generate k-means parameters
params_kmeans( metric = c("euclidean", "cosine"), max_iters = 1000L, batch_size = 4096L, drift_threshold = 1e-04, lr_alpha = 1, init = c("parallel", "random"), use_hamerly = NULL, use_gemm = NULL )params_kmeans( metric = c("euclidean", "cosine"), max_iters = 1000L, batch_size = 4096L, drift_threshold = 1e-04, lr_alpha = 1, init = c("parallel", "random"), use_hamerly = NULL, use_gemm = NULL )
metric |
String. Distance metric to use. One of |
max_iters |
Integer. Maximum number of iterations. Defaults to |
batch_size |
Integer. Mini-batch size. Only used when |
drift_threshold |
Numeric. Below which centroid drift the mini-batch
k-means is considered converged. Only used when |
lr_alpha |
Numeric. Learning rate decay for the mini-batch k-means.
Original paper uses |
init |
String. The initialisation of the centroids. One of
|
use_hamerly |
Boolean or |
use_gemm |
Boolean or |
A named list with the following elements:
metric - String. Distance metric to use. One of c("euclidean", "cosine"). Defaults to "euclidean".
max_iters - Integer. Maximum number of iterations. Defaults to
1000L.
batch_size - Integer. Mini-batch size. Only used when method = "minibatch". Defaults to 4096L.
drift_threshold - Numeric. Below which centroid drift the mini-batch
k-means is considered converged. Only used when method = "minibatch".
Defaults to 1e-04.
lr_alpha - Numeric. Learning rate decay for the mini-batch k-means.
Original paper uses 1.0. Defaults to 1.0.
init - String. The initialisation of the centroids. One of
c("parallel", "random"). Defaults to "parallel".
use_hamerly - Boolean or NULL. Shall Hamerly's method be used (only
if metric == "euclidean"). Defaults to NULL.
use_gemm - Boolean or NULL. Shall the GEMM path be used. Useful on
high dimensional data. If NULL, choice will be based on heuristics.
Defaults to NULL.
Wrapper function to generate nearest neighbour parameters
params_nn( dist_metric = c("euclidean", "cosine"), n_tree = 50L, search_budget = NULL, m = 16L, ef_construction = 100L, ef_search = 100L, diversify_prob = 0, delta = 0.001, ef_budget = NULL, extract_knn = TRUE, bt_budget = 0.1, n_list = NULL, n_probes = NULL )params_nn( dist_metric = c("euclidean", "cosine"), n_tree = 50L, search_budget = NULL, m = 16L, ef_construction = 100L, ef_search = 100L, diversify_prob = 0, delta = 0.001, ef_budget = NULL, extract_knn = TRUE, bt_budget = 0.1, n_list = NULL, n_probes = NULL )
dist_metric |
String. The distance metric to use. One of |
n_tree |
Integer. Number of trees for Annoy. Defaults to |
search_budget |
Integer or |
m |
Integer. Number of bidirectional links for HNSW. Defaults to |
ef_construction |
Integer. Size of the dynamic candidate list during
HNSW construction. Defaults to |
ef_search |
Integer. Size of the dynamic candidate list during HNSW
search. Defaults to |
diversify_prob |
Numeric. Diversification probability for NN descent.
Defaults to |
delta |
Numeric. Precision parameter for NN descent. Defaults to
|
ef_budget |
Integer or |
extract_knn |
Boolean. Only affects the |
bt_budget |
Numeric. Budget for ball tree search. Defaults to |
n_list |
Integer or |
n_probes |
Integer or |
A named list with the following elements:
dist_metric - String. The distance metric to use. One of
c("euclidean", "cosine"). Defaults to "euclidean".
n_tree - Integer. Number of trees for Annoy. Defaults to 50L.
search_budget - Integer or NULL. Search budget for Annoy. Defaults
to NULL.
m - Integer. Number of bidirectional links for HNSW. Defaults to
16L.
ef_construction - Integer. Size of the dynamic candidate list during
HNSW construction. Defaults to 100L.
ef_search - Integer. Size of the dynamic candidate list during HNSW
search. Defaults to 100L.
diversify_prob - Numeric. Diversification probability for NN descent.
Defaults to 0.0.
delta - Numeric. Precision parameter for NN descent. Defaults to
0.001.
ef_budget - Integer or NULL. Effort budget for NN descent. Ignored
when extract_knn is TRUE, as no search runs. Defaults to NULL.
extract_knn - Boolean. Only affects the "nndescent" backend. If
TRUE, the descent hands back the graph it just built instead of running a
beam search over it. Faster, at a recall of roughly 0.98 rather than
0.99-1.00. Defaults to TRUE.
bt_budget - Numeric. Budget for ball tree search. Defaults to 0.1.
n_list - Integer or NULL. Number of clusters to use for IVF. If
NULL, uses sqrt(n). Defaults to NULL.
n_probes - Integer or NULL. Number of clusters to probe for IVF. If
NULL, uses sqrt(n_list). Defaults to NULL.
Wrapper function to generate PaCMAP parameters
params_pacmap( n_near = 10L, n_mid_near = 5L, n_further = 20L, mn_candidate_start = 4L, mn_candidate_end = 50L, init = c("pca", "random"), optimiser = c("adam_parallel", "adam"), lr = 1, n_epochs = NULL, beta1 = 0.9, beta2 = 0.999, eps = 1e-07, phase1_end = NULL, phase2_end = NULL )params_pacmap( n_near = 10L, n_mid_near = 5L, n_further = 20L, mn_candidate_start = 4L, mn_candidate_end = 50L, init = c("pca", "random"), optimiser = c("adam_parallel", "adam"), lr = 1, n_epochs = NULL, beta1 = 0.9, beta2 = 0.999, eps = 1e-07, phase1_end = NULL, phase2_end = NULL )
n_near |
Integer. Near pairs per point (attractive). Defaults to |
n_mid_near |
Integer. Mid-near pairs per point. Defaults to |
n_further |
Integer. Further (random) pairs per point. Defaults to
|
mn_candidate_start |
Integer. Start index into kNN list for mid-near
candidate window. Defaults to |
mn_candidate_end |
Integer. End index into kNN list for mid-near
candidate window. Also determines the kNN search size. Defaults to |
init |
String. Embedding initialisation. One of |
optimiser |
String. The optimiser. One of |
lr |
Numeric. Adam learning rate. Defaults to |
n_epochs |
Integer or |
beta1 |
Numeric. Adam first moment decay. Defaults to |
beta2 |
Numeric. Adam second moment decay. Defaults to |
eps |
Numeric. Adam numerical stability constant. Defaults to |
phase1_end |
Integer or |
phase2_end |
Integer or |
A named list with the following elements:
n_near - Integer. Near pairs per point (attractive). Defaults to
10L.
n_mid_near - Integer. Mid-near pairs per point. Defaults to 5L.
n_further - Integer. Further (random) pairs per point. Defaults to
20L.
mn_candidate_start - Integer. Start index into kNN list for mid-near
candidate window. Defaults to 4L.
mn_candidate_end - Integer. End index into kNN list for mid-near
candidate window. Also determines the kNN search size. Defaults to 50L.
init - String. Embedding initialisation. One of c("pca", "random").
Defaults to "pca".
optimiser - String. The optimiser. One of c("adam_parallel", "adam"). Defaults to "adam_parallel".
lr - Numeric. Adam learning rate. Defaults to 1.0.
n_epochs - Integer or NULL. Total optimisation epochs. If NULL,
resolved downstream to 450. Defaults to NULL.
beta1 - Numeric. Adam first moment decay. Defaults to 0.9.
beta2 - Numeric. Adam second moment decay. Defaults to 0.999.
eps - Numeric. Adam numerical stability constant. Defaults to 1e-07.
phase1_end - Integer or NULL. Epoch at which phase 1 ends. If
NULL, resolved downstream to 100. Defaults to NULL.
phase2_end - Integer or NULL. Epoch at which phase 2 ends. If
NULL, resolved downstream to 200. Defaults to NULL.
Wrapper function to generate PHATE parameters
params_phate( decay = 40, bandwidth_scale = NULL, t_max = 100L, t_custom = NULL, gamma = 1, n_landmarks = 2048L, landmark_method = c("spectral", "random", "density"), n_svd = NULL, mds_method = c("sgd_dense", "classic"), graph_symmetry = c("additive", "multiplicative", "mnn", "none") )params_phate( decay = 40, bandwidth_scale = NULL, t_max = 100L, t_custom = NULL, gamma = 1, n_landmarks = 2048L, landmark_method = c("spectral", "random", "density"), n_svd = NULL, mds_method = c("sgd_dense", "classic"), graph_symmetry = c("additive", "multiplicative", "mnn", "none") )
decay |
Numeric. Alpha decay parameter controlling the kernel bandwidth.
Higher values create sharper transitions. Defaults to |
bandwidth_scale |
Numeric or |
t_max |
Integer. Maximum diffusion time considered during automatic
selection via Von Neumann entropy knee point detection. Defaults to |
t_custom |
Integer or |
gamma |
Numeric. Informational distance parameter for the diffusion
potential. Defaults to |
n_landmarks |
Integer or |
landmark_method |
String. Method used to select landmarks. One of
|
n_svd |
Integer or |
mds_method |
String. MDS algorithm used for the final embedding. One of
|
graph_symmetry |
String. Method used to symmetrise the affinity graph.
One of |
A named list with the following elements:
decay - Numeric. Alpha decay parameter controlling the kernel
bandwidth. Higher values create sharper transitions. Defaults to 40.0.
bandwidth_scale - Numeric or NULL. Scaling factor applied to the
kernel bandwidth. If NULL, the library selects a sensible default.
Defaults to NULL.
t_max - Integer. Maximum diffusion time considered during automatic
selection via Von Neumann entropy knee point detection. Defaults to 100L.
t_custom - Integer or NULL. Fixed diffusion time. If set, overrides
automatic time selection. Defaults to NULL.
gamma - Numeric. Informational distance parameter for the diffusion
potential. Defaults to 1.0.
n_landmarks - Integer or NULL. Number of landmarks for compressed
diffusion. If NULL, the full N x N diffusion operator is used. Defaults to
2048L.
landmark_method - String. Method used to select landmarks. One of
c("spectral", "random", "density"). Defaults to "spectral".
n_svd - Integer or NULL. Number of SVD components used in landmark
construction. If NULL, the library selects a sensible default. Defaults to
NULL.
mds_method - String. MDS algorithm used for the final embedding. One
of c("sgd_dense", "classic"). Defaults to "sgd_dense".
graph_symmetry - String. Method used to symmetrise the affinity graph.
One of c("additive", "multiplicative", "mnn", "none"). Defaults to
"additive".
For use with manifold_synthetic_data().
params_swiss_role(noise = 0.1)params_swiss_role(noise = 0.1)
noise |
Numeric. Amount of noise to add. Defaults to |
A named list with the following elements:
noise - Numeric. Amount of noise to add. Defaults to 0.1.
For use with manifold_synthetic_data().
params_swiss_role_biased(noise = 0.1, bias = 2.5)params_swiss_role_biased(noise = 0.1, bias = 2.5)
noise |
Numeric. Amount of noise to add. Defaults to |
bias |
Numeric. The sampling bias across the manifold. Defaults to
|
A named list with the following elements:
noise - Numeric. Amount of noise to add. Defaults to 0.1.
bias - Numeric. The sampling bias across the manifold. Defaults to
2.5.
For use with manifold_synthetic_data().
params_trajectory( topology = c("bifurcation", "linear", "combination"), cell_trajectories = NULL, noise = 0.1 )params_trajectory( topology = c("bifurcation", "linear", "combination"), cell_trajectories = NULL, noise = 0.1 )
topology |
String. Ignored if |
cell_trajectories |
Any. Optional named list with three equal-length
vectors: |
noise |
Numeric. Amount of noise to add. Defaults to |
A named list with the following elements:
topology - String. Ignored if cell_trajectories is not NULL. One
of c("bifurcation", "linear", "combination"). Defaults to "bifurcation".
cell_trajectories - Any. Optional named list with three equal-length
vectors: parent (integer, NA for root, zero-indexed), split_at
(numeric, fraction along parent where branch starts), and length (numeric,
length of the branch). If NULL, topology is used instead. Defaults to
NULL.
noise - Numeric. Amount of noise to add. Defaults to 0.1.
Wrapper function to generate t-SNE parameters
params_tsne( lr = NULL, n_epochs = 1000L, early_exag_iter = 250L, early_exag_factor = 12, late_exag_factor = NULL, theta = 0.5, n_interp_points = 3L, max_depth = 7L, init = c("pca", "spectral", "random"), randomised = TRUE )params_tsne( lr = NULL, n_epochs = 1000L, early_exag_iter = 250L, early_exag_factor = 12, late_exag_factor = NULL, theta = 0.5, n_interp_points = 3L, max_depth = 7L, init = c("pca", "spectral", "random"), randomised = TRUE )
lr |
Numeric or |
n_epochs |
Integer. Number of optimisation epochs. Defaults to |
early_exag_iter |
Integer. Number of early exaggeration iterations.
Defaults to |
early_exag_factor |
Numeric. Early exaggeration factor. Defaults to
|
late_exag_factor |
Numeric or |
theta |
Numeric. Barnes-Hut approximation angle. Lower values increase
accuracy at the cost of speed. Defaults to |
n_interp_points |
Integer. Number of interpolation points per grid cell
for FFT acceleration ( |
max_depth |
Integer. Maximum Barnes-Hut tree depth for the
quick-and-dirty optimiser ( |
init |
String. Embedding initialisation method. One of |
randomised |
Boolean. Use randomised SVD for PCA initialisation.
Defaults to |
A named list with the following elements:
lr - Numeric or NULL. Learning rate. If NULL, the Rust backend
sets it to max((n_samples / 12), 200), following the N-dependent heuristic
of Belkina et al. (2019). Defaults to NULL.
n_epochs - Integer. Number of optimisation epochs. Defaults to
1000L.
early_exag_iter - Integer. Number of early exaggeration iterations.
Defaults to 250L.
early_exag_factor - Numeric. Early exaggeration factor. Defaults to
12.0.
late_exag_factor - Numeric or NULL. Late exaggeration factor, if you
wish to use one. Can be useful on large data sets (set it to 2.0 to
4.0). Defaults to NULL.
theta - Numeric. Barnes-Hut approximation angle. Lower values increase
accuracy at the cost of speed. Defaults to 0.5.
n_interp_points - Integer. Number of interpolation points per grid
cell for FFT acceleration ("fft" and "fft_3k"). Defaults to 3L.
max_depth - Integer. Maximum Barnes-Hut tree depth for the
quick-and-dirty optimiser ("bh_qd"). Smaller is faster and coarser; qdtsne
recommends 7 to 10. No effect on the other optimisers. Defaults to 7L.
init - String. Embedding initialisation method. One of c("pca", "spectral", "random"). Defaults to "pca".
randomised - Boolean. Use randomised SVD for PCA initialisation.
Defaults to TRUE.
Belkina, et al., Nat. Commun., 2019
Wrapper function to generate UMAP parameters
params_umap( local_connectivity = 1, bandwidth = 1e-05, mix_weight = 1, lr = 1, n_epochs = NULL, neg_sample_rate = 5L, gamma = 1, optimiser = c("adam_parallel", "sgd", "adam"), init = c("spectral", "pca", "random"), randomised = TRUE )params_umap( local_connectivity = 1, bandwidth = 1e-05, mix_weight = 1, lr = 1, n_epochs = NULL, neg_sample_rate = 5L, gamma = 1, optimiser = c("adam_parallel", "sgd", "adam"), init = c("spectral", "pca", "random"), randomised = TRUE )
local_connectivity |
Numeric. Number of nearest neighbours assumed to be
at distance zero. Defaults to |
bandwidth |
Numeric. Convergence tolerance for smooth kNN distance
binary search. Defaults to |
mix_weight |
Numeric. Balance between fuzzy union and directed graph
during symmetrisation. Defaults to |
lr |
Numeric. Learning rate. Defaults to |
n_epochs |
Integer or |
neg_sample_rate |
Integer. Number of negative samples per positive
sample. Defaults to |
gamma |
Numeric. Repulsion strength. Defaults to |
optimiser |
String. The optimiser. One of |
init |
String. Embedding initialisation method. One of |
randomised |
Boolean. Use randomised SVD for PCA initialisation.
Defaults to |
A named list with the following elements:
local_connectivity - Numeric. Number of nearest neighbours assumed to
be at distance zero. Defaults to 1.0.
bandwidth - Numeric. Convergence tolerance for smooth kNN distance
binary search. Defaults to 1e-05.
mix_weight - Numeric. Balance between fuzzy union and directed graph
during symmetrisation. Defaults to 1.0.
lr - Numeric. Learning rate. Defaults to 1.0.
n_epochs - Integer or NULL. Number of optimisation epochs. If
NULL, resolved downstream based on data size. Defaults to NULL.
neg_sample_rate - Integer. Number of negative samples per positive
sample. Defaults to 5L.
gamma - Numeric. Repulsion strength. Defaults to 1.0.
optimiser - String. The optimiser. One of c("adam_parallel", "sgd", "adam"). Defaults to "adam_parallel".
init - String. Embedding initialisation method. One of c("spectral", "pca", "random"). Defaults to "spectral".
randomised - Boolean. Use randomised SVD for PCA initialisation.
Defaults to TRUE.
Performs PHATE dimensionality reduction on the input data. This function provides a user-friendly interface with input validation before calling the Rust implementation.
phate( data, knn = NULL, n_dim = 2L, k = 5L, knn_method = c("kmknn", "balltree", "hnsw", "annoy", "nndescent", "exhaustive", "ivf"), nn_params = params_nn(), phate_params = params_phate(), seed = 42L, use_high_precision = NULL, .verbose = TRUE )phate( data, knn = NULL, n_dim = 2L, k = 5L, knn_method = c("kmknn", "balltree", "hnsw", "annoy", "nndescent", "exhaustive", "ivf"), nn_params = params_nn(), phate_params = params_phate(), seed = 42L, use_high_precision = NULL, .verbose = TRUE )
data |
Numerical matrix or data frame. The data to embed of shape samples x features. Will be coerced to a matrix. |
knn |
Optional |
n_dim |
Integer. Number of dimensions in the embedding space.
Currently only |
k |
Integer. Number of nearest neighbours for graph construction.
Defaults to |
knn_method |
Character. (Approximate) Nearest neighbour method to use.
One of |
nn_params |
Named list. Nearest neighbour search parameters, see
|
phate_params |
Named list. PHATE algorithm parameters, see
|
seed |
Integer. Random seed for reproducibility. Defaults to |
use_high_precision |
Optional boolean. Gives fine-grained control over
|
.verbose |
Logical. Controls verbosity. Defaults to |
A numerical matrix with dimensions samples x n_dim containing the PHATE embedding.
This is an interface into various (approximate) nearest neighbour searches
implemented in the Rust crate
ann-search-rs. They designed for incredible
fast in-memory searches for kNN generation.
rs_approx_nearest_neighbours(data, k, ann_method, ann_params, seed, verbose)rs_approx_nearest_neighbours(data, k, ann_method, ann_params, seed, verbose)
data |
Numeric matrix. Shape of samples x n_dim for which to get the (approximate) nearest neighbours |
k |
Integer. Number of neighbours to return |
ann_method |
String. Which of the methods to use. One of
|
ann_params |
Named list. Contains the nearest neighbour parameters. |
seed |
Integer. Seed for reproducibility |
verbose |
Integer. If |
A list with the following elements
indices - flat representation of the indices.
dist - flat representaitons of the distances.
k - number of neighbours.
n - number of samples.
Calculates the adjusted Rand index in Rust between two membership vectors.
rs_ari(cluster_membership_a, cluster_membership_b)rs_ari(cluster_membership_a, cluster_membership_b)
cluster_membership_a |
Integers. Cluster memberships in group a. |
cluster_membership_b |
Integers. Cluster memberships in group b. |
Returns the adjusted Rand index between the two groups.
Generates synthetic data, i.e., the Swiss role to test different manifold
learning techniques
rs_data_biased_swiss_role(n_samples, noise, bias, seed)rs_data_biased_swiss_role(n_samples, noise, bias, seed)
n_samples |
Integer. Number of data points to generate. |
noise |
Numeric. How much noise to add. |
bias |
Numeric. Sampling bias along |
seed |
Integer. For reproducibility purposes |
The biased swiss role synthetic data with the desired parameters.
Generates synthetic data with clear cluster structure.
rs_data_clusters(n_samples, dim, n_clusters, seed)rs_data_clusters(n_samples, dim, n_clusters, seed)
n_samples |
Integer. Number of data points to generate. |
dim |
Integer. Dimensionality of the data |
n_clusters |
Integer. Number of clusters to produce in the data. |
seed |
Integer. For reproducibility purposes |
A list with the following elements:
data - Numerical matrix with the data.
clusters - Cluster assignments
Generates synthetic data with a two-level cluster hierarchy:
n_supergroups
top-level groups each containing n_subclusts tight subclusters. Supergroup
centres are spread far apart; subcluster centres sit tightly around their
supergroup centre.
Note that the actual number of samples returned may be slightly less than
n_samples if it is not evenly divisible by n_supergroups * n_subclusts.
rs_data_hierarchical( n_samples, dim, n_supergroups, n_subclusts, supergroup_spread, subcluster_spread, point_std, seed )rs_data_hierarchical( n_samples, dim, n_supergroups, n_subclusts, supergroup_spread, subcluster_spread, point_std, seed )
n_samples |
Integer. Total number of points, distributed evenly across all subclusters. |
dim |
Integer. Dimensionality of the ambient space. |
n_supergroups |
Integer. Number of top-level groups. Defaults to |
n_subclusts |
Integer. Number of subclusters per supergroup. Defaults
to |
supergroup_spread |
Numeric. Spread of supergroup centres. Defaults to
|
subcluster_spread |
Numeric. Spread of subcluster centres around their
supergroup centre. Defaults to |
point_std |
Numeric. Within-subcluster Gaussian noise. Defaults to
|
seed |
Integer. Seed for reproducibility. |
A named list with three elements: data, a numeric matrix of shape
samples x dim; supergroup, an integer vector of supergroup labels
(0..n_supergroups) one per sample; and subgroup, an integer vector of
subcluster labels (0..n_supergroups * n_subclusts) one per sample.
Generates synthetic data, i.e., the Swiss role to test different manifold
learning techniques
rs_data_swiss_role(n_samples, noise, seed)rs_data_swiss_role(n_samples, noise, seed)
n_samples |
Integer. Number of data points to generate. |
noise |
Numeric. How much noise to add. |
seed |
Integer. For reproducibility purposes |
The swiss role synthetic data with the desired parameters.
Generates synthetic data that has a tree-like structure to simulate
evolution/trajectory of data.
rs_data_trajectory(n_samples, dim, topology, cell_trajectories, noise, seed)rs_data_trajectory(n_samples, dim, topology, cell_trajectories, noise, seed)
n_samples |
Integer. Number of data points to generate. |
dim |
Integer. Dimensionality of the data. |
topology |
String. One of |
cell_trajectories |
List or NULL. Named list with three equal-length
vectors: |
noise |
Numeric. How much noise to add. |
seed |
Integer. For reproducibility purposes. |
A list with the following elements:
data - Numerical matrix with the generated data.
branches - Branch assignments for each sample.
Leverages the densMAP implementation in manifolds-rs - a very fast
Rust-based implementation. densMAP is UMAP with an added density-preserving
term, so tight clusters stay tight and diffuse ones stay diffuse. Setting
lambda to 0 in the parameters recovers plain UMAP.
rs_densmap( embd, n_dim, min_dist, spread, k, densmap_params, seed, use_high_precision, verbose )rs_densmap( embd, n_dim, min_dist, spread, k, densmap_params, seed, use_high_precision, verbose )
embd |
Numerical matrix. The data to use to generate the embeddings. Should be of dimensions samples x features. |
n_dim |
Integer. Number of densMAP dimensions to return. |
min_dist |
Numeric. Minimum distance to use. |
spread |
Numeric. Spread parameter to use. |
k |
Integer. Number of nearest neighbours to consider |
densmap_params |
Named list. List that contains all of the key
parameters for the densMAP generation, i.e. the UMAP ones plus |
seed |
Integer. Seed for reproducibility. |
use_high_precision |
Optional logical. Controls |
verbose |
Integer. If |
The densMAP embeddings.
Narayan, Berger & Cho, Nature Biotechnology, 2021
Leverages the densMAP implementation in manifolds-rs - a very fast
Rust-based implementation. densMAP is UMAP with an added density-preserving
term, so tight clusters stay tight and diffuse ones stay diffuse. This
version uses a pre-computed kNN graph, please see
new_nearest_neighbour().
rs_densmap_from_knn( embd, knn_data, n_dim, min_dist, spread, k, densmap_params, seed, use_high_precision, verbose )rs_densmap_from_knn( embd, knn_data, n_dim, min_dist, spread, k, densmap_params, seed, use_high_precision, verbose )
embd |
Numerical matrix. The data to use to generate the embeddings. Should be of dimensions samples x features. |
knn_data |
|
n_dim |
Integer. Number of densMAP dimensions to return. |
min_dist |
Numeric. Minimum distance to use. |
spread |
Numeric. Spread parameter to use. |
k |
Integer. Number of nearest neighbours to consider |
densmap_params |
Named list. List that contains all of the key
parameters for the densMAP generation, i.e. the UMAP ones plus |
seed |
Integer. Seed for reproducibility. |
use_high_precision |
Optional logical. Controls |
verbose |
Integer. If |
The densMAP embeddings.
Narayan, Berger & Cho, Nature Biotechnology, 2021
Leverages the den-SNE implementation in manifolds-rs - a very fast
Rust-based implementation. den-SNE is tSNE with an added density-preserving
term, so tight clusters stay tight and diffuse ones stay diffuse. Setting
lambda to 0 in the parameters recovers plain tSNE.
rs_densne( embd, n_dim, perplexity, approx_type, densne_params, seed, use_high_precision, verbose )rs_densne( embd, n_dim, perplexity, approx_type, densne_params, seed, use_high_precision, verbose )
embd |
Numerical matrix. The data to use to generate the embeddings. Should be of dimensions samples x features. |
n_dim |
Integer. Number of den-SNE dimensions to return. Needs to be two, others are not supported. |
perplexity |
Numeric. The tSNE perplexity parameter. |
approx_type |
String. One of |
densne_params |
Named list. List that contains all of the key
parameters for the den-SNE generation, i.e. the tSNE ones plus |
seed |
Integer. Seed for reproducibility. |
use_high_precision |
Optional logical. Controls |
verbose |
Integer. If |
The den-SNE embeddings.
Narayan, Berger & Cho, Nature Biotechnology, 2021
Leverages the den-SNE implementation in manifolds-rs - a very fast
Rust-based implementation. den-SNE is tSNE with an added density-preserving
term, so tight clusters stay tight and diffuse ones stay diffuse. This
version uses a pre-computed kNN graph, please see
new_nearest_neighbour().
rs_densne_from_knn( embd, knn_data, n_dim, perplexity, approx_type, densne_params, seed, use_high_precision, verbose )rs_densne_from_knn( embd, knn_data, n_dim, perplexity, approx_type, densne_params, seed, use_high_precision, verbose )
embd |
Numerical matrix. The data to use to generate the embeddings. Should be of dimensions samples x features. |
knn_data |
|
n_dim |
Integer. Number of den-SNE dimensions to return. Needs to be two, others are not supported. |
perplexity |
Numeric. The tSNE perplexity parameter. |
approx_type |
String. One of |
densne_params |
Named list. List that contains all of the key
parameters for the den-SNE generation, i.e. the tSNE ones plus |
seed |
Integer. Seed for reproducibility. |
use_high_precision |
Optional logical. Controls |
verbose |
Integer. If |
The den-SNE embeddings.
Narayan, Berger & Cho, Nature Biotechnology, 2021
Leverages the Diffusion Maps implementation in manifolds-rs - a very fast
Rust-based implementation.
rs_diffusion_maps(embd, n_dim, k, dm_params, seed, use_high_precision, verbose)rs_diffusion_maps(embd, n_dim, k, dm_params, seed, use_high_precision, verbose)
embd |
Numerical matrix. The data to use to generate the embeddings. Should be of dimensions samples x features. |
n_dim |
Integer. Number of dimensions to return. |
k |
Integer. Number of nearest neighbours to consider. |
dm_params |
Named list. List that contains all of the key parameters for the diffusion maps generation. |
seed |
Integer. Seed for reproducibility. |
use_high_precision |
Optional logical. Controls |
verbose |
Integer. If |
The diffusion maps embeddings.
Leverages the Diffusion Maps implementation in manifolds-rs - a very fast
Rust-based implementation. This version uses a pre-computed kNN graph, please see
new_nearest_neighbour().
rs_diffusion_maps_from_knn( embd, knn_data, n_dim, k, dm_params, seed, use_high_precision, verbose )rs_diffusion_maps_from_knn( embd, knn_data, n_dim, k, dm_params, seed, use_high_precision, verbose )
embd |
Numerical matrix. The data to use to generate the embeddings. Should be of dimensions samples x features. |
knn_data |
|
n_dim |
Integer. Number of dimensions to return. |
k |
Integer. Number of nearest neighbours to consider. |
dm_params |
Named list. List that contains all of the key parameters for the diffusion maps generation. |
seed |
Integer. Seed for reproducibility. |
use_high_precision |
Optional logical. Controls |
verbose |
Integer. If |
The diffusion maps embeddings.
Wrapper function into the Rust interface for EVoC clustering.
rs_evoc( embd, n_neighbours, evoc_params, return_knn, seed, use_high_precision, verbose )rs_evoc( embd, n_neighbours, evoc_params, return_knn, seed, use_high_precision, verbose )
embd |
Numerical matrix. The data to cluster. Should be of dimensions samples x features. |
n_neighbours |
Integer. Number of nearest neighbours for graph construction. |
evoc_params |
Named list. List that contains all of the key parameters for EVoC clustering. |
return_knn |
Boolean. Shall the kNN graph be returned. |
seed |
Integer. Seed for reproducibility. |
use_high_precision |
Optional logical. Controls |
verbose |
Integer. If |
A named list with:
evoc_res - List with the EVoC results
knn - Optional list (can be NULL) with the kNN graph
Wrapper function into the Rust interface for EVoC clustering. This version
uses a pre-computed kNN graph, please see
new_nearest_neighbour().
rs_evoc_from_knn( embd, knn_data, n_neighbours, evoc_params, seed, use_high_precision, verbose )rs_evoc_from_knn( embd, knn_data, n_neighbours, evoc_params, seed, use_high_precision, verbose )
embd |
Numerical matrix. The data to cluster. Should be of dimensions samples x features. |
knn_data |
List. A NearestNeighbours object with |
n_neighbours |
Integer. Number of nearest neighbours for graph construction. |
evoc_params |
Named list. List that contains all of the key parameters for EVoC clustering. |
seed |
Integer. Seed for reproducibility. |
use_high_precision |
Optional logical. Controls |
verbose |
Integer. If |
A named list with cluster layers, membership strengths, persistence scores, and the kNN graph.
Leverages the ForceAtlas2 implementation in manifolds-rs. Builds the UMAP
fuzzy union graph from the data and lays it out with ForceAtlas2.
rs_forceatlas2(embd, k, fa2_params, seed, use_high_precision, verbose)rs_forceatlas2(embd, k, fa2_params, seed, use_high_precision, verbose)
embd |
Numerical matrix. The data to use to generate the embeddings. Should be of dimensions samples x features. |
k |
Integer. Number of nearest neighbours to consider. |
fa2_params |
Named list. List that contains all of the key parameters for the kNN search, graph generation and ForceAtlas2 optimisation. |
seed |
Integer. Seed for reproducibility. |
use_high_precision |
Optional logical. Controls |
verbose |
Integer. If |
The ForceAtlas2 embedding, samples x 2.
Leverages the ForceAtlas2 implementation in manifolds-rs and lays out a
caller-supplied undirected graph. Each edge is passed once; the Rust side
adds the reverse direction.
rs_forceatlas2_from_graph( from, to, weight, n, init, fa2_params, seed, use_high_precision, verbose )rs_forceatlas2_from_graph( from, to, weight, n, init, fa2_params, seed, use_high_precision, verbose )
from |
Integer vector. 1-based source vertex of each edge. |
to |
Integer vector. 1-based target vertex of each edge. |
weight |
Numeric vector. Weight of each edge. |
n |
Integer. Number of vertices. |
init |
Optional numerical matrix of dimensions n x 2. The initial
layout. If |
fa2_params |
Named list. List that contains the ForceAtlas2 optimisation parameters. |
seed |
Integer. Seed for reproducibility. |
use_high_precision |
Optional logical. Controls |
verbose |
Integer. If |
The ForceAtlas2 embedding, n x 2.
Leverages the ForceAtlas2 implementation in manifolds-rs. This version uses
a pre-computed kNN graph, please see
new_nearest_neighbour().
rs_forceatlas2_from_knn( embd, knn_data, k, fa2_params, seed, use_high_precision, verbose )rs_forceatlas2_from_knn( embd, knn_data, k, fa2_params, seed, use_high_precision, verbose )
embd |
Numerical matrix. The data to use to generate the embeddings. Should be of dimensions samples x features. |
knn_data |
|
k |
Integer. Number of nearest neighbours to consider. |
fa2_params |
Named list. List that contains all of the key parameters for the graph generation and ForceAtlas2 optimisation. |
seed |
Integer. Seed for reproducibility. |
use_high_precision |
Optional logical. Controls |
verbose |
Integer. If |
The ForceAtlas2 embedding, samples x 2.
Calculates inertia for k-means clustering given the data, centroids and
membership
rs_intertia(data, centroids, cluster_membership)rs_intertia(data, centroids, cluster_membership)
data |
Numeric matrix. The data in shape of sample x features. |
centroids |
Numeric matrix. The centroid data in shape k x features. |
cluster_membership |
Integers. Cluster memberships as integers. |
The inertia score
Rust interface for k-means clustering using Lloyd's algorithm with SIMD or
GEMM acceleration depending on dimensionality. It exposes the high
performance k-means clustering code from the Rust crate
ann-search-rs
for rapid clustering.
rs_k_means(data, k, kmeans_params, seed, verbose)rs_k_means(data, k, kmeans_params, seed, verbose)
data |
Numerical matrix. The data to cluster, of dimensions samples x features. |
k |
Integer. Number of clusters. |
kmeans_params |
Named list. Parameters produced by |
seed |
Integer. Seed for reproducibility. |
verbose |
Boolean. Controls verbosity. |
A named list with:
centroids - Numeric matrix of shape k x features.
assignments - Integer vector of length samples (1-indexed).
Rust interface for mini batch k-means clustering from
bixverse-rs. This
version can be very useful in cases where you overcluster the data.
rs_k_means_mini_batch(data, k, kmeans_params, seed, verbose)rs_k_means_mini_batch(data, k, kmeans_params, seed, verbose)
data |
Numerical matrix. The data to cluster, of dimensions samples x features. |
k |
Integer. Number of clusters. |
kmeans_params |
Named list. Parameters produced by |
seed |
Integer. Seed for reproducibility. |
verbose |
Boolean. Controls verbosity. |
A named list with:
centroids - Numeric matrix of shape k x features.
assignments - Integer vector of length samples (1-indexed).
Leverages the PacMAP implementation in manifolds-rs - a very fast Rust-based
implementation.
rs_pacmap(embd, n_dim, pacmap_params, seed, use_high_precision, verbose)rs_pacmap(embd, n_dim, pacmap_params, seed, use_high_precision, verbose)
embd |
Numerical matrix. The data to use to generate the embeddings. Should be of dimensions samples x features. |
n_dim |
Integer. Number of dimensions to return. |
pacmap_params |
Named list. List that contains all of the key parameters for the PaCMAP generation. |
seed |
Integer. Seed for reproducibility. |
use_high_precision |
Optional logical. Controls |
verbose |
Integer. If |
The PaCMAP embeddings.
Leverages the PacMAP implementation in manifolds-rs - a very fast Rust-based
implementation. This version uses a pre-computed kNN graph, please see
new_nearest_neighbour().
rs_pacmap_from_knn( embd, knn_data, n_dim, pacmap_params, seed, use_high_precision, verbose )rs_pacmap_from_knn( embd, knn_data, n_dim, pacmap_params, seed, use_high_precision, verbose )
embd |
Numerical matrix. The data to use to generate the embeddings. Should be of dimensions samples x features. |
knn_data |
|
n_dim |
Integer. Number of dimensions to return. |
pacmap_params |
Named list. List that contains all of the key parameters for the PaCMAP generation. |
seed |
Integer. Seed for reproducibility. |
use_high_precision |
Optional logical. Controls |
verbose |
Integer. If |
The PaCMAP embeddings.
Leverages the PHATE implementation in manifolds-rs - a very fast Rust-based
implementation.
rs_phate(embd, n_dim, k, phate_params, seed, use_high_precision, verbose)rs_phate(embd, n_dim, k, phate_params, seed, use_high_precision, verbose)
embd |
Numerical matrix. The data to embed of shape samples x features. |
n_dim |
Integer. Number of PHATE dimensions to return. Currently only
|
k |
Integer. Number of nearest neighbours for graph construction. |
phate_params |
Named list. Contains all key parameters for PHATE,
see |
seed |
Integer. Seed for reproducibility. |
use_high_precision |
Optional logical. Controls |
verbose |
Integer. If |
The PHATE embedding as a matrix of shape samples x n_dim.
Leverages the PHATE implementation in manifolds-rs - a very fast Rust-based
implementation. This version uses a pre-computed kNN graph, please see
new_nearest_neighbour().
rs_phate_from_knn( embd, knn_data, n_dim, k, phate_params, seed, use_high_precision, verbose )rs_phate_from_knn( embd, knn_data, n_dim, k, phate_params, seed, use_high_precision, verbose )
embd |
Numerical matrix. The data to embed of shape samples x features. |
knn_data |
|
n_dim |
Integer. Number of PHATE dimensions to return. Currently only
|
k |
Integer. Number of nearest neighbours used during graph
construction. Must match the k used to generate |
phate_params |
Named list. Contains all key parameters for PHATE,
see |
seed |
Integer. Seed for reproducibility. |
use_high_precision |
Optional logical. Controls |
verbose |
Integer. If |
The PHATE embedding as a matrix of shape samples x n_dim.
Calculates the Silhouette in Rust given the original data and a membership
vector.
a(i) and b(i) are mean squared Euclidean distances, which
keeps the whole thing closed-form and avoids materialising any pairwise
distance. The trade-off is that the scores are not the numbers a
plain-Euclidean silhouette gives: squaring inflates b more than a, so
the values run higher. The sign is unaffected, so which points sit in the
wrong cluster is the same call, but do not compare the magnitudes against
implementations that use plain Euclidean.
rs_silhouette_score(data, cluster_membership)rs_silhouette_score(data, cluster_membership)
data |
Numeric matrix. The data in shape of sample x features. |
cluster_membership |
Integers. Cluster memberships as integers. |
A list with the following items
mean_silhouette - Mean silhouette scores per cluster.
silhouette_scores - Silhouette scores per given data point.
Leverages the tSNE implementation in manifolds-rs - a very fast Rust-based
implementation. You have three optimiser options:
"bh" which tends to be
faster on smaller datasets, and "fft" or its three-kernel variant
"fft_3k" for large data sets.
rs_tsne( embd, n_dim, perplexity, approx_type, tsne_params, seed, use_high_precision, verbose )rs_tsne( embd, n_dim, perplexity, approx_type, tsne_params, seed, use_high_precision, verbose )
embd |
Numerical matrix. The data to use to generate the embeddings. Should be of dimensions samples x features. |
n_dim |
Integer. Number of tSNE dimensions to return. Needs to be two, others are not supported. |
perplexity |
Numeric. The tSNE perplexity parameter. |
approx_type |
String. One of |
tsne_params |
Named list. List that contains all of the key parameters for the tSNE generation. |
seed |
Integer. Seed for reproducibility. |
use_high_precision |
Optional logical. Controls |
verbose |
Integer. If |
The tSNE embeddings.
Leverages the tSNE implementation in manifolds-rs - a very fast Rust-based
implementation. You have three optimiser options:
"bh" which tends to be
faster on smaller datasets, and "fft" or its three-kernel variant
"fft_3k" for large data sets. This version uses a pre-computed kNN graph,
please see new_nearest_neighbour().
rs_tsne_from_knn( embd, knn_data, n_dim, perplexity, approx_type, tsne_params, seed, use_high_precision, verbose )rs_tsne_from_knn( embd, knn_data, n_dim, perplexity, approx_type, tsne_params, seed, use_high_precision, verbose )
embd |
Numerical matrix. The data to use to generate the embeddings. Should be of dimensions samples x features. |
knn_data |
|
n_dim |
Integer. Number of tSNE dimensions to return. Needs to be two, others are not supported. |
perplexity |
Numeric. The tSNE perplexity parameter. |
approx_type |
String. One of |
tsne_params |
Named list. List that contains all of the key parameters for the tSNE generation. |
seed |
Integer. Seed for reproducibility. |
use_high_precision |
Optional logical. Controls |
verbose |
Integer. If |
The tSNE embeddings.
Leverages the UMAP implementation in manifolds-rs - a very fast Rust-based
implementation.
rs_umap( embd, n_dim, min_dist, spread, k, umap_params, seed, use_high_precision, verbose )rs_umap( embd, n_dim, min_dist, spread, k, umap_params, seed, use_high_precision, verbose )
embd |
Numerical matrix. The data to use to generate the embeddings. Should be of dimensions samples x features. |
n_dim |
Integer. Number of UMAP dimensions to return. |
min_dist |
Numeric. Minimum distance to use. |
spread |
Numeric. Spread parameter to use. |
k |
Integer. Number of nearest neighbours to consider |
umap_params |
Named list. List that contains all of the key parameters for the UMAP generation. |
seed |
Integer. Seed for reproducibility. |
use_high_precision |
Optional logical. Controls |
verbose |
Integer. If |
The UMAP embeddings.
Leverages the UMAP implementation in manifolds-rs - a very fast Rust-based
implementation. This version uses a pre-computed kNN graph, please see
new_nearest_neighbour().
rs_umap_from_knn( embd, knn_data, n_dim, min_dist, spread, k, umap_params, seed, use_high_precision, verbose )rs_umap_from_knn( embd, knn_data, n_dim, min_dist, spread, k, umap_params, seed, use_high_precision, verbose )
embd |
Numerical matrix. The data to use to generate the embeddings. Should be of dimensions samples x features. |
knn_data |
|
n_dim |
Integer. Number of UMAP dimensions to return. |
min_dist |
Numeric. Minimum distance to use. |
spread |
Numeric. Spread parameter to use. |
k |
Integer. Number of nearest neighbours to consider |
umap_params |
Named list. List that contains all of the key parameters for the UMAP generation. |
seed |
Integer. Seed for reproducibility. |
use_high_precision |
Optional logical. Controls |
verbose |
Integer. If |
The UMAP embeddings.
Performs t-SNE dimensionality reduction on the input data. This function provides a user-friendly interface with input validation before calling the Rust implementation.
tsne( data, knn = NULL, n_dim = 2L, perplexity = 20, approx_type = c("bh", "bh_qd", "fft", "fft_3k"), knn_method = c("kmknn", "balltree", "hnsw", "annoy", "nndescent", "exhaustive", "ivf"), nn_params = params_nn(), tsne_params = params_tsne(), seed = 42L, use_high_precision = NULL, .verbose = TRUE )tsne( data, knn = NULL, n_dim = 2L, perplexity = 20, approx_type = c("bh", "bh_qd", "fft", "fft_3k"), knn_method = c("kmknn", "balltree", "hnsw", "annoy", "nndescent", "exhaustive", "ivf"), nn_params = params_nn(), tsne_params = params_tsne(), seed = 42L, use_high_precision = NULL, .verbose = TRUE )
data |
Numerical matrix or data frame. The data to embed of shape samples x features. Will be coerced to a matrix. |
knn |
Optional |
n_dim |
Integer. Number of dimensions in the embedding space.
Currently only |
perplexity |
Numeric. Perplexity parameter, related to the number of
nearest neighbours used in manifold learning. Typical values are between
5 and 50. Defaults to |
approx_type |
Character. Approximation method for computing repulsive
forces. One of |
knn_method |
Character. (Approximate) Nearest neighbour method to use.
One of |
nn_params |
Named list. Nearest neighbour search parameters, see
|
tsne_params |
Named list. t-SNE algorithm parameters, see
|
seed |
Integer. Random seed for reproducibility. |
use_high_precision |
Optional boolean. Gives fine-grained control over
|
.verbose |
Logical. Controls verbosity. Defaults to |
The number of neighbours will be '3 * perplexity“, as this is a usual default in tSNE.
A numerical matrix with dimensions samples x n_dim containing the t-SNE embedding.
Performs UMAP dimensionality reduction on the input data. This function provides a user-friendly interface with input validation before calling the Rust implementation.
umap( data, knn = NULL, n_dim = 2L, k = 15L, min_dist = 0.5, spread = 1, knn_method = c("kmknn", "balltree", "hnsw", "annoy", "nndescent", "exhaustive", "ivf"), nn_params = params_nn(), umap_params = params_umap(), seed = 42L, use_high_precision = NULL, .verbose = TRUE )umap( data, knn = NULL, n_dim = 2L, k = 15L, min_dist = 0.5, spread = 1, knn_method = c("kmknn", "balltree", "hnsw", "annoy", "nndescent", "exhaustive", "ivf"), nn_params = params_nn(), umap_params = params_umap(), seed = 42L, use_high_precision = NULL, .verbose = TRUE )
data |
Numerical matrix or data frame. The data to embed of shape samples x features. Will be coerced to a matrix. |
knn |
Optional |
n_dim |
Integer. Number of dimensions in the embedding space.
Defaults to |
k |
Integer. Number of nearest neighbours to consider for manifold
approximation. Larger values result in more global structure being
preserved. Defaults to |
min_dist |
Numeric. Minimum distance between points in the embedding.
Controls how tightly points are packed. Smaller values result in more
clustered embeddings. Must be >= 0. Defaults to |
spread |
Numeric. Effective scale of embedded points. Determines the
scale at which embedded points will be spread out. Defaults to |
knn_method |
Character. (Approximate) Nearest neighbour method to use.
One of |
nn_params |
Named list. Nearest neighbour search parameters, see
|
umap_params |
Named list. UMAP algorithm parameters, see
|
seed |
Integer. Random seed for reproducibility. Defaults to |
use_high_precision |
Optional boolean. Gives fine-grained control over
|
.verbose |
Logical. Controls verbosity. Defaults to |
A numerical matrix with dimensions samples x n_dim containing the UMAP embedding.