| Title: | Fast CellChat Database Querying Backed by Rust |
|---|---|
| Description: | Accelerates three bottleneck steps in the CellChat workflow using Rust via extendr. Provides parallel Wilcoxon rank-sum testing with tie correction, HashSet-based gene filtering, and ligand-receptor pair matching as drop-in replacements for CellChat functions. Achieves up to 183x speedup on Wilcoxon testing using Rayon parallelism. |
| Authors: | Mayank Gandhi [aut, cre] (ORCID: <https://orcid.org/0009-0000-3448-9308>) |
| Maintainer: | Mayank Gandhi <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.99.0 |
| Built: | 2026-06-04 10:28:06 UTC |
| Source: | https://github.com/mayankgandhi13/cellchatr |
"Hello world!" to R.Return string "Hello world!" to R.
hello_world()hello_world()
A character string "Hello world!"
hello_world()hello_world()
Match overexpressed genes against CellChatDB ligand-receptor pairs.
rust_match_lr_pairs(overexpressed, lr_ligands, lr_receptors, lr_names)rust_match_lr_pairs(overexpressed, lr_ligands, lr_receptors, lr_names)
overexpressed |
Character vector of overexpressed gene names. |
lr_ligands |
Character vector of ligands from CellChatDB. |
lr_receptors |
Character vector of receptors from CellChatDB. |
lr_names |
Character vector of interaction names from CellChatDB. |
Character vector of matched interaction names.
Time: O(m + r) where m = overexpressed genes, r = LR pairs
Space: O(m) for HashSet
R equivalent (%%in%% twice): O(m x r)
rust_match_lr_pairs( c("TGFB1", "VEGFA"), c("TGFB1", "MYC", "VEGFA"), c("TGFBR1", "MYCBP", "FLT1"), c("TGFB1_TGFBR1", "MYC_MYCBP", "VEGFA_FLT1") )rust_match_lr_pairs( c("TGFB1", "VEGFA"), c("TGFB1", "MYC", "VEGFA"), c("TGFBR1", "MYCBP", "FLT1"), c("TGFB1_TGFBR1", "MYC_MYCBP", "VEGFA_FLT1") )
Filter expression matrix genes to only those present in CellChatDB.
rust_subset_genes(expr_genes, db_genes)rust_subset_genes(expr_genes, db_genes)
expr_genes |
Character vector of gene names from expression matrix. |
db_genes |
Character vector of gene names from CellChatDB. |
Character vector of genes present in both inputs.
Time: O(n + m) where n = db_genes, m = expr_genes
Space: O(n) for HashSet
R equivalent (%%in%%): O(n x m)
rust_subset_genes( c("TGFB1", "VEGFA", "GAPDH"), c("TGFB1", "VEGFA", "MYC") )rust_subset_genes( c("TGFB1", "VEGFA", "GAPDH"), c("TGFB1", "VEGFA", "MYC") )
Identify over-expressed genes per cell type using Wilcoxon rank-sum test.
rust_wilcoxon_filter(counts, labels, gene_names, pval_threshold)rust_wilcoxon_filter(counts, labels, gene_names, pval_threshold)
counts |
NumericMatrix of gene expression (genes x cells). |
labels |
Character vector of cell type labels, one per cell. |
gene_names |
Character vector of gene names. |
pval_threshold |
P-value cutoff for significance. |
Character vector of over-expressed gene names.
Time: O((g/p) x k x c log c) where g = genes, p = CPU cores, k = cell types, c = cells
Space: O(c) per gene
R equivalent: O(g x k x c log c) — serial, no parallelism
counts <- matrix(c(rep(10, 50), rep(0, 50), rep(1, 100)), nrow = 2, byrow = TRUE) labels <- c(rep("A", 50), rep("B", 50)) rust_wilcoxon_filter(counts, labels, c("TGFB1", "GAPDH"), 0.05)counts <- matrix(c(rep(10, 50), rep(0, 50), rep(1, 100)), nrow = 2, byrow = TRUE) labels <- c(rep("A", 50), rep("B", 50)) rust_wilcoxon_filter(counts, labels, c("TGFB1", "GAPDH"), 0.05)