Skip to contents

GPU-accelerated counterpart to bixverse::umap_sc(). Pulls an embedding (defaulting to PCA) off the object, runs umap_gpu() on it (GPU kNN plus GPU Adam optimiser by default), and writes the resulting embedding back into sc_cache$other_embeddings[[slot_name]].

When use_knn = TRUE (the default), the kNN graph already stored on the object is reused via bixverse::sc_knn_to_nearest_neighbours(). Otherwise a fresh GPU kNN is built from the chosen embedding.

Usage

umap_gpu_sc(
  object,
  use_knn = TRUE,
  embd_to_use = "pca",
  slot_name = "umap",
  no_embd_to_use = NULL,
  modality = c("rna", "adt", "atac", "wnn"),
  n_dim = 2L,
  k = 15L,
  min_dist = 0.5,
  spread = 1,
  knn_method = c("nndescent", "exhaustive", "ivf"),
  nn_params = params_nn_gpu(),
  umap_params = params_umap_gpu(),
  seed = 42L,
  backend = c("wgpu", "mlx"),
  .verbose = TRUE
)

Arguments

object

SingleCells (or SingleCellsMultiModal) class.

use_knn

Boolean. Use the kNN graph found in the object. Defaults to TRUE. Only reused if the modality lines up; otherwise a fresh GPU kNN is generated.

embd_to_use

String. The embedding to use for UMAP. Must be available in the object for the chosen modality.

slot_name

String. The name of this embedding within the object. Defaults to "umap".

no_embd_to_use

Optional integer. Number of embedding dimensions to use. If NULL, all will be used.

modality

String. On which modality to run UMAP. One of c("rna", "adt", "atac", "wnn"). "adt" and "wnn" need a SingleCellsMultiModal, "atac" a SingleCellsMultiModal or a SingleCellsAtac.

n_dim

Integer. Number of UMAP dimensions. Defaults to 2L.

k

Integer. Number of nearest neighbours. Defaults to 15L.

min_dist

Numeric. Minimum distance between embedded points. Defaults to 0.5.

spread

Numeric. Effective scale of embedded points. Defaults to 1.0.

knn_method

String. GPU (approximate) nearest neighbour method. One of c("nndescent", "exhaustive", "ivf").

nn_params

Named list. GPU kNN parameters, see params_nn_gpu().

umap_params

Named list. UMAP (GPU) parameters, see params_umap_gpu().

seed

Integer. For reproducibility.

backend

String. One of c("wgpu", "mlx"). "mlx" runs the kNN search and the "adam_gpu" optimiser on MLX, see umap_gpu(). "adam_v06_gpu" stays on WGPU. The CPU optimisers ("adam_parallel", "adam_v06", "sgd", "sgd_parallel", "adam") stay on the CPU.

.verbose

Boolean or integer. Controls verbosity.

Value

The object with a "umap" embedding added. If the requested embedding is missing, errors.