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,
cores = 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,
cores = 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
Which dimensionality reduction to use. Default is
"pca".- dims
The dimensions to be used. Default is
NULL.- features
A character vector of features to use. 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
Which assay to use. If
NULL, the default assay of the Seurat object will be used.- layer
Which layer to use. 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.- cores
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.0and1.0; a value of1.0will use a pure fuzzy union, while0.0will 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
Random seed for reproducibility. Default is
11.
Examples
data(pancreas_sub)
pancreas_sub <- standard_scop(pancreas_sub)
#> ℹ [2026-01-27 08:35:03] Start standard scop workflow...
#> ℹ [2026-01-27 08:35:04] Checking a list of <Seurat>...
#> ! [2026-01-27 08:35:04] Data 1/1 of the `srt_list` is "unknown"
#> ℹ [2026-01-27 08:35:04] Perform `NormalizeData()` with `normalization.method = 'LogNormalize'` on the data 1/1 of the `srt_list`...
#> ℹ [2026-01-27 08:35:06] Perform `Seurat::FindVariableFeatures()` on the data 1/1 of the `srt_list`...
#> ℹ [2026-01-27 08:35:06] Use the separate HVF from srt_list
#> ℹ [2026-01-27 08:35:07] Number of available HVF: 2000
#> ℹ [2026-01-27 08:35:07] Finished check
#> ℹ [2026-01-27 08:35:07] Perform `Seurat::ScaleData()`
#> ℹ [2026-01-27 08:35:07] Perform pca linear dimension reduction
#> ℹ [2026-01-27 08:35:08] Perform `Seurat::FindClusters()` with `cluster_algorithm = 'louvain'` and `cluster_resolution = 0.6`
#> ℹ [2026-01-27 08:35:08] Reorder clusters...
#> ℹ [2026-01-27 08:35:08] Perform umap nonlinear dimension reduction
#> ℹ [2026-01-27 08:35:08] Non-linear dimensionality reduction (umap) using (Standardpca) dims (1-50) as input
#> ℹ [2026-01-27 08:35:13] Non-linear dimensionality reduction (umap) using (Standardpca) dims (1-50) as input
#> ✔ [2026-01-27 08:35:17] Run scop standard workflow completed
pancreas_sub <- RunUMAP2(pancreas_sub, dims = 1:30)
CellDimPlot(
pancreas_sub,
group.by = "CellType",
reduction = "umap"
)