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.1.tar.gz (98.0 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.1-py3-none-any.whl (99.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: zmap_tools-0.2.1.tar.gz
  • Upload date:
  • Size: 98.0 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.1.tar.gz
Algorithm Hash digest
SHA256 1f12be92ddb51be1ad0efcefc59c70c760b029e65ba78cfc4763b3f7b81088f1
MD5 6ef5883942b019615d7570063bf9eb2d
BLAKE2b-256 d67ea9fb236dd810455b6f04ed85bb7134746295427fc397b5c150a74e144f7f

See more details on using hashes here.

Provenance

The following attestation bundles were made for zmap_tools-0.2.1.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.1-py3-none-any.whl.

File metadata

  • Download URL: zmap_tools-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 99.7 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 50ef863920f11a702088507822c0c41a6fe80c60b772e2eacd4f6eb1afadd149
MD5 0742f99a31d2289f3f89ab7013e629e1
BLAKE2b-256 57562f9708ba6e5ca0e5cb94bbbebdbda450384d1388c0a0ed191f88bdf4c359

See more details on using hashes here.

Provenance

The following attestation bundles were made for zmap_tools-0.2.1-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