zmap-tools 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,29 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2025, Daniel Wagner
4
+ All rights reserved.
5
+
6
+ Redistribution and use in source and binary forms, with or without
7
+ modification, are permitted provided that the following conditions are met:
8
+
9
+ 1. Redistributions of source code must retain the above copyright notice,
10
+ this list of conditions and the following disclaimer.
11
+
12
+ 2. Redistributions in binary form must reproduce the above copyright
13
+ notice, this list of conditions and the following disclaimer in the
14
+ documentation and/or other materials provided with the distribution.
15
+
16
+ 3. Neither the name of the copyright holder nor the names of its
17
+ contributors may be used to endorse or promote products derived from
18
+ this software without specific prior written permission.
19
+
20
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,188 @@
1
+ Metadata-Version: 2.4
2
+ Name: zmap-tools
3
+ Version: 0.1.0
4
+ Summary: API for working with ZMAP (Zebrafish Multi-Atlas Project)
5
+ Author-email: Daniel Wagner <Daniel.Wagner@ucsf.edu>
6
+ License: BSD 3-Clause License
7
+
8
+ Copyright (c) 2025, Daniel Wagner
9
+ All rights reserved.
10
+
11
+ Redistribution and use in source and binary forms, with or without
12
+ modification, are permitted provided that the following conditions are met:
13
+
14
+ 1. Redistributions of source code must retain the above copyright notice,
15
+ this list of conditions and the following disclaimer.
16
+
17
+ 2. Redistributions in binary form must reproduce the above copyright
18
+ notice, this list of conditions and the following disclaimer in the
19
+ documentation and/or other materials provided with the distribution.
20
+
21
+ 3. Neither the name of the copyright holder nor the names of its
22
+ contributors may be used to endorse or promote products derived from
23
+ this software without specific prior written permission.
24
+
25
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
29
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
33
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35
+
36
+ Project-URL: Homepage, https://github.com/WagnerLabUCSF/zmap-tools
37
+ Project-URL: Documentation, https://zmap-tools.readthedocs.io
38
+ Project-URL: Issues, https://github.com/WagnerLabUCSF/zmap-tools/issues
39
+ Keywords: single-cell,zebrafish,rna-seq,reference atlas,scanpy
40
+ Classifier: Development Status :: 3 - Alpha
41
+ Classifier: Intended Audience :: Science/Research
42
+ Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
43
+ Classifier: Programming Language :: Python :: 3
44
+ Classifier: Programming Language :: Python :: 3.10
45
+ Classifier: Programming Language :: Python :: 3.11
46
+ Classifier: Programming Language :: Python :: 3.12
47
+ Requires-Python: >=3.10
48
+ Description-Content-Type: text/markdown
49
+ License-File: LICENSE
50
+ Requires-Dist: anndata>=0.10
51
+ Requires-Dist: scanpy>=1.9
52
+ Requires-Dist: numpy>=1.24
53
+ Requires-Dist: pandas>=2.0
54
+ Requires-Dist: matplotlib>=3.7
55
+ Requires-Dist: requests>=2.31
56
+ Requires-Dist: scipy>=1.10
57
+ Requires-Dist: scikit-learn>=1.3
58
+ Requires-Dist: seaborn>=0.12
59
+ Requires-Dist: tqdm>=4.66
60
+ Requires-Dist: adjustText>=0.8
61
+ Requires-Dist: symphonypy>=0.2
62
+ Dynamic: license-file
63
+
64
+ # zmap-tools
65
+
66
+ [![Documentation](https://readthedocs.org/projects/zmap-tools/badge/?version=latest)](https://zmap-tools.readthedocs.io)
67
+ [![PyPI version](https://img.shields.io/pypi/v/zmap-tools.svg)](https://pypi.org/project/zmap-tools/)
68
+ [![Python 3.10+](https://img.shields.io/badge/python-3.10%2B-blue.svg)](https://www.python.org/downloads/)
69
+
70
+ Python API for the **Zebrafish Multi-Atlas Project (ZMAP)** — a curated single-cell RNA-seq reference atlas for zebrafish development.
71
+
72
+ `zmap-tools` provides a simple **load → annotate → visualize** workflow for transferring cell-type labels from the ZMAP reference to your own datasets.
73
+
74
+ ## Installation
75
+
76
+ ```bash
77
+ pip install zmap-tools
78
+ ```
79
+
80
+ Or from GitHub:
81
+
82
+ ```bash
83
+ pip install git+https://github.com/WagnerLabUCSF/zmap-tools.git
84
+ ```
85
+
86
+ ## Quick start
87
+
88
+ ### 1. Load the reference
89
+
90
+ ```python
91
+ import zmap
92
+
93
+ # Download and cache the ZMAP reference (persists on Google Drive in Colab)
94
+ adata_ref = zmap.ref.load_zmap_h5ad()
95
+ ```
96
+
97
+ Available presets: `"processed_slim_tpm"` (default, best for plotting), `"symphony"` (required for label transfer), `"processed"`, `"processed_slim"`, `"raw"`.
98
+
99
+ ### 2. Annotate a query dataset
100
+
101
+ ```python
102
+ zmap.predict.annotate_with_zmap(
103
+ adata_query,
104
+ query_raw_counts_source="counts", # where your raw counts live
105
+ cluster_col="leiden", # your cluster column
106
+ )
107
+ ```
108
+
109
+ 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`:
110
+
111
+ | Column | Description |
112
+ |---|---|
113
+ | `ZMAP_CellType_predicted` | Transferred cell-type label |
114
+ | `ZMAP_CellType_predicted_prob` | kNN vote probability (0–1) |
115
+ | `ZMAP_time_id` | Predicted developmental time (hpf) |
116
+
117
+ ### 3. Visualize
118
+
119
+ ```python
120
+ # Two-panel dotplot: gene expression across cell types × timepoints and studies
121
+ zmap.dotplot.gene_view(adata_ref, "sox2")
122
+
123
+ # Sibling comparison: a focal cell type vs. its relatives and tissues
124
+ zmap.dotplot.group_view(adata_ref, "hepatocyte")
125
+ ```
126
+
127
+ ### 4. Access consensus markers
128
+
129
+ ```python
130
+ # Top markers per cell type as a dict
131
+ markers = zmap.ref.load_consensus_markers()
132
+
133
+ # As a panel DataFrame for dotplot input
134
+ panel = zmap.ref.load_consensus_markers(level="Tissue", n_per_group=10, format="panel")
135
+ ```
136
+
137
+ Available levels: `"GermLayer"`, `"Tissue"`, `"CellType"`, `"CellTypeFine"`, `"Cluster"`, `"Leiden100"`.
138
+
139
+ ## API overview
140
+
141
+ | Module | Purpose | Key functions |
142
+ |---|---|---|
143
+ | `zmap.ref` | Reference data | `load_zmap_h5ad()`, `load_consensus_markers()` |
144
+ | `zmap.predict` | Label transfer | `annotate_with_zmap()`, `predict_labels_kNN()`, `aggregate_by_cluster()` |
145
+ | `zmap.dotplot` | Visualization | `gene_view()`, `group_view()`, `group_descendants_vs_markers()` |
146
+
147
+ ## Workflow details
148
+
149
+ ### Label transfer pipeline
150
+
151
+ `annotate_with_zmap` chains these steps (each also callable individually):
152
+
153
+ 1. **Preprocess** — `preprocess_adata_query()`: TPM normalization + log1p
154
+ 2. **Embed** — Symphony mapping into the ZMAP PCA/Harmony space
155
+ 3. **Transfer** — `predict_labels_kNN()`: distance-weighted kNN voting with per-cell confidence scores
156
+ 4. **Filter** — probability and distance thresholds flag low-confidence assignments
157
+ 5. **Summarize** — `aggregate_by_cluster()`: cluster-level consensus calls with margin statistics
158
+ 6. **Plot** — UMAP overlay with on-data labels + label-overlap heatmaps
159
+
160
+ ### Dotplot modules
161
+
162
+ **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.
163
+
164
+ **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.
165
+
166
+ **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.
167
+
168
+ ## Data access
169
+
170
+ 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`.
171
+
172
+ ## Dependencies
173
+
174
+ Core: `anndata`, `scanpy`, `numpy`, `pandas`, `matplotlib`, `scipy`, `scikit-learn`, `seaborn`, `tqdm`, `adjustText`, `symphonypy`
175
+
176
+ Requires Python ≥ 3.10.
177
+
178
+ ## Documentation
179
+
180
+ Full API reference: [zmap-tools.readthedocs.io](https://zmap-tools.readthedocs.io)
181
+
182
+ ## Citation
183
+
184
+ If you use `zmap-tools` in your work, please cite the ZMAP project (citation forthcoming).
185
+
186
+ ## License
187
+
188
+ See [LICENSE](LICENSE).
@@ -0,0 +1,125 @@
1
+ # zmap-tools
2
+
3
+ [![Documentation](https://readthedocs.org/projects/zmap-tools/badge/?version=latest)](https://zmap-tools.readthedocs.io)
4
+ [![PyPI version](https://img.shields.io/pypi/v/zmap-tools.svg)](https://pypi.org/project/zmap-tools/)
5
+ [![Python 3.10+](https://img.shields.io/badge/python-3.10%2B-blue.svg)](https://www.python.org/downloads/)
6
+
7
+ Python API for the **Zebrafish Multi-Atlas Project (ZMAP)** — a curated single-cell RNA-seq reference atlas for zebrafish development.
8
+
9
+ `zmap-tools` provides a simple **load → annotate → visualize** workflow for transferring cell-type labels from the ZMAP reference to your own datasets.
10
+
11
+ ## Installation
12
+
13
+ ```bash
14
+ pip install zmap-tools
15
+ ```
16
+
17
+ Or from GitHub:
18
+
19
+ ```bash
20
+ pip install git+https://github.com/WagnerLabUCSF/zmap-tools.git
21
+ ```
22
+
23
+ ## Quick start
24
+
25
+ ### 1. Load the reference
26
+
27
+ ```python
28
+ import zmap
29
+
30
+ # Download and cache the ZMAP reference (persists on Google Drive in Colab)
31
+ adata_ref = zmap.ref.load_zmap_h5ad()
32
+ ```
33
+
34
+ Available presets: `"processed_slim_tpm"` (default, best for plotting), `"symphony"` (required for label transfer), `"processed"`, `"processed_slim"`, `"raw"`.
35
+
36
+ ### 2. Annotate a query dataset
37
+
38
+ ```python
39
+ zmap.predict.annotate_with_zmap(
40
+ adata_query,
41
+ query_raw_counts_source="counts", # where your raw counts live
42
+ cluster_col="leiden", # your cluster column
43
+ )
44
+ ```
45
+
46
+ 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`:
47
+
48
+ | Column | Description |
49
+ |---|---|
50
+ | `ZMAP_CellType_predicted` | Transferred cell-type label |
51
+ | `ZMAP_CellType_predicted_prob` | kNN vote probability (0–1) |
52
+ | `ZMAP_time_id` | Predicted developmental time (hpf) |
53
+
54
+ ### 3. Visualize
55
+
56
+ ```python
57
+ # Two-panel dotplot: gene expression across cell types × timepoints and studies
58
+ zmap.dotplot.gene_view(adata_ref, "sox2")
59
+
60
+ # Sibling comparison: a focal cell type vs. its relatives and tissues
61
+ zmap.dotplot.group_view(adata_ref, "hepatocyte")
62
+ ```
63
+
64
+ ### 4. Access consensus markers
65
+
66
+ ```python
67
+ # Top markers per cell type as a dict
68
+ markers = zmap.ref.load_consensus_markers()
69
+
70
+ # As a panel DataFrame for dotplot input
71
+ panel = zmap.ref.load_consensus_markers(level="Tissue", n_per_group=10, format="panel")
72
+ ```
73
+
74
+ Available levels: `"GermLayer"`, `"Tissue"`, `"CellType"`, `"CellTypeFine"`, `"Cluster"`, `"Leiden100"`.
75
+
76
+ ## API overview
77
+
78
+ | Module | Purpose | Key functions |
79
+ |---|---|---|
80
+ | `zmap.ref` | Reference data | `load_zmap_h5ad()`, `load_consensus_markers()` |
81
+ | `zmap.predict` | Label transfer | `annotate_with_zmap()`, `predict_labels_kNN()`, `aggregate_by_cluster()` |
82
+ | `zmap.dotplot` | Visualization | `gene_view()`, `group_view()`, `group_descendants_vs_markers()` |
83
+
84
+ ## Workflow details
85
+
86
+ ### Label transfer pipeline
87
+
88
+ `annotate_with_zmap` chains these steps (each also callable individually):
89
+
90
+ 1. **Preprocess** — `preprocess_adata_query()`: TPM normalization + log1p
91
+ 2. **Embed** — Symphony mapping into the ZMAP PCA/Harmony space
92
+ 3. **Transfer** — `predict_labels_kNN()`: distance-weighted kNN voting with per-cell confidence scores
93
+ 4. **Filter** — probability and distance thresholds flag low-confidence assignments
94
+ 5. **Summarize** — `aggregate_by_cluster()`: cluster-level consensus calls with margin statistics
95
+ 6. **Plot** — UMAP overlay with on-data labels + label-overlap heatmaps
96
+
97
+ ### Dotplot modules
98
+
99
+ **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.
100
+
101
+ **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.
102
+
103
+ **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.
104
+
105
+ ## Data access
106
+
107
+ 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`.
108
+
109
+ ## Dependencies
110
+
111
+ Core: `anndata`, `scanpy`, `numpy`, `pandas`, `matplotlib`, `scipy`, `scikit-learn`, `seaborn`, `tqdm`, `adjustText`, `symphonypy`
112
+
113
+ Requires Python ≥ 3.10.
114
+
115
+ ## Documentation
116
+
117
+ Full API reference: [zmap-tools.readthedocs.io](https://zmap-tools.readthedocs.io)
118
+
119
+ ## Citation
120
+
121
+ If you use `zmap-tools` in your work, please cite the ZMAP project (citation forthcoming).
122
+
123
+ ## License
124
+
125
+ See [LICENSE](LICENSE).
@@ -0,0 +1,53 @@
1
+ [build-system]
2
+ requires = ["setuptools>=64", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "zmap-tools"
7
+ version = "0.1.0"
8
+ description = "API for working with ZMAP (Zebrafish Multi-Atlas Project)"
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = { file = "LICENSE" }
12
+
13
+ authors = [
14
+ { name = "Daniel Wagner", email = "Daniel.Wagner@ucsf.edu" }
15
+ ]
16
+
17
+ keywords = ["single-cell", "zebrafish", "rna-seq", "reference atlas", "scanpy"]
18
+
19
+ classifiers = [
20
+ "Development Status :: 3 - Alpha",
21
+ "Intended Audience :: Science/Research",
22
+ "Topic :: Scientific/Engineering :: Bio-Informatics",
23
+ "Programming Language :: Python :: 3",
24
+ "Programming Language :: Python :: 3.10",
25
+ "Programming Language :: Python :: 3.11",
26
+ "Programming Language :: Python :: 3.12",
27
+ ]
28
+
29
+ dependencies = [
30
+ "anndata>=0.10",
31
+ "scanpy>=1.9",
32
+ "numpy>=1.24",
33
+ "pandas>=2.0",
34
+ "matplotlib>=3.7",
35
+ "requests>=2.31",
36
+ "scipy>=1.10",
37
+ "scikit-learn>=1.3",
38
+ "seaborn>=0.12",
39
+ "tqdm>=4.66",
40
+ "adjustText>=0.8",
41
+ "symphonypy>=0.2",
42
+ ]
43
+
44
+ [project.urls]
45
+ Homepage = "https://github.com/WagnerLabUCSF/zmap-tools"
46
+ Documentation = "https://zmap-tools.readthedocs.io"
47
+ Issues = "https://github.com/WagnerLabUCSF/zmap-tools/issues"
48
+
49
+ [tool.setuptools]
50
+ package-dir = {"" = "src"}
51
+
52
+ [tool.setuptools.packages.find]
53
+ where = ["src"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,36 @@
1
+ from __future__ import annotations
2
+
3
+ """
4
+ zmap-tools — Python API for the Zebrafish Multi-Atlas Project (ZMAP).
5
+
6
+ A curated single-cell RNA-seq reference atlas for zebrafish development,
7
+ with tools for reference loading, label transfer, and visualization.
8
+
9
+ Submodules
10
+ ----------
11
+ reference (aliased as ref)
12
+ Download, cache, and load ZMAP reference H5ADs and consensus markers.
13
+ predict
14
+ kNN-based label transfer from the ZMAP reference to query datasets.
15
+ dotplot
16
+ Publication-ready dotplot visualization of gene expression patterns.
17
+ """
18
+
19
+ from importlib.metadata import PackageNotFoundError, version as _version
20
+
21
+ # Package version (from the PyPI/dist name)
22
+ try:
23
+ __version__ = _version("zmap-tools")
24
+ except PackageNotFoundError:
25
+ __version__ = "0.0.0"
26
+
27
+ # Import subpackages as attributes
28
+ from . import reference # zmap.reference
29
+ from . import dotplot # zmap.dotplot
30
+ from . import predict # zmap.predict
31
+
32
+ # Scanpy-style aliases:
33
+ ref = reference
34
+
35
+
36
+ __all__ = ["__version__", "ref", "dotplot", "predict"]
@@ -0,0 +1,26 @@
1
+ from __future__ import annotations
2
+
3
+ """
4
+ Dotplot visualization for ZMAP reference data.
5
+
6
+ Provides gene-centric dotplots (expression across cell types × timepoints
7
+ and studies) and group-centric dotplots (marker genes for a focal cell type
8
+ compared to its siblings and tissues).
9
+
10
+ Convenience aliases:
11
+
12
+ - ``gene_view`` → :func:`gene_groups_vs_time_and_studies`
13
+ - ``group_view`` → :func:`group_siblings_vs_markers`
14
+ """
15
+
16
+ from .dotplot_gene import gene_groups_vs_time_and_studies
17
+ from .dotplot_group import group_siblings_vs_markers, group_descendants_vs_markers
18
+
19
+ gene_view = gene_groups_vs_time_and_studies
20
+ group_view = group_siblings_vs_markers
21
+
22
+ __all__ = ["gene_groups_vs_time_and_studies",
23
+ "group_siblings_vs_markers",
24
+ "group_descendants_vs_markers",
25
+ "gene_view",
26
+ "group_view"]