dot-ggmlr_pca_gpu: GPU-accelerated PCA on a dense expression matrix

.ggmlr_pca_gpuR Documentation

GPU-accelerated PCA on a dense expression matrix

Description

Computes principal components of a feature-by-cell matrix. The heavy step — the gene-by-gene covariance (a large matrix multiply) — runs on the Vulkan GPU via the ag_* backend; the eigendecomposition of the (small, features x features) covariance runs on the CPU, since ggml has no eigensolver. Cells are projected onto the leading eigenvectors.

Usage

.ggmlr_pca_gpu(
  mat,
  n_components = 50L,
  center = TRUE,
  backend = c("vulkan", "cpu"),
  chunk_size = NULL
)

Arguments

mat

Dense numeric matrix, features in rows, cells in columns.

n_components

Number of principal components to return.

center

Logical; subtract the per-feature mean before PCA (default TRUE). Single-cell PCA is virtually always centered.

backend

"vulkan" to use the GPU for the covariance multiply, "cpu" to keep it on the CPU. The caller (dispatch layer) resolves "auto" to one of these.

Value

A ggml_result: embedding is cells x n_components; metadata holds stdev (component standard deviations), loadings (features x components) and backend.


ggmlR documentation built on July 14, 2026, 1:08 a.m.