Computes a 2-D UMAP embedding via the uwot package and stores it under
"umap". By default the embedding is computed on the top principal
components (see use_pca).
Usage
RunUMAP(
object,
dims = 30L,
use_pca = TRUE,
n_neighbors = 15L,
densmap = FALSE,
slot = "data",
markers = NULL,
seed = NULL,
n_threads = 1L,
pca_method = "svd",
...
)Arguments
- object
A
SpatialCellData-classobject.- dims
Integer. Number of PCs (or markers) to embed. Default
30.- use_pca
Logical. Embed on PCA space (default
TRUE) or directly on the marker matrix.- n_neighbors
Integer. UMAP neighbourhood size. Default
15.- densmap
Logical. Preserve local densities with the approximation of densMAP in uwot (
dens_scale = 1inuwot::umap()) instead of plain UMAP. DefaultFALSE. For partial density preservation, passdens_scalethrough...instead.- slot
Character.
"data"(default) or"counts".- markers
Character vector or
NULL.- seed
Integer or
NULL. Random seed for reproducibility. The random number stream of the caller is restored afterwards.- n_threads
Integer. Number of worker threads for UMAP neighbour search. Defaults to
1; increase explicitly for larger analyses.- pca_method
Character. PCA solver used by uwot for initialisation or optional dimensionality reduction. Defaults to
"svd", using base R for the small marker/PC panels typical of spatial data. Pass"auto"or"irlba"to use an optional truncated solver for larger panels.- ...
Passed to
uwot::umap().
Examples
# \donttest{
if (requireNamespace("uwot", quietly = TRUE)) {
counts <- matrix(rnorm(500), nrow = 50,
dimnames = list(NULL, paste0("M", 1:10)))
coords <- data.frame(x = runif(50), y = runif(50))
obj <- CreateSpatialObject(counts, coords)
obj <- RunUMAP(obj, seed = 1)
}
# }