Skip to contents

A GPU-accelerated version of Harmony v2 by Patikas et al., 2026, implemented in Rust. Performs batch correction on PCA embeddings and stores the result as a "harmony_gpu" embedding in the object. Only a single batch covariate is supported on the GPU path.

Usage

harmony_gpu_sc(
  object,
  batch_column,
  embd_to_use = "pca",
  modality = c("rna", "adt", "atac"),
  harmony_params = params_sc_harmony_v2_gpu(),
  seed = 42L,
  backend = c("wgpu", "mlx"),
  .verbose = TRUE
)

Arguments

object

SingleCells class.

batch_column

String. Column name in the object containing the batch labels.

embd_to_use

String. The embedding to correct, "pca" or any other cached embedding.

modality

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

harmony_params

List. Output of params_sc_harmony_v2_gpu().

seed

Integer. For reproducibility.

backend

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

.verbose

Boolean or integer. Controls verbosity and returns run times. FALSE -> quiet, TRUE or 1L -> normal verbosity, 2L -> detailed verbosity.

Value

The object with a "harmony_gpu" embedding added. If the embedding is not found or the batch column holds a single batch, returns the object unchanged with a warning.