Skip to main content

API for working with ZMAP (Zebrafish Multi-Atlas Project)

Project description

zmap-tools

Documentation PyPI version Python 3.10+

Python API for the Zebrafish Multi-Atlas Project (ZMAP) — a curated single-cell RNA-seq reference atlas for zebrafish development.

zmap-tools provides a simple load → annotate → visualize workflow for transferring cell-type labels from the ZMAP reference to your own datasets.

Installation

pip install zmap-tools

Or from GitHub:

pip install git+https://github.com/WagnerLabUCSF/zmap-tools.git

Quick start

1. Load the reference

import zmap

# Download and cache the ZMAP reference (persists on Google Drive in Colab)
adata_ref = zmap.ref.load_zmap_h5ad()

Available presets: "processed_slim_tpm" (default, best for plotting), "symphony" (required for label transfer), "processed", "processed_slim", "raw".

2. Annotate a query dataset

zmap.predict.annotate_with_zmap(
    adata_query,
    query_raw_counts_source="counts",   # where your raw counts live
    cluster_col="leiden",               # your cluster column
)

This runs the full pipeline — TPM normalization, Symphony embedding, kNN label transfer, QC filtering, and plotting — in one call. Results land in adata_query.obs:

Column Description
ZMAP_CellType_predicted Transferred cell-type label
ZMAP_CellType_predicted_prob kNN vote probability (0–1)
ZMAP_time_id Predicted developmental time (hpf)

3. Visualize

# Two-panel dotplot: gene expression across cell types × timepoints and studies
zmap.dotplot.gene_view(adata_ref, "sox2")

# Sibling comparison: a focal cell type vs. its relatives and tissues
zmap.dotplot.group_view(adata_ref, "hepatocyte")

4. Access consensus markers

# Top markers per cell type as a dict
markers = zmap.ref.load_consensus_markers()

# As a panel DataFrame for dotplot input
panel = zmap.ref.load_consensus_markers(level="Tissue", n_per_group=10, format="panel")

Available levels: "GermLayer", "Tissue", "CellType", "CellTypeFine", "Cluster", "Leiden100".

API overview

Module Purpose Key functions
zmap.ref Reference data load_zmap_h5ad(), load_consensus_markers()
zmap.predict Label transfer annotate_with_zmap(), predict_labels_kNN(), predict_label_tissue_kNN(), aggregate_by_cluster()
zmap.dotplot Visualization gene_view(), group_view(), group_descendants_vs_markers()

Workflow details

Label transfer pipeline

annotate_with_zmap chains these steps (each also callable individually):

  1. Preprocesspreprocess_adata_query(): TPM normalization + log1p
  2. Embed — Symphony mapping into the ZMAP PCA/Harmony space
  3. Transferpredict_labels_kNN(): distance-weighted kNN voting with per-cell confidence scores
  4. Filter — probability and distance thresholds flag low-confidence assignments
  5. Summarizeaggregate_by_cluster(): cluster-level consensus calls with margin statistics
  6. Plot — UMAP overlay with on-data labels + label-overlap heatmaps

Dotplot modules

Gene-centric (gene_view): visualize one gene across all cell types, split by developmental timepoint (left panel) and study (right panel). Assesses both temporal dynamics and cross-study reproducibility.

Group-centric (group_view): given a focal cell type, fetches its consensus markers and plots a two-block dotplot — siblings sharing the same parent in the ZMAP hierarchy (top) and all tissues (bottom). Rows sorted by mean expression; support rings encode cross-study reproducibility.

Descendant drilldown (group_descendants_vs_markers): zoom into a parent group (e.g. a tissue) and show all child clusters with their own marker genes, optionally ordered by dendrogram.

Data access

Reference H5ADs and consensus marker tables are hosted on Cloudflare R2 and downloaded on first use. Files are cached to Google Drive when mounted (/content/drive/MyDrive/zmap/h5ad), so they persist across Colab sessions. On local machines, caching falls back to <cwd>/zmap/h5ad and ~/.cache/zmap_tools.

Dependencies

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

Requires Python ≥ 3.10.

Documentation

Full API reference: zmap-tools.readthedocs.io

Citation

If you use zmap-tools in your work, please cite the ZMAP project (citation forthcoming).

License

See LICENSE.

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

zmap_tools-0.2.0.tar.gz (97.2 kB view details)

Uploaded Source

Built Distribution

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

zmap_tools-0.2.0-py3-none-any.whl (98.9 kB view details)

Uploaded Python 3

File details

Details for the file zmap_tools-0.2.0.tar.gz.

File metadata

  • Download URL: zmap_tools-0.2.0.tar.gz
  • Upload date:
  • Size: 97.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for zmap_tools-0.2.0.tar.gz
Algorithm Hash digest
SHA256 4ad4a0fda9bfac71919efdb0be188a9a8122232febfbe5f7921d5cbc0b15b151
MD5 a2ebdec1429348d4cfc798a32e1c002d
BLAKE2b-256 1e1523724cf55dba215d30f08ac0a39885a02a47598a83964f2d6c0dcd2088cc

See more details on using hashes here.

Provenance

The following attestation bundles were made for zmap_tools-0.2.0.tar.gz:

Publisher: pip-publish.yml on WagnerLabUCSF/zmap-tools

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file zmap_tools-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: zmap_tools-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 98.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for zmap_tools-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 10ddf8ec3f97bf229a8112c2cf12ac677619bd0104fda69485d2c1d2d8ce3d72
MD5 4b46092a60b6ad12ef9e8317876db728
BLAKE2b-256 b9c61eee851b80449d409e327910510529c8751316aa256b7f1b5b31e4257056

See more details on using hashes here.

Provenance

The following attestation bundles were made for zmap_tools-0.2.0-py3-none-any.whl:

Publisher: pip-publish.yml on WagnerLabUCSF/zmap-tools

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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