Skip to contents

This function generates a SingleCellNearestNeighbour object using GPU-accelerated kNN algorithms via the bixverse.gpu package. Four methods are available: "nndescent" hands back the NN-descent kNN graph itself, with no index and no search, and tops up rows the descent left short with an exact search; "cagra" prunes the same graph into a CAGRA navigational graph and beam searches it; "exhaustive" performs an exact brute-force search on the GPU; and "ivf" builds an inverted file index that partitions the embedding space into Voronoi cells and probes only a subset at query time. This function is the GPU counterpart of generate_knn_sc().

Usage

generate_gpu_knn_sc(
  object,
  embd_to_use = "pca",
  cells_to_use = NULL,
  no_embd_to_use = NULL,
  modality = c("rna", "adt", "atac"),
  knn_method = c("nndescent", "cagra", "exhaustive", "ivf"),
  nn_params = params_nn_gpu(),
  k = 15L,
  seed = 42L,
  gpu_method = lifecycle::deprecated(),
  ivf_params = lifecycle::deprecated(),
  dist_metric = lifecycle::deprecated(),
  backend = c("wgpu", "mlx"),
  .verbose = TRUE
)

Arguments

object

SingleCells (or SingleCellsMultiModal) class.

embd_to_use

String. The embedding to use. Whichever you choose, it needs to be part of the object for the selected modality.

cells_to_use

Optional string vector. Cell names to include. If NULL all cells in the object will be used.

no_embd_to_use

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

modality

String. One of c("rna", "adt", "atac"). "adt" needs a SingleCellsMultiModal, "atac" a SingleCellsMultiModal or a SingleCellsAtac.

knn_method

String. One of c("nndescent", "cagra", "exhaustive", "ivf").

nn_params

List. Output of params_nn_gpu().

k

Integer. Number of neighbours.

seed

Integer. For reproducibility.

gpu_method

[Deprecated] Use knn_method.

ivf_params

[Deprecated] Use nn_params.

dist_metric

[Deprecated] Use params_nn_gpu(dist_metric = ).

backend

String. One of c("wgpu", "mlx"). "mlx" runs the search on Apple Silicon via MLX and needs a build with the MLX backend, see mlx_available().

.verbose

Boolean or integer. Controls verbosity.

Value

Initialised sc_knn with the kNN data.