
Generate GPU kNN data for single cells
generate_gpu_knn_sc.RdThis 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(orSingleCellsMultiModal) 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
NULLall cells in the object will be used.- no_embd_to_use
Optional integer. Number of embedding dimensions to use. If
NULLall will be used.- modality
String. One of
c("rna", "adt", "atac")."adt"needs aSingleCellsMultiModal,"atac"aSingleCellsMultiModalor aSingleCellsAtac.- 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
- ivf_params
- 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, seemlx_available().- .verbose
Boolean or integer. Controls verbosity.