Skip to main content

A single-cell analysis pipeline.

Project description

scAnalyzer: A Single-Cell Analysis Toolkit

A Python toolkit for single-cell RNA sequencing (scRNA-seq) analysis.

🚧 Warning this project is under heavy development and not ready for production. ABI changes can happen frequently until reach stable version 🚧

GitHub Black isort

Package version

scAnalyzer is an integrated toolkit designed for scalable and memory-efficient single-cell RNA sequencing (scRNA-seq) data analysis. Built around a custom, highly optimized SingleCellDataset core, it seamlessly bridges foundational preprocessing with advanced downstream analyses, including trajectory inference, batch correction, and interactive 3D visualizations.

✨ Key Features

  • 📦 Memory-Efficient Core: Custom SingleCellDataset supporting sparse matrices (CSR/CSC) and HDF5 (.h5ad) I/O operations natively.
  • 🧹 Robust Preprocessing: Automated QC, MAD-based outlier detection, doublet prediction (via Scrublet), and cell-cycle scoring.
  • 🔄 Batch Correction: Built-in support for multiple integration algorithms including Harmony, ComBat, and MNN.
  • 🗺️ Dimensionality Reduction & Clustering: PCA, UMAP, t-SNE, PHATE, and Diffusion Maps. Supports graph-based (Leiden, Louvain) and distance-based clustering (K-Means, DBSCAN, Hierarchical).
  • 📊 Differential Expression: Highly vectorized, ultra-fast marker gene identification (t-test, Wilcoxon) and Gene Set Enrichment Analysis (Hypergeometric, GSEA).
  • 🛤️ Trajectory Inference: Dynamic cellular lineage tracking using Diffusion Pseudotime (DPT) with automated branch detection.
  • 🎨 Interactive Visualizations: Publication-ready static plots (Matplotlib/Seaborn) and dynamic, browser-based visualizations (Plotly 3D embeddings, interactive heatmaps).

🚀 Installation

Install the package directly from PyPI:

pip install scAnalysis

For interactive visualizations, ensure plotly is installed. For Leiden/Louvain clustering, leidenalg, louvain, and igraph are required.

💡 Quick Start

Here is a minimal example demonstrating a standard scRNA-seq workflow using scAnalyzer:

import scAnalysis as sca

1. Load Data

adata = sca.sc_io.read_10x_mtx('data/filtered_gene_bc_matrices/hg19')

2. Preprocessing & QC

sca.preprocessing.calculate_qc_metrics(adata, qc_vars=['MT-'])
adata = sca.preprocessing.filter_cells(adata, min_genes=200, max_pct_mito=5.0)
adata = sca.preprocessing.filter_genes(adata, min_cells=3)
sca.preprocessing.normalize_total(adata, target_sum=1e4)
sca.preprocessing.log1p(adata)
sca.preprocessing.highly_variable_genes(adata, n_top_genes=2000)

3. Dimensionality Reduction

sca.dimensionality.run_pca(adata, n_components=50)
sca.dimensionality.neighbors(adata, n_neighbors=10, n_pcs=40)
sca.dimensionality.run_umap(adata, min_dist=0.3)

4. Clustering & Differential Expression

sca.clustering.cluster_leiden(adata, resolution=0.5, key_added='leiden')
sca.differential.rank_genes_groups(adata, groupby='leiden', method='t-test')

5. Visualization

sca.visualization.plot_umap(adata, color='leiden', save='umap_clusters.png')
sca.visualization.plot_dotplot(adata, var_names=['CD3E', 'MS4A1', 'CD14'], groupby='leiden')

🏗️ Architecture & Modules

The framework is highly modular, allowing you to use only the components you need:

scAnalysis.core: Contains the base SingleCellDataset data structure.

scAnalysis.preprocessing: Filtering, normalization, and HVG selection.

scAnalysis.quality_control: Scrublet doublet detection and outlier filtering.

scAnalysis.dimensionality: PCA, UMAP, t-SNE, DiffMap, PHATE.

scAnalysis.clustering: K-Means, Leiden, Louvain, Spectral, DBSCAN.

scAnalysis.differential: Vectorized stats for marker discovery.

scAnalysis.enrichment: Gene set scoring, MSigDB integration, GSEA.

scAnalysis.trajectory: Root cell selection, DPT, branching.

scAnalysis.visualization: Static plotting (Violin, Dotplot, Heatmap, Volcano).

scAnalysis.interactive_viz: Plotly-powered interactive UI.

scAnalysis.sc_io: Native 10x MTX, CSV, and .h5ad read/write support.

🧪 Testing

The package includes a comprehensive suite of unit tests. To run the tests locally:

python -m unittest discover scAnalysis/ -p "test_*.py"

🤝 Contributing

Contributions are welcome! If you find a bug or want to suggest a new feature, please open an issue or submit a pull request.

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

scanalysis-0.1.6.tar.gz (54.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

scanalysis-0.1.6-py3-none-any.whl (67.1 kB view details)

Uploaded Python 3

File details

Details for the file scanalysis-0.1.6.tar.gz.

File metadata

  • Download URL: scanalysis-0.1.6.tar.gz
  • Upload date:
  • Size: 54.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.19

File hashes

Hashes for scanalysis-0.1.6.tar.gz
Algorithm Hash digest
SHA256 10d8c0e5a5c13ca806734798559f721671a60b5757207c88b0555801058982bf
MD5 b46ec98d5d057c263482570b30e47b56
BLAKE2b-256 e234cfaf09018897346bb25fb9cfd6b3f026eb4ea992dd1cc8c7d089733234a8

See more details on using hashes here.

File details

Details for the file scanalysis-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: scanalysis-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 67.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.19

File hashes

Hashes for scanalysis-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 3ebd15660dcf2813961af0cbc8cc4065075c676d8430b719ecf579ebe40d5fbf
MD5 72e62513df8d3e98f0b87572a2207eb9
BLAKE2b-256 f7e110b19e7a5646b5e1883136c426e5b18e89dd019d08de031d5775b5e5608e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page