Skip to content

Shanuz v0.1.0

Choose a tag to compare

@shanikawm shanikawm released this 30 Jun 14:58

Shanuz v0.1.0 — First Release

A Python port of the Seurat single-cell RNA-seq analysis framework, algorithmically faithful to Seurat v5.

Features

Core data structures

  • Shanuz object mirroring the R Seurat S4 class
  • Assay5 — sparse-matrix-backed multi-layer assay with per-layer feature/cell name tracking
  • Graph, DimReduc, Neighbor — faithful ports of Seurat's internal structures

Preprocessing

  • normalize_data — LogNormalize and CLR (Seurat-exact formula)
  • find_variable_features — VST with Seurat-faithful dispersion and LOESS
  • scale_data — z-score with ddof=1 (sample SD, matching R)
  • percentage_feature_set

Normalization

  • sctransform — regularized negative-binomial Pearson residuals; vectorised Poisson IRLS, moment-estimated theta, LOESS regularisation, vars_to_regress support

Signature scoring

  • add_module_score — binned control-gene scoring (Tirosh 2016)
  • cell_cycle_scoring — S/G2M phase assignment with built-in CC_GENES

Dimensionality reduction & neighbours

  • run_pca (scikit-learn, ddof=1 stdev)
  • find_neighbors — KNN + fully-sparse SNN (no dense n×n materialisation)
  • jack_straw / score_jackstraw — JackStraw permutation test
  • run_umap (umap-learn)

Clustering

  • find_clusters — Louvain (python-igraph, deterministic igraph RNG seeding) and Leiden (leidenalg)

Differential expression

  • find_markers / find_all_markers with test types: wilcox (tie-corrected Mann-Whitney U), t, LR (logistic LRT), negbinom (NB GLM LRT), roc (AUC + power)

Plotting

  • dim_plot, feature_plot, vln_plot, dot_plot, elbow_plot, do_heatmap, dim_heatmap, feature_scatter, variable_feature_plot, ridge_plot

AnnData interoperability

  • as_anndata, from_anndata

Tutorials

Four end-to-end tutorials validated against the official Seurat vignettes, each pairing R and Python code with side-by-side output plots:

# Tutorial
1 PBMC 3k — Guided Clustering
2 PBMC 8k — Advanced Subclustering
3 CBMC CITE-seq — Multimodal (RNA + ADT)
4 PBMC 3k — SCTransform

Tests

129 unit tests, all passing.

Installation

git clone https://github.com/GenomicAI/shanuz.git
cd shanuz
pip install -e ".[analysis]"

Algorithms faithfully ported from R Seurat

  • Seurat CLR formula (log1p(x / exp(Σ log1p(x>0) / n)))
  • VST dispersion with Bessel correction
  • Wilcoxon with tie correction (scipy.stats.mannwhitneyu, asymptotic)
  • SCTransform NB model (Hafemeister & Satija 2019; Choudhary & Satija 2022)
  • AddModuleScore (Tirosh et al. 2016)
  • JackStraw permutation test