Skip to main content

Subjacent Analysis Toolkits for Single-Cell Omics in Python

Project description

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

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

sjanpy-0.0.1.tar.gz (36.1 kB view details)

Uploaded Source

Built Distribution

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

sjanpy-0.0.1-py3-none-any.whl (37.7 kB view details)

Uploaded Python 3

File details

Details for the file sjanpy-0.0.1.tar.gz.

File metadata

  • Download URL: sjanpy-0.0.1.tar.gz
  • Upload date:
  • Size: 36.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.1

File hashes

Hashes for sjanpy-0.0.1.tar.gz
Algorithm Hash digest
SHA256 6b1d5409224a2ebf59288a10b1521f921976c8c05a5744ed59ff4e7d9abf57c6
MD5 366d9a5e7d7de351715ee8bfdf18e823
BLAKE2b-256 e2643c463afd8167b9200872d979a41b0d9e1343912742f5ca4e719a50d5e9c2

See more details on using hashes here.

File details

Details for the file sjanpy-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: sjanpy-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 37.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.1

File hashes

Hashes for sjanpy-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 23c68a1a5a098afa52cb6d8f83cf5a1ae22435560ea1292e71563a84cce1a64f
MD5 20a0f27c8b7e6479b6df0f23c945b05b
BLAKE2b-256 095c3dd5a4072739d7387ab8829d9f52a738271f0d77dc850714599a602811c7

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