Skip to main content

sjanpy

Python License: MIT

Subjacent Analysis Toolkits for Single-Cell Omics in Python

sjanpy extends the Scanpy / AnnData ecosystem with publication-quality visualizations, fast differential expression analysis, and preprocessing utilities for single-cell RNA-seq.

Package Structure

sjanpy follows the Scanpy subpackage convention:

Subpackage Purpose Key Functions
sjanpy.pl Plotting Embedding, dot plot, bar plot, volcano plot, Nebulosa density
sjanpy.tl Tools Differential expression, Pearson residuals normalization
sjanpy.pp Preprocessing Organism-specific gene filtering (human, mouse, rat)
sjanpy.ml Machine Learning Chunked .pt dataset builder from h5ad files

Installation

git clone https://github.com/chansigit/sjanpy.git
cd sjanpy
pip install .

Quick Start

Embedding visualization

import scanpy as sc
from sjanpy.pl import fancy_embedding_pro

adata = sc.datasets.pbmc3k_processed()
fancy_embedding_pro(adata, basis='umap', color='louvain')

Differential expression

from sjanpy.tl import fast_two_group_deg
from sjanpy.pl import plot_volcano

deg = fast_two_group_deg(adata, label_col='louvain', lst1=['B cells'], lst2=['CD4 T cells'])
plot_volcano(deg, logfc_col='log2FC', padj_col='padj')

Nebulosa density

Traditional scatter plots obscure gene expression patterns due to point overlap. Nebulosa uses weighted kernel density estimation to reveal true expression distributions:

from sjanpy.pl import nebulosa_density

nebulosa_density(adata, coord_key='X_umap', gene='CD3D', show=True)
Standard scatter Nebulosa density
before after

Gene filtering

from sjanpy.pp import filter_human_sc_genes

# Mask artifact genes from HVG selection (predicted, non-coding, IG variable, etc.)
adata = filter_human_sc_genes(adata, mask_hvg_only=True)

Complex dot plot

from sjanpy.pl import complex_dotplot

complex_dotplot(
    adata,
    genes=marker_genes,
    groupby='cell_type',
    z_score=True,
    cluster_rows=True,
    cmap='RdBu_r',
)

Module Reference

sjanpy.pl — Plotting

Function Description
fancy_embedding_pro UMAP/t-SNE with density overlays, auto-labels, equal-aspect axes
complex_dotplot Dot plot with hierarchical clustering and dendrograms
fan_dotplot Polar/radial dot plot layout
plot_stacked_bar_repel Stacked bar plot with smart label placement
plot_volcano Volcano plot for DEG visualization
plot_cluster_deg_jitter_highlight Per-cluster jitter plot with gene annotations
nebulosa_density Weighted KDE density on embeddings
wkde2d / wkde3d Low-level 2D/3D weighted kernel density estimation

sjanpy.tl — Tools

Function / Class Description
fast_two_group_deg Vectorized Welch's t-test DEG between two groups
compute_nested_deg_df Within-cluster DEG between two conditions
clip_logfc_in_nested_deg_df Per-cluster quantile clipping of logFC
generate_highlight_dict Select genes to label (top-N, k-times, manual)
PearsonResidualsScaler NB-based Pearson residuals normalization

sjanpy.pp — Preprocessing

Function Description
filter_human_sc_genes Remove/mask artifact genes (human)
filter_mouse_sc_genes Remove/mask artifact genes (mouse)
filter_rat_sc_genes Remove/mask artifact genes (rat)
get_background_gene_dict Catalog artifact gene categories in a dataset

sjanpy.ml — Machine Learning

Function Description
build_dataset Stream h5ad → chunked .pt files with condition vectors
build_condition_schema Build encoding schema from condition DSL specs
process_file Process a single h5ad file into chunks

Dependencies

Core: numpy, pandas, scipy, matplotlib, seaborn, scanpy, anndata, adjustText, statsmodels, scikit-learn

Optional: plotly (3D visualization), torch / h5py (ML dataset building)

License

MIT

Metadata

Release files for sjanpy 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sjanpy 0.0.1
File Size Uploaded Provenance
sjanpy-0.0.1.tar.gz 36.1 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for sjanpy 0.0.1
File Interpreter ABI Platform
sjanpy-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 73.8 kB

Release files / sjanpy-0.0.1.tar.gz

Download URL sjanpy-0.0.1.tar.gz
Size 36.1 kB
Tags Source
SHA-256 checksum
How to use checksums
6b1d5409224a2ebf59288a10b1521f921976c8c05a5744ed59ff4e7d9abf57c6
BLAKE2b-256 checksum
How to use checksums
e2643c463afd8167b9200872d979a41b0d9e1343912742f5ca4e719a50d5e9c2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.1

Release files / sjanpy-0.0.1-py3-none-any.whl

Download URL sjanpy-0.0.1-py3-none-any.whl
Size 37.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
23c68a1a5a098afa52cb6d8f83cf5a1ae22435560ea1292e71563a84cce1a64f
BLAKE2b-256 checksum
How to use checksums
095c3dd5a4072739d7387ab8829d9f52a738271f0d77dc850714599a602811c7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.1

Security for sjanpy 0.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page