| Crates.io | single-statistics |
| lib.rs | single-statistics |
| version | 0.8.1 |
| created_at | 2025-04-29 08:43:45.04394+00 |
| updated_at | 2025-09-11 11:23:08.286108+00 |
| description | A specialized Rust library for statistical analysis of single-cell data, part of the single-rust ecosystem. |
| homepage | https://singlerust.com |
| repository | https://github.com/SingleRust/single-statistics |
| max_upload_size | |
| id | 1653315 |
| size | 114,071 |
A specialized Rust library for statistical analysis of single-cell data, part of the single-rust ecosystem.
single-statistics provides robust statistical methods for biological analysis of single-cell data, focusing on differential expression analysis, marker gene identification, and related statistical tests. This crate builds on the foundations provided by single-algebra while implementing biologically-relevant statistical approaches optimized for sparse single-cell data.
Differential Expression Analysis
Multiple Testing Correction
Statistical Framework
Add the crate to your Cargo.toml:
[dependencies]
single-statistics = "0.1.0"
use nalgebra_sparse::CsrMatrix;
use single_statistics::testing::{Alternative, MatrixStatTests, TestMethod, TTestType};
fn main() -> anyhow::Result<()> {
// Create or load your expression matrix (genes x cells)
let expression_matrix: CsrMatrix<f64> = // ...
// Define groups (e.g., cell types, conditions)
let group_ids = vec![0, 0, 0, 1, 1, 1];
// Run differential expression analysis
let results = expression_matrix.differential_expression(
&group_ids,
TestMethod::TTest(TTestType::Welch)
)?;
// Get significantly differentially expressed genes
let significant_genes = results.significant_indices(0.05);
println!("Found {} significant genes", significant_genes.len());
// Access statistics, p-values, and effect sizes
if let Some(effect_sizes) = &results.effect_sizes {
for (i, &gene_idx) in significant_genes.iter().enumerate() {
println!(
"Gene {}: statistic = {}, p-value = {}, adjusted p-value = {}, effect size = {}",
gene_idx,
results.statistics[gene_idx],
results.p_values[gene_idx],
results.adjusted_p_values.as_ref().unwrap()[gene_idx],
effect_sizes[i]
);
}
}
Ok(())
}
single-statistics is designed to work seamlessly with other components of the single-rust ecosystem:
This crate focuses specifically on statistics related to differential expression and marker gene identification. It implements robust, efficient algorithms optimized for sparse data, providing statistical foundations for higher-level analyses in the single-cell domain.
Features in scope:
Features out of scope (available in other crates):
single-algebra)single-algebra)single-clustering)Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the BSD 3-Clause License - see the LICENSE.md file for details.