Skip to contents

Run UMAP (Uniform Manifold Approximation and Projection)

Usage

RunUMAP2(object, ...)

# S3 method for class 'Seurat'
RunUMAP2(
  object,
  reduction = "pca",
  dims = NULL,
  features = NULL,
  neighbor = NULL,
  graph = NULL,
  assay = NULL,
  layer = "data",
  umap.method = "uwot",
  reduction.model = NULL,
  n_threads = NULL,
  return.model = FALSE,
  n.neighbors = 30L,
  n.components = 2L,
  metric = "cosine",
  n.epochs = 200L,
  spread = 1,
  min.dist = 0.3,
  set.op.mix.ratio = 1,
  local.connectivity = 1L,
  negative.sample.rate = 5L,
  a = NULL,
  b = NULL,
  learning.rate = 1,
  repulsion.strength = 1,
  reduction.name = "umap",
  reduction.key = "UMAP_",
  verbose = TRUE,
  seed.use = 11,
  ...
)

# Default S3 method
RunUMAP2(
  object,
  assay = NULL,
  umap.method = "uwot",
  reduction.model = NULL,
  n_threads = NULL,
  return.model = FALSE,
  n.neighbors = 30L,
  n.components = 2L,
  metric = "cosine",
  n.epochs = 200L,
  spread = 1,
  min.dist = 0.3,
  set.op.mix.ratio = 1,
  local.connectivity = 1L,
  negative.sample.rate = 5L,
  a = NULL,
  b = NULL,
  learning.rate = 1,
  repulsion.strength = 1,
  reduction.key = "UMAP_",
  verbose = TRUE,
  seed.use = 11L,
  ...
)

Arguments

object

An object. This can be a Seurat object, a matrix-like object, a Neighbor object, or a Graph object.

...

Additional arguments to be passed to UMAP.

reduction

The reduction to be used. Default is "pca".

dims

The dimensions to be used. Default is NULL.

features

The features to be used. Default is NULL.

neighbor

The name of the Neighbor object to be used. Default is NULL.

graph

The name of the Graph object to be used. Default is NULL.

assay

The assay to be used. Default is NULL.

layer

The layer to be used. Default is "data".

umap.method

The UMAP method to be used. Options are "naive" and "uwot". Default is "uwot".

reduction.model

A DimReduc object containing a pre-trained UMAP model. Default is NULL.

n_threads

Num of threads used.

return.model

Whether to return the UMAP model. Default is FALSE.

n.neighbors

A number of nearest neighbors to be used. Default is 30.

n.components

A number of UMAP components. Default is 2.

metric

The metric or a function to be used for distance calculations. When using a string, available metrics are: euclidean, manhattan. Other available generalized metrics are: cosine, pearson, pearson2. Note the triangle inequality may not be satisfied by some generalized metrics, hence knn search may not be optimal. When using metric.function as a function, the signature must be function(matrix, origin, target) and should compute a distance between the origin column and the target columns. Default is "cosine".

n.epochs

A number of iterations performed during layout optimization for UMAP. Default is 200.

spread

The spread parameter for UMAP, used during automatic estimation of a/b parameters. Default is 1.

min.dist

The minimum distance between UMAP embeddings, determines how close points appear in the final layout. Default is 0.3.

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, used during construction of fuzzy simplicial set. Default is 1.

negative.sample.rate

The negative sample rate for UMAP optimization. Determines how many non-neighbor points are used per point and per iteration during layout optimization. Default is 5.

a

The parameter a for UMAP optimization. Contributes to gradient calculations during layout optimization. When left at NA, a suitable value will be estimated automatically. Default is NULL.

b

The parameter b for UMAP optimization. Details see parameter a.

learning.rate

The initial value of "learning rate" of layout optimization. Default is 1.

repulsion.strength

A numeric value determines, together with alpha, the learning rate of layout optimization. Default is 1.

reduction.name

The name of the reduction to be stored in the Seurat object. Default is "umap".

reduction.key

The prefix for the column names of the UMAP embeddings. Default is "UMAP_".

verbose

Whether to print the message. Default is TRUE.

seed.use

The random seed to be used. Default is 11.

Examples

pancreas_sub <- Seurat::FindVariableFeatures(pancreas_sub)
#> Finding variable features for layer counts
pancreas_sub <- RunUMAP2(
  object = pancreas_sub,
  features = SeuratObject::VariableFeatures(pancreas_sub)
)
#> Warning: Layer ‘data’ is empty
#> Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 't': subscript out of bounds
CellDimPlot(
  pancreas_sub,
  group.by = "CellType",
  reduction = "umap"
)
#> Warning: No shared levels found between `names(values)` of the manual scale and the
#> data's fill values.