Run UMAP on a BANKSY embedding.

runBanksyUMAP(
  se,
  use_agf = FALSE,
  lambda = 0.2,
  use_pcs = TRUE,
  npcs = 20L,
  dimred = NULL,
  ndims = NULL,
  assay_name = NULL,
  scale = TRUE,
  group = NULL,
  n_neighbors = 30L,
  spread = 3,
  min_dist = 0.1,
  n_epochs = 300L,
  M = NULL,
  seed = NULL,
  ...
)

Arguments

se

A SpatialExperiment, SingleCellExperiment or SummarizedExperiment object with computeBanksy ran.

use_agf

A logical vector specifying whether to use the AGF for computing UMAP.

lambda

A numeric vector in \(\in [0,1]\) specifying a spatial weighting parameter. Larger values (e.g. 0.8) incorporate more spatial neighborhood and find spatial domains, while smaller values (e.g. 0.2) perform spatial cell-typing.

use_pcs

A logical scalar specifying whether to run UMAP on PCs. If FALSE, runs on the BANKSY matrix.

npcs

An integer scalar specifying the number of principal components to use if use_pcs is TRUE.

dimred

A string scalar specifying the name of an existing dimensionality reduction result to use. Will overwrite use_pcs if supplied.

ndims

An integer scalar specifying the number of dimensions to use if dimred is supplied.

assay_name

A string scalar specifying the name of the assay used in computeBanksy.

scale

A logical scalar specifying whether to scale features before UMAP. Only used when use_pcs is FALSE. Defaults to TRUE.

group

A string scalar specifying a grouping variable for samples in se. This is used to scale the samples in each group separately.

n_neighbors

An integer scalar specifying the number of neighbors to use for UMAP.

spread

A numeric scalar specifying the effective scale of embedded points.

min_dist

A numeric scalar specifying the effective min. dist. between embedded points.

n_epochs

An integer scalar specifying the number of epochs to run UMAP optimization.

M

Advanced usage. An integer vector specifying the highest azimuthal Fourier harmonic to use. If specified, overwrites the use_agf argument.

seed

Seed for UMAP. If not specified, no seed is set.

...

parameters to pass to uwot::umap

Value

A SpatialExperiment / SingleCellExperiment / SummarizedExperiment object with UMAP coordinates in reducedDims(se).

Details

This function runs UMAP on the principal components computed on the BANKSY matrix.

Examples

data(rings)
spe <- runBanksyPCA(rings, assay_name = "counts", lambda = 0.2, npcs = 20)
#> Computing neighbors...
#> Spatial mode is kNN_median
#> Parameters: k_geom=15
#> Done
#> Building sparse weight matrix
#> Computing scaling parameters for own expression
#> Computing clipping excess for own expression
#> Computing scaling params and clipping for H0
#> H0 genes requiring clipping: 0 / 50
#> Clipping corrections: own=0 H0=0 entries
#> Computing BANKSY PCA (20 PCs) via C++ irlba (work=27)
#>   iter=1  mprod=54  sv[20]=8.5000e+00  t=0s
#>   iter=2  mprod=68  sv[20]=1.1893e+01  t=0s
#>   iter=5  mprod=110  sv[20]=1.4406e+01  t=0s
#>   iter=8  mprod=152  sv[20]=1.4489e+01  t=0s
#>   Converged: iter=8, mprod=152
#> Done.
spe <- runBanksyUMAP(spe, lambda = 0.2)