
GPU-accelerated PCA for single cell
calculate_pca_gpu_sc.RdThis function will run a sparse SVD while running the large sparse matrix
multiplications on GPU for improved speed. This also means you will have to
provide the necessary VRAM for your data set. This version only works on the
"rna" modality.
Usage
calculate_pca_gpu_sc(
object,
no_pcs,
pca_params = bixverse::params_sc_pca(),
hvg = NULL,
seed = 42L,
backend = c("wgpu", "mlx"),
.verbose = TRUE
)Arguments
- object
SingleCellsclass- no_pcs
Integer. Number of PCs to calculate.
- pca_params
Named list. Controls the parameters to be used for the PCA calculation which is single cell-specific, see
params_sc_pca().svd_solver = "randomised"picks the randomised SVD, anything else the exact block Lanczos.- hvg
Optional integer. If you want to provide your own HVG genes. Otherwise, the function will default to what is found in
bixverse::get_hvg(). Please provide 1-indexed genes here! If you provide these, the internal HVG will be overwritten.- seed
Integer. Seed for the sketch or the Lanczos starting block.
- backend
String. One of
c("wgpu", "mlx")."mlx"runs the SVD on Apple Silicon via MLX and needs a build with the MLX backend, seemlx_available().- .verbose
Boolean or integer. Controls verbosity and returns run times.
FALSE-> quiet,TRUEor1L-> normal verbosity,2L-> detailed verbosity.
Value
The function will add the PCA factors, loadings and singular values to the object cache in memory.
Details
svd_solver = "randomised" runs the randomised SVD: fast, but
approximate in the trailing PCs. Every other solver ("auto", "exact",
"covariance") runs an exact block Lanczos, as there is no GPU covariance
path. The default from bixverse::params_sc_pca() is "auto", so the
default is exact and slower than the randomised solver.