Skip to main content

Crate edge_rs

Crate edge_rs 

Source
Expand description

Negative binomial differential expression for bulk and single-cell RNA-seq.

A Rust port of the edgeR numerical stack (normalisation, Cox-Reid dispersion estimation, the Levenberg-damped negative binomial GLM, quasi-likelihood weights, the exact test), the parts of limma edgeR leans on (squeezeVar, the F-distribution fits, voom), and NEBULA, a negative binomial gamma mixed model for single cell.

The bulk stack follows edgePython, itself a port of edgeR and limma, with the R winning wherever the two disagree. NEBULA is ported from the nebula package’s own C++ instead.

§Numeric policy

Public containers and fits are generic over prelude::EdgeFloat, so single-cell counts can be held as f32 and halve the memory. Likelihood evaluation, Cox-Reid log-determinants, the optimisers and every p-value run in f64 regardless of T. A negative binomial deviance is a difference of large logs, and accumulating one in f32 loses parity with edgeR well before it saves anything worth having.

§Parallelism

Genes are the parallel axis almost everywhere. Counts are stored gene-major, so one gene is a contiguous slice, and the fan-out is a rayon iterator over genes with a per-thread scratch buffer.

Normalisation is the exception, and deliberately so: TMM has no gene axis to fan out over, since the unit of work is one sample compared against a reference column. It parallelises over samples and transposes the counts once on entry so each sample is contiguous. Any module that departs from the gene-major rule says so in its own header.

Modules§

core
Containers and the per-sample quantities edgeR derives from raw counts.
dispersion
Dispersion estimation.
errors
The crate-level error enum.
exact
The classic two-group exact test, edgeR’s exactTest.
glm
Negative binomial generalised linear models, fitted per gene.
limma
The limma routines edgeR depends on.
numeric
The numerical support layer: everything edgePython reaches into scipy for.
prelude
The types most modules want. Prefer use crate::prelude::*; over deep imports in new code.
ql
Quasi-likelihood machinery: edgeR’s ql_weights.c and the adjusted deviances built on it.
results
Ranking and calling: edgeR’s topTags and decideTests.
sc
NEBULA: negative binomial mixed models for single cell.
splicing
diffSpliceDGE: differential exon usage.
utils
Shared building blocks: trait bounds, SIMD kernels and the data structures every other module indexes through.