1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
//! # xcell — a pure-Rust port of xCell 1.1.0
//!
//! [xCell](https://github.com/dviraran/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
//!
//! ```no_run
//! 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);
//! ```
pub use ;
pub use ;
// Re-export the gsva substrate xcell is built on, so downstream code can
// construct inputs and read results without depending on gsva directly.
pub use ;