API for working with ZMAP (Zebrafish Multi-Atlas Project)
Project description
zmap-tools
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):
- Preprocess —
preprocess_adata_query(): TPM normalization + log1p - Embed — Symphony mapping into the ZMAP PCA/Harmony space
- Transfer —
predict_labels_kNN(): distance-weighted kNN voting with per-cell confidence scores - Filter — probability and distance thresholds flag low-confidence assignments
- Summarize —
aggregate_by_cluster(): cluster-level consensus calls with margin statistics - 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4ad4a0fda9bfac71919efdb0be188a9a8122232febfbe5f7921d5cbc0b15b151
|
|
| MD5 |
a2ebdec1429348d4cfc798a32e1c002d
|
|
| BLAKE2b-256 |
1e1523724cf55dba215d30f08ac0a39885a02a47598a83964f2d6c0dcd2088cc
|
Provenance
The following attestation bundles were made for zmap_tools-0.2.0.tar.gz:
Publisher:
pip-publish.yml on WagnerLabUCSF/zmap-tools
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
zmap_tools-0.2.0.tar.gz -
Subject digest:
4ad4a0fda9bfac71919efdb0be188a9a8122232febfbe5f7921d5cbc0b15b151 - Sigstore transparency entry: 1154334065
- Sigstore integration time:
-
Permalink:
WagnerLabUCSF/zmap-tools@07d9dc7b51cf60c7031d923803463c25348ab4ed -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/WagnerLabUCSF
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pip-publish.yml@07d9dc7b51cf60c7031d923803463c25348ab4ed -
Trigger Event:
release
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
10ddf8ec3f97bf229a8112c2cf12ac677619bd0104fda69485d2c1d2d8ce3d72
|
|
| MD5 |
4b46092a60b6ad12ef9e8317876db728
|
|
| BLAKE2b-256 |
b9c61eee851b80449d409e327910510529c8751316aa256b7f1b5b31e4257056
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
zmap_tools-0.2.0-py3-none-any.whl -
Subject digest:
10ddf8ec3f97bf229a8112c2cf12ac677619bd0104fda69485d2c1d2d8ce3d72 - Sigstore transparency entry: 1154334067
- Sigstore integration time:
-
Permalink:
WagnerLabUCSF/zmap-tools@07d9dc7b51cf60c7031d923803463c25348ab4ed -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/WagnerLabUCSF
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pip-publish.yml@07d9dc7b51cf60c7031d923803463c25348ab4ed -
Trigger Event:
release
-
Statement type: