bixverse-rs 0.5.6

A Rust library with various utilities for computational biology and single cell.
Documentation

CI Crates.io Version docs.rs License: MIT

bixverse-rs

Description

A Rust crate for computational biology: statistics, gene set enrichment, graph algorithms, matrix factorisation, ontologies and a full single cell suite. It is the numerical core underneath the bixverse R package, but it has no R dependency of its own and can be used as a plain Rust library.

The code originally lived in src/Rust/ of that R package. Pulling it out into its own crate means the numerics get tested, benchmarked and versioned independently of the wrapper that happens to call them. Design constraint throughout: atlas-scale analysis on a laptop, not on a cluster.

What's in it

Well over a hundred named methods, plus the shared numerical scaffolding they sit on.

Domain Methods
core Correlations and pairwise similarity, PCA/SVD, randomised SVD, LOESS, RBF kernels, mutual information and entropy, scalar optimisation (R's optimize), linear mixed models (REML with Satterthwaite), E-distance and perturbation distances, sparse structures, synthetic data generators
enrichment GSEA (fgsea multi-level), blitzGSEA (gamma-approximated null), GSVA, ssGSEA, singscore, mitch, over-representation
graph Louvain, WalkTrap, spectral clustering, label propagation, personalised and constrained PageRank, connected components, Dijkstra (single and multi-source), Kruskal spanning forests, PAGA-style graph abstraction, graph metrics
methods NMF (bulk, dense HALS, sparse HALS, consensus, refit), ICA, LDA via variational Bayes, sparse multiple CCA, differential correlation, graph diffusion, SNF, RBH, CoReMo, dgRDL, cis-target; bulk DGE via edgeR's quasi-likelihood chain and limma-voom (feature dge)
ml k-means, clustering metrics, landmark Gaussian process regression, Matern kernels
ontology GO Elim, Wang and Resnik-style semantic similarity
single_cell I/O for h5ad, 10x h5, mtx, R/Seurat counts and a versioned binary sparse format (single and multi-file, mmap-backed, mergeable); QC, CellSweep ambient removal, HVG, scTransform v2 (per-sample fits, covariate regression, analytic Pearson residuals, corrected counts), PCA, kNN, SNN, MAGIC; doublet detection (Scrublet, scDblFinder, cxds); batch correction (Harmony v1 and v2, BBKNN, fastMNN, Seurat CCA/rPCA anchors); integration metrics (kBET, iLISI/cLISI, silhouette, PC regression); annotation (scType, Symphony); DGE (Mann-Whitney with AUROC, pseudobulk edgeR, NEBULA); analysis (SCENIC with regulon binarisation, AUCell, Hotspot, VISION, DIALOGUE, MELD, miloR, NicheNet, NMF, module scoring, fast k-means/Louvain clustering); meta cells (SEACells, MetaCells2, SuperCell, hdWGCNA, plus density and compactness metrics); trajectories (Palantir, PAGA, diffusion maps, Markov chains, gene trends); multi-modal (WNN, DSB)
gpu Sparse randomised SVD, SpMM and sparse GEMM, skinny GEMM, Gram, CholeskyQR2, correlation, PCA, kNN, NMF and consensus NMF, Harmony, BBKNN, SCENIC, Scrublet, SEACells, NEBULA, fast clustering

Heavy lifting goes through faer for dense linear algebra, rayon for CPU fan-out, wide for SIMD, and cubecl for GPU kernels. Vector search, distance metrics and k-means come from the sister crate ann-search-rs; the GPU primitives layer from cubecl-utils-rs; the edgeR, limma and NEBULA numerics from edge-rs.

Feature flags

Everything past the base statistics and graph code is gated, so a consumer only pays for what it uses.

Flag What it turns on
(default) Bulk statistics, enrichment, graph, ontology, matrix factorisation
single-cell The single_cell module, HDF5 and mmap I/O, the binary sparse format
multi-modal single_cell::multi_modal (WNN, ADT), implies single-cell
dge Negative binomial DGE via edge-rs: bulk edgeR and limma-voom. Implied by single-cell, usable on its own
hdf5-static Builds the bundled HDF5 from source instead of linking an external libhdf5
hdf5-filters Compiles the LZF and Blosc filters into HDF5, so h5ad files written with those codecs load
gpu The gpu module via cubecl (wgpu and CPU backends) and cubek
large-test Slow but asserting tests: GPU parity gates, large-scale numerical checks
large_scale_diagnostics Unasserted diagnostic sweeps that print tables for a human

Using it from Rust

[dependencies]
bixverse-rs = { version = "0.5", features = ["single-cell"] }
use bixverse_rs::prelude::*;

The prelude re-exports the errors, sparse structures, SparseGraph, matrix and vector helpers, the SIMD trait and the assertion macros.

How it plugs into R

The R side is a thin wrapper, and deliberately so. bixverse depends on this crate through extendr, and does the things R is good at: argument checking, S7 classes, documentation, plotting handoff. The Rust side owns the maths.

Each top-level module carries a *_r_wrapper.rs sibling holding the R conversions: from_r_list deserialisers for the parameter structs and a handful of serialisers back to R lists. The #[extendr] entry points themselves live downstream in the R packages, so R types never touch the numerical surface.

Two R packages consume the crate:

  • bixverse with single-cell and multi-modal. The main package.
  • bixverse.gpu with gpu and single-cell, adding wgpu-backed versions of the expensive methods.

Anything on the Rust side that never crosses into R works standalone, so the crate is equally usable from a pure Rust binary or behind a PyO3 layer.

Roadmap

Methods

Differential expression

  • Bulk edgeR quasi-likelihood and limma-voom via edge-rs
  • Pseudobulk and NEBULA for single cell
  • limma treat/topTreat, decideTests, and block/correlation in voom

GPU accelerations

  • GPU-accelerated sparse, randomised SVD
  • GPU-accelerated Harmony
  • GPU-accelerated correlations (Metal does not have the absolute greatest performance here unfortunately...)
  • SEACells with GPU acceleration.
  • GPU-accelerated BBKNN version
  • GPU-accelerated NEBULA

Python interface

  • Data loader to pull the counts out of the binary files and expose them to Python-based deep learning frameworks (JAX, PyTorch).

Updates

Updates on what's happening in this crate can be found here

Licence

MIT License

Copyright (c) 2026 Gregor Alexander Lueg

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.