Learn R Programming

uwot (version 0.0.0.9001)

tumap: Dimensionality Reduction Using t-Distributed UMAP (t-UMAP)

Description

A faster (but less flexible) version of the UMAP gradient. FOr more detail on UMAP, see the umap function.

Usage

tumap(X, n_neighbors = 15, n_components = 2, metric = "euclidean",
  n_epochs = NULL, alpha = 1, scale = FALSE, init = "spectral",
  set_op_mix_ratio = 1, local_connectivity = 1, bandwidth = 1,
  gamma = 1, negative_sample_rate = 5, nn_method = NULL,
  n_trees = 50, search_k = 2 * n_neighbors * n_trees,
  n_threads = max(1, RcppParallel::defaultNumThreads()/2),
  grain_size = 1, y = NULL, target_n_neighbors = n_neighbors,
  target_weight = 0.5, ret_model = FALSE,
  verbose = getOption("verbose", TRUE))

Arguments

X

Input data. Can be a data.frame, matrix, dist object or sparseMatrix. A sparse matrix is interpreted as a distance matrix and both implicit and explicit zero entries are ignored. Set zero distances you want to keep to an arbitrarily small non-zero value (e.g. 1e-10). Matrix and data frames should contain one observation per row. Data frames will have any non-numeric columns removed.

n_neighbors

The size of local neighborhood (in terms of number of neighboring sample points) used for manifold approximation. Larger values result in more global views of the manifold, while smaller values result in more local data being preserved. In general values should be in the range 2 to 100.

n_components

The dimension of the space to embed into. This defaults to 2 to provide easy visualization, but can reasonably be set to any integer value in the range 2 to 100.

metric

Type of distance metric to use to find nearest neighbors. One of:

  • "euclidean" (the default)

  • "cosine"

  • "manhattan"

Only applies if nn_method = "annoy" (for nn_method = "fnn", the distance metric is always "euclidean").

n_epochs

Number of epochs to use during the optimization of the embedded coordinates. By default, this value is set to 500 for datasets containing 10,000 vertices or less, and 200 otherwise.

alpha

Initial learning rate used in optimization of the coordinates.

scale

Scaling to apply to X if it is a data frame or matrix:

  • "none" or FALSE or NULL No scaling.

  • "scale" or TRUE Scale each column to zero mean and variance 1.

  • "maxabs" Center each column to mean 0, then divide each element by the maximum absolute value over the entire matrix.

  • "range" Range scale the entire matrix, so the smallest element is 0 and the largest is 1.

For t-UMAP, the default is "none".

init

Type of initialization for the coordinates. Options are:

  • "spectral" Spectral embedding using the normalized Laplacian of the fuzzy 1-skeleton, with Gaussian noise added.

  • "normlaplacian". Spectral embedding using the normalized Laplacian of the fuzzy 1-skeleton, without noise.

  • "random". Coordinates assigned using a uniform random distribution between -10 and 10.

  • "lvrandom". Coordinates assigned using a Gaussian distribution with standard deviation 1e-4, as used in LargeVis (Tang et al., 2016) and t-SNE.

  • "laplacian". Spectral embedding using the Laplacian Eigenmap (Belkin and Niyogi, 2002).

  • "pca". The first two principal components from PCA of X if X is a data frame, and from a 2-dimensional classical MDS if X is of class "dist".

  • "spca". Like "pca", but each dimension is then scaled so the standard deviation is 1e-4, to give a distribution similar to that used in t-SNE.

  • A matrix of initial coordinates.

set_op_mix_ratio

Interpolate between (fuzzy) union and intersection as the set operation used to combine local fuzzy simplicial sets to obtain a global fuzzy simplicial sets. Both fuzzy set operations use the product t-norm. The value of this parameter should be between 0.0 and 1.0; a value of 1.0 will use a pure fuzzy union, while 0.0 will use a pure fuzzy intersection.

local_connectivity

The local connectivity required -- i.e. the number of nearest neighbors that should be assumed to be connected at a local level. The higher this value the more connected the manifold becomes locally. In practice this should be not more than the local intrinsic dimension of the manifold.

bandwidth

The effective bandwidth of the kernel if we view the algorithm as similar to Laplacian eigenmaps. Larger values induce more connectivity and a more global view of the data, smaller values concentrate more locally.

gamma

Weighting applied to negative samples in low dimensional embedding optimization. Values higher than one will result in greater weight being given to negative samples.

negative_sample_rate

The number of negative edge/1-simplex samples to use per positive edge/1-simplex sample in optimizing the low dimensional embedding.

nn_method

Method for finding nearest neighbors. Options are:

  • "fnn". Use exact nearest neighbors via the FNN package.

  • "annoy" Use approximate nearest neighbors via the RcppAnnoy package.

By default, if X has less than 4,096 vertices, the exact nearest neighbors are found. Otherwise, approximate nearest neighbors are used.

n_trees

Number of trees to build when constructing the nearest neighbor index. The more trees specified, the larger the index, but the better the results. With search_k, determines the accuracy of the Annoy nearest neighbor search. Only used if the nn_method is "annoy". Sensible values are between 10 to 100.

search_k

Number of nodes to search during the neighbor retrieval. The larger k, the more the accurate results, but the longer the search takes. With n_trees, determines the accuracy of the Annoy nearest neighbor search. Only used if the nn_method is "annoy".

n_threads

Number of threads to use. Default is half that recommended by RcppParallel. For nearest neighbor search, only applies if nn_method = "annoy".

grain_size

Minimum batch size for multithreading. If the number of items to process in a thread falls below this number, then no threads will be used. Used in conjunction with n_threads.

y

Optional target array for supervised dimension reduction. Must be a factor or numeric vector with the same length as X.

target_n_neighbors

Number of nearest neighbors to use to construct the target simplcial set. Default value is n_neighbors. Applies only if y is non-NULL and numeric.

target_weight

Weighting factor between data topology and target topology. A value of 0.0 weights entirely on data, a value of 1.0 weights entirely on target. The default of 0.5 balances the weighting equally between data and target. Only applies if y is non-NULL.

ret_model

If TRUE, then return extra data that can be used to add new data to an existing embedding via umap_transform. Otherwise, just return the coordinates.

verbose

If TRUE, log details to the console.

Value

A matrix of optimized coordinates, or if ret_model = TRUE, a list containing extra information that can be used to add new data to an existing embedding via umap_transform. In this case, the coordinates are available in the list item embedding.

Details

By setting the UMAP curve parameters a and b to 1, you get back the Cauchy distribution as used in t-SNE and LargeVis. It also results in a substantially simplified gradient expression. This can give a speed improvement of around 50%.