Skip to main content

Crate xcell

Crate xcell 

Source
Expand description

§xcell — a pure-Rust port of xCell 1.1.0

xCell (Aran, Hu & Butte, Genome Biology 2017) scores 64 immune and stromal cell types from bulk expression. This crate is a faithful, dependency-light Rust re-implementation of the xCell 1.1.0 pipeline, built on the gsva ssGSEA engine:

  1. rawEnrichmentAnalysis — keep genes shared with xCell’s universe, per-sample average-tie rank, unnormalized ssGSEA over the 489 signatures, subtract each signature’s minimum, average signatures per cell type.
  2. transformScores — per-cell-type power-curve calibration.
  3. spillOver — per-sample non-negative least squares against the compensation matrix K to remove cross-cell-type spillover.
  4. microenvironmentScores — append ImmuneScore, StromaScore, and MicroenvironmentScore.

The bundled model data (signatures, gene universe, spillover matrix, and calibration table) is exported from the GPL-3 xCell package; this crate is therefore licensed GPL-3.0-or-later.

§Example

use xcell::{xcell_analysis, ExprMatrix, XCellModel, XCellParams};

// expr: genes (rows, labelled by symbol) × samples (columns).
let expr: ExprMatrix = xcell::io::read_tsv_matrix(&std::fs::read_to_string("expr.tsv").unwrap());
let model = XCellModel::load();
let scores = xcell_analysis(&expr, &model, &XCellParams::default());
println!("{} rows × {} samples", scores.gene_sets.len(), scores.samples.len());

Loading the embedded model on its own is cheap and infallible:

let model = xcell::XCellModel::load();
assert_eq!(model.cell_types.len(), 64);

Re-exports§

pub use data::SpillModel;
pub use data::XCellModel;
pub use xcell::xcell_analysis;
pub use xcell::XCellParams;

Modules§

data
Embedded xCell model data (xCell 1.1.0): the signatures, the scoring-gene universe, the spillover matrix K, and the calibration table fv, for both the RNA-seq and the microarray spill objects. All of it is exported from the GPL-3 xCell package by benchmarks/export_xcell_data.R; xcell-rust is itself GPL-3.0-or-later, so bundling it is license-clean.
io
Minimal, dependency-free TSV reader for expression matrices.
microenv
Stage 4 of xCell: microenvironmentScores.
rawenrich
Stage 1 of xCell: rawEnrichmentAnalysis.
spillover
Stage 3 of xCell: spillOver.
transform
Stage 2 of xCell: transformScores.
xcell
The xCell pipeline entry point: xCellAnalysis.

Structs§

EnrichmentResult
Result of a gene-set enrichment run: a per-set score for each sample.
ExprMatrix
An expression matrix with named rows (features/genes) and columns (samples).
GeneSet
A named gene set: a signature name and its member gene identifiers.
GeneSets
An ordered collection of GeneSets.