cellmapper 0.0.1__tar.gz → 0.1.2__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.
Files changed (55) hide show
  1. {cellmapper-0.0.1 → cellmapper-0.1.2}/.gitignore +4 -0
  2. {cellmapper-0.0.1 → cellmapper-0.1.2}/.readthedocs.yaml +1 -1
  3. cellmapper-0.1.2/CHANGELOG.md +31 -0
  4. {cellmapper-0.0.1 → cellmapper-0.1.2}/LICENSE +1 -1
  5. {cellmapper-0.0.1 → cellmapper-0.1.2}/PKG-INFO +53 -18
  6. cellmapper-0.1.2/README.md +89 -0
  7. cellmapper-0.1.2/docs/api.md +25 -0
  8. {cellmapper-0.0.1 → cellmapper-0.1.2}/docs/conf.py +8 -0
  9. {cellmapper-0.0.1 → cellmapper-0.1.2}/docs/contributing.md +1 -2
  10. {cellmapper-0.0.1 → cellmapper-0.1.2}/docs/index.md +1 -1
  11. cellmapper-0.1.2/docs/notebooks/tutorials/index.rst +9 -0
  12. cellmapper-0.1.2/docs/notebooks/tutorials/spatial_mapping.ipynb +950 -0
  13. cellmapper-0.1.2/docs/references.bib +130 -0
  14. {cellmapper-0.0.1 → cellmapper-0.1.2}/pyproject.toml +11 -2
  15. {cellmapper-0.0.1 → cellmapper-0.1.2}/src/cellmapper/__init__.py +2 -1
  16. {cellmapper-0.0.1 → cellmapper-0.1.2}/src/cellmapper/cellmapper.py +44 -29
  17. {cellmapper-0.0.1 → cellmapper-0.1.2}/src/cellmapper/check.py +2 -0
  18. cellmapper-0.1.2/src/cellmapper/evaluate.py +457 -0
  19. {cellmapper-0.0.1 → cellmapper-0.1.2}/src/cellmapper/knn.py +17 -2
  20. {cellmapper-0.0.1 → cellmapper-0.1.2}/tests/conftest.py +7 -3
  21. {cellmapper-0.0.1 → cellmapper-0.1.2}/tests/test_cellmapper.py +47 -9
  22. cellmapper-0.1.2/tests/test_check.py +34 -0
  23. cellmapper-0.1.2/tests/test_evaluate.py +50 -0
  24. {cellmapper-0.0.1 → cellmapper-0.1.2}/tests/test_neighbors.py +16 -5
  25. cellmapper-0.0.1/CHANGELOG.md +0 -14
  26. cellmapper-0.0.1/README.md +0 -58
  27. cellmapper-0.0.1/docs/api.md +0 -39
  28. cellmapper-0.0.1/docs/notebooks/example.ipynb +0 -171
  29. cellmapper-0.0.1/docs/references.bib +0 -10
  30. cellmapper-0.0.1/src/cellmapper/evaluate.py +0 -323
  31. {cellmapper-0.0.1 → cellmapper-0.1.2}/.codecov.yaml +0 -0
  32. {cellmapper-0.0.1 → cellmapper-0.1.2}/.cruft.json +0 -0
  33. {cellmapper-0.0.1 → cellmapper-0.1.2}/.editorconfig +0 -0
  34. {cellmapper-0.0.1 → cellmapper-0.1.2}/.github/ISSUE_TEMPLATE/bug_report.yml +0 -0
  35. {cellmapper-0.0.1 → cellmapper-0.1.2}/.github/ISSUE_TEMPLATE/config.yml +0 -0
  36. {cellmapper-0.0.1 → cellmapper-0.1.2}/.github/ISSUE_TEMPLATE/feature_request.yml +0 -0
  37. {cellmapper-0.0.1 → cellmapper-0.1.2}/.github/workflows/build.yaml +0 -0
  38. {cellmapper-0.0.1 → cellmapper-0.1.2}/.github/workflows/release.yaml +0 -0
  39. {cellmapper-0.0.1 → cellmapper-0.1.2}/.github/workflows/test.yaml +0 -0
  40. {cellmapper-0.0.1 → cellmapper-0.1.2}/.pre-commit-config.yaml +0 -0
  41. {cellmapper-0.0.1 → cellmapper-0.1.2}/.vscode/extensions.json +0 -0
  42. {cellmapper-0.0.1 → cellmapper-0.1.2}/.vscode/launch.json +0 -0
  43. {cellmapper-0.0.1 → cellmapper-0.1.2}/.vscode/settings.json +0 -0
  44. {cellmapper-0.0.1 → cellmapper-0.1.2}/biome.jsonc +0 -0
  45. {cellmapper-0.0.1 → cellmapper-0.1.2}/docs/_static/.gitkeep +0 -0
  46. {cellmapper-0.0.1 → cellmapper-0.1.2}/docs/_static/css/custom.css +0 -0
  47. {cellmapper-0.0.1 → cellmapper-0.1.2}/docs/_templates/.gitkeep +0 -0
  48. {cellmapper-0.0.1 → cellmapper-0.1.2}/docs/_templates/autosummary/class.rst +0 -0
  49. {cellmapper-0.0.1 → cellmapper-0.1.2}/docs/changelog.md +0 -0
  50. {cellmapper-0.0.1 → cellmapper-0.1.2}/docs/extensions/typed_returns.py +0 -0
  51. {cellmapper-0.0.1 → cellmapper-0.1.2}/docs/references.md +0 -0
  52. {cellmapper-0.0.1 → cellmapper-0.1.2}/src/cellmapper/logging.py +0 -0
  53. {cellmapper-0.0.1 → cellmapper-0.1.2}/tests/data/precomputed_leiden.csv +0 -0
  54. {cellmapper-0.0.1 → cellmapper-0.1.2}/tests/test_basic.py +0 -0
  55. {cellmapper-0.0.1 → cellmapper-0.1.2}/tests/test_neighbors_results.py +0 -0
@@ -18,3 +18,7 @@ __pycache__/
18
18
  # docs
19
19
  /docs/generated/
20
20
  /docs/_build/
21
+ .ipynb_checkpoints/
22
+
23
+ # datasets
24
+ *.h5ad
@@ -7,7 +7,7 @@ build:
7
7
  sphinx:
8
8
  configuration: docs/conf.py
9
9
  # disable this for more lenient docs builds
10
- fail_on_warning: true
10
+ fail_on_warning: false
11
11
  python:
12
12
  install:
13
13
  - method: pip
@@ -0,0 +1,31 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog][],
6
+ and this project adheres to [Semantic Versioning][].
7
+
8
+ [keep a changelog]: https://keepachangelog.com/en/1.0.0/
9
+ [semantic versioning]: https://semver.org/spec/v2.0.0.html
10
+
11
+ ## [Unreleased]
12
+
13
+ ## [v0.1.2]
14
+
15
+ ### Added
16
+ - Included tests for the `check` module, and more tests for the main classes {pr}`15`.
17
+ - Implemented the computation of presence scores, following HNOCA-tools {pr}`16`.
18
+ - Add a `groupby` parameter to expression transfer evaluation {pr}`16`.
19
+ - Add a `test_var_key` parameter to expression transfer evaluation {pr}`19`.
20
+ - Add a tutorial on spatial mapping {pr}`19`.
21
+
22
+ ## [v0.1.1]
23
+
24
+ ### Changed
25
+ - Switched to `vcs`-based versioning {pr}`5`.
26
+
27
+ ### Added
28
+ - Added PyPI badge.
29
+
30
+ ## [v0.1.0]
31
+ Initial package release.
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2025, Marius Lange
3
+ Copyright (c) 2025, QuaDBioLab
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cellmapper
3
- Version: 0.0.1
3
+ Version: 0.1.2
4
4
  Summary: k-NN-based mapping of cells across representations
5
5
  Project-URL: Documentation, https://cellmapper.readthedocs.io/
6
6
  Project-URL: Homepage, https://github.com/quadbio/cellmapper
@@ -9,7 +9,7 @@ Author: Marius Lange
9
9
  Maintainer-email: Marius Lange <marius.lange@bsse.ethz.ch>
10
10
  License: MIT License
11
11
 
12
- Copyright (c) 2025, Marius Lange
12
+ Copyright (c) 2025, QuaDBioLab
13
13
 
14
14
  Permission is hereby granted, free of charge, to any person obtaining a copy
15
15
  of this software and associated documentation files (the "Software"), to deal
@@ -65,6 +65,10 @@ Requires-Dist: sphinxext-opengraph; extra == 'doc'
65
65
  Provides-Extra: test
66
66
  Requires-Dist: coverage; extra == 'test'
67
67
  Requires-Dist: pytest; extra == 'test'
68
+ Provides-Extra: tutorials
69
+ Requires-Dist: harmony-pytorch; extra == 'tutorials'
70
+ Requires-Dist: seaborn; extra == 'tutorials'
71
+ Requires-Dist: squidpy; extra == 'tutorials'
68
72
  Description-Content-Type: text/markdown
69
73
 
70
74
  # CellMapper
@@ -72,39 +76,55 @@ Description-Content-Type: text/markdown
72
76
  [![Tests][badge-tests]][tests]
73
77
  [![Coverage][badge-coverage]][coverage]
74
78
  [![Pre-commit.ci][badge-pre-commit]][pre-commit]
79
+ [![PyPI][badge-pypi]][pypi]
80
+ [![Documentation][badge-docs]][docs]
75
81
 
76
82
  [badge-tests]: https://github.com/quadbio/cellmapper/actions/workflows/test.yaml/badge.svg
77
83
  [badge-coverage]: https://codecov.io/gh/quadbio/cellmapper/branch/main/graph/badge.svg
78
84
  [badge-pre-commit]: https://results.pre-commit.ci/badge/github/quadbio/cellmapper/main.svg
85
+ [badge-pypi]: https://img.shields.io/pypi/v/cellmapper.svg
86
+ [badge-docs]: https://img.shields.io/readthedocs/cellmapper
79
87
 
80
- k-NN-based mapping of cells across representations to tranfer labels, embeddings and expression values. Works for millions of cells, on CPU and GPU, across molecular modalities, between spatial and non-spatial data, for arbitrary query and reference datasets. Using `faiss` to compute k-NN graphs, CellMapper takes about 30 seconds to transfer cell type labels from 1.5M cells to 1.5M cells on a single RTX 4090 with 60 GB CPU memory.
88
+ k-NN-based mapping of cells across representations to tranfer labels, embeddings and expression values. Works for millions of cells, on CPU and GPU, across molecular modalities, between spatial and non-spatial data, for arbitrary query and reference datasets. Using [faiss][] to compute k-NN graphs, CellMapper takes about 30 seconds to transfer cell type labels from 1.5M cells to 1.5M cells on a single RTX 4090 with 60 GB CPU memory.
81
89
 
82
- ## Getting started
83
-
84
- Please refer to the [documentation][],
85
- in particular, the [API documentation][].
90
+ Inspired by scanpy's [ingest][] and the [HNOCA-tools][] packages. Check out the [docs][] to learn more, in particular our [tutorials][].
86
91
 
87
92
  ## Installation
88
93
 
89
94
  You need to have Python 3.10 or newer installed on your system.
90
95
  If you don't have Python installed, we recommend installing [uv][].
91
96
 
92
- There are several alternative options to install cellmapper:
97
+ There are two alternative options to install ``cellmapper``:
93
98
 
94
- <!--
95
- 1) Install the latest release of `cellmapper` from [PyPI][]:
99
+ - Install the latest release from [PyPI][]:
96
100
 
97
- ```bash
98
- pip install cellmapper
99
- ```
100
- -->
101
+ ```bash
102
+ pip install cellmapper
103
+ ```
104
+
105
+ - Install the latest development version:
106
+
107
+ ```bash
108
+ pip install git+https://github.com/quadbio/cellmapper.git@main
109
+ ```
101
110
 
102
- 1. Install the latest development version:
111
+ ## Getting started
112
+
113
+ This package assumes that you have ``ref`` and ``query`` AnnData objects, with a joint embedding computed and stored in ``.obsm``. We explicilty do not compute this joint embedding, but there are plenty of method you can use to get such joint embeddings, e.g. [GimVI][] or [ENVI][] for spatial mapping, [GLUE][], [MIDAS][] and [MOFA+][] for modality translation, and [scVI][], [scANVI][] and [scArches][] for query-to-reference mapping - this is just a small selection!
114
+
115
+ With a joint embedding in ``.obsm["X_joint"]`` at hand, the simplest way to use ``CellMapper`` is as follows:
116
+ ```Python
117
+ from cellmapper import CellMapper
103
118
 
104
- ```bash
105
- pip install git+https://github.com/quadbio/cellmapper.git@main
119
+ cmap = CellMapper(ref, query).fit(
120
+ use_rep="X_joint", obs_keys="celltype", obsm_keys="X_umap", layer_key="X"
121
+ )
106
122
  ```
107
123
 
124
+ This will transfer data from the reference to the query dataset, including celltype labels stored in ``ref.obs``, a UMAP embedding stored in ``ref.obsm``, and expression values stored in ``ref.X``.
125
+
126
+ There are many ways to customize this, e.g. use different ways to compute k-NN graphs and to turn them into mapping matrices, and we implement a few methods to evaluate whether your k-NN transfer was sucessful. Check out the [docs][] to learn more.
127
+
108
128
  ## Release notes
109
129
 
110
130
  See the [changelog][].
@@ -121,7 +141,22 @@ Please cite this GitHub repo if you find CellMapper useful for your research.
121
141
  [issue tracker]: https://github.com/quadbio/cellmapper/issues
122
142
  [tests]: https://github.com/quadbio/cellmapper/actions/workflows/test.yaml
123
143
  [changelog]: https://cellmapper.readthedocs.io/en/latest/changelog.html
124
- [api documentation]: https://cellmapper.readthedocs.io/en/latest/api.html
144
+ [docs]: https://cellmapper.readthedocs.io/
145
+ [tutorials]: https://cellmapper.readthedocs.io/en/latest/notebooks/tutorials/index.html
125
146
  [pypi]: https://pypi.org/project/cellmapper
126
147
  [coverage]: https://codecov.io/gh/quadbio/cellmapper
127
148
  [pre-commit]: https://results.pre-commit.ci/latest/github/quadbio/cellmapper/main
149
+ [pypi]: https://pypi.org/project/cellmapper/
150
+ [faiss]: https://github.com/facebookresearch/faiss
151
+
152
+ [ingest]: https://scanpy.readthedocs.io/en/stable/generated/scanpy.tl.ingest.html
153
+ [HNOCA-tools]: https://devsystemslab.github.io/HNOCA-tools/
154
+
155
+ [GimVI]: https://docs.scvi-tools.org/en/stable/api/reference/scvi.external.GIMVI.html#
156
+ [ENVI]: https://scenvi.readthedocs.io/en/latest/#
157
+ [GLUE]: https://scglue.readthedocs.io/en/latest/
158
+ [MIDAS]: https://scmidas.readthedocs.io/en/latest/
159
+ [MOFA+]: https://muon.readthedocs.io/en/latest/omics/multi.html
160
+ [scVI]: https://docs.scvi-tools.org/en/stable/api/reference/scvi.model.SCVI.html
161
+ [scANVI]: https://docs.scvi-tools.org/en/stable/api/reference/scvi.model.SCANVI.html
162
+ [scArches]: https://docs.scarches.org/en/latest/
@@ -0,0 +1,89 @@
1
+ # CellMapper
2
+
3
+ [![Tests][badge-tests]][tests]
4
+ [![Coverage][badge-coverage]][coverage]
5
+ [![Pre-commit.ci][badge-pre-commit]][pre-commit]
6
+ [![PyPI][badge-pypi]][pypi]
7
+ [![Documentation][badge-docs]][docs]
8
+
9
+ [badge-tests]: https://github.com/quadbio/cellmapper/actions/workflows/test.yaml/badge.svg
10
+ [badge-coverage]: https://codecov.io/gh/quadbio/cellmapper/branch/main/graph/badge.svg
11
+ [badge-pre-commit]: https://results.pre-commit.ci/badge/github/quadbio/cellmapper/main.svg
12
+ [badge-pypi]: https://img.shields.io/pypi/v/cellmapper.svg
13
+ [badge-docs]: https://img.shields.io/readthedocs/cellmapper
14
+
15
+ k-NN-based mapping of cells across representations to tranfer labels, embeddings and expression values. Works for millions of cells, on CPU and GPU, across molecular modalities, between spatial and non-spatial data, for arbitrary query and reference datasets. Using [faiss][] to compute k-NN graphs, CellMapper takes about 30 seconds to transfer cell type labels from 1.5M cells to 1.5M cells on a single RTX 4090 with 60 GB CPU memory.
16
+
17
+ Inspired by scanpy's [ingest][] and the [HNOCA-tools][] packages. Check out the [docs][] to learn more, in particular our [tutorials][].
18
+
19
+ ## Installation
20
+
21
+ You need to have Python 3.10 or newer installed on your system.
22
+ If you don't have Python installed, we recommend installing [uv][].
23
+
24
+ There are two alternative options to install ``cellmapper``:
25
+
26
+ - Install the latest release from [PyPI][]:
27
+
28
+ ```bash
29
+ pip install cellmapper
30
+ ```
31
+
32
+ - Install the latest development version:
33
+
34
+ ```bash
35
+ pip install git+https://github.com/quadbio/cellmapper.git@main
36
+ ```
37
+
38
+ ## Getting started
39
+
40
+ This package assumes that you have ``ref`` and ``query`` AnnData objects, with a joint embedding computed and stored in ``.obsm``. We explicilty do not compute this joint embedding, but there are plenty of method you can use to get such joint embeddings, e.g. [GimVI][] or [ENVI][] for spatial mapping, [GLUE][], [MIDAS][] and [MOFA+][] for modality translation, and [scVI][], [scANVI][] and [scArches][] for query-to-reference mapping - this is just a small selection!
41
+
42
+ With a joint embedding in ``.obsm["X_joint"]`` at hand, the simplest way to use ``CellMapper`` is as follows:
43
+ ```Python
44
+ from cellmapper import CellMapper
45
+
46
+ cmap = CellMapper(ref, query).fit(
47
+ use_rep="X_joint", obs_keys="celltype", obsm_keys="X_umap", layer_key="X"
48
+ )
49
+ ```
50
+
51
+ This will transfer data from the reference to the query dataset, including celltype labels stored in ``ref.obs``, a UMAP embedding stored in ``ref.obsm``, and expression values stored in ``ref.X``.
52
+
53
+ There are many ways to customize this, e.g. use different ways to compute k-NN graphs and to turn them into mapping matrices, and we implement a few methods to evaluate whether your k-NN transfer was sucessful. Check out the [docs][] to learn more.
54
+
55
+ ## Release notes
56
+
57
+ See the [changelog][].
58
+
59
+ ## Contact
60
+
61
+ If you found a bug, please use the [issue tracker][].
62
+
63
+ ## Citation
64
+
65
+ Please cite this GitHub repo if you find CellMapper useful for your research.
66
+
67
+ [uv]: https://github.com/astral-sh/uv
68
+ [issue tracker]: https://github.com/quadbio/cellmapper/issues
69
+ [tests]: https://github.com/quadbio/cellmapper/actions/workflows/test.yaml
70
+ [changelog]: https://cellmapper.readthedocs.io/en/latest/changelog.html
71
+ [docs]: https://cellmapper.readthedocs.io/
72
+ [tutorials]: https://cellmapper.readthedocs.io/en/latest/notebooks/tutorials/index.html
73
+ [pypi]: https://pypi.org/project/cellmapper
74
+ [coverage]: https://codecov.io/gh/quadbio/cellmapper
75
+ [pre-commit]: https://results.pre-commit.ci/latest/github/quadbio/cellmapper/main
76
+ [pypi]: https://pypi.org/project/cellmapper/
77
+ [faiss]: https://github.com/facebookresearch/faiss
78
+
79
+ [ingest]: https://scanpy.readthedocs.io/en/stable/generated/scanpy.tl.ingest.html
80
+ [HNOCA-tools]: https://devsystemslab.github.io/HNOCA-tools/
81
+
82
+ [GimVI]: https://docs.scvi-tools.org/en/stable/api/reference/scvi.external.GIMVI.html#
83
+ [ENVI]: https://scenvi.readthedocs.io/en/latest/#
84
+ [GLUE]: https://scglue.readthedocs.io/en/latest/
85
+ [MIDAS]: https://scmidas.readthedocs.io/en/latest/
86
+ [MOFA+]: https://muon.readthedocs.io/en/latest/omics/multi.html
87
+ [scVI]: https://docs.scvi-tools.org/en/stable/api/reference/scvi.model.SCVI.html
88
+ [scANVI]: https://docs.scvi-tools.org/en/stable/api/reference/scvi.model.SCANVI.html
89
+ [scArches]: https://docs.scarches.org/en/latest/
@@ -0,0 +1,25 @@
1
+ # API Reference
2
+
3
+ ```{eval-rst}
4
+ The class :class:`~cellmapper.CellMapper` is the main class that users interact with:
5
+
6
+ .. module:: cellmapper
7
+ .. currentmodule:: cellmapper
8
+
9
+ .. autosummary::
10
+ :toctree: generated
11
+
12
+ CellMapper
13
+ ```
14
+
15
+ ```{eval-rst}
16
+ The following classes are more technical; :class:`~cellmapper.Neighbors` is called under the hood for k-NN graph computation.
17
+
18
+ .. module:: cellmapper
19
+ .. currentmodule:: cellmapper
20
+
21
+ .. autosummary::
22
+ :toctree: generated
23
+
24
+ Neighbors
25
+ ```
@@ -60,6 +60,7 @@ extensions = [
60
60
  "IPython.sphinxext.ipython_console_highlighting",
61
61
  "sphinxext.opengraph",
62
62
  *[p.stem for p in (HERE / "extensions").glob("*.py")],
63
+ "sphinx.ext.extlinks",
63
64
  ]
64
65
 
65
66
  autosummary_generate = True
@@ -98,6 +99,13 @@ intersphinx_mapping = {
98
99
  "numpy": ("https://numpy.org/doc/stable/", None),
99
100
  }
100
101
 
102
+ # extlinks config
103
+ extlinks = {
104
+ "issue": (f"{repository_url}/issues/%s", "#%s"),
105
+ "pr": (f"{repository_url}/pull/%s", "#%s"),
106
+ "ghuser": ("https://github.com/%s", "@%s"),
107
+ }
108
+
101
109
  # List of patterns, relative to source directory, that match files and
102
110
  # directories to ignore when looking for source files.
103
111
  # This pattern also affects html_static_path and html_extra_path.
@@ -129,8 +129,7 @@ gives you time to fix the issue or reach out to the developers of the dependency
129
129
 
130
130
  ### Updating the version number
131
131
 
132
- Before making a release, you need to update the version number in the `pyproject.toml` file.
133
- Please adhere to [Semantic Versioning][semver], in brief
132
+ This package uses `hatch-vcs` to infer version numbers. Please adhere to [Semantic Versioning][semver], in brief
134
133
 
135
134
  > Given a version number MAJOR.MINOR.PATCH, increment the:
136
135
  >
@@ -11,5 +11,5 @@ changelog.md
11
11
  contributing.md
12
12
  references.md
13
13
 
14
- notebooks/example
14
+ notebooks/tutorials/index
15
15
  ```
@@ -0,0 +1,9 @@
1
+ Tutorials
2
+ =========
3
+ This section contains tutorials showcasing use cases for k-NN based mapping of cells across representations with :mod:`cellmapper`.
4
+
5
+ .. toctree::
6
+ :maxdepth: 1
7
+ :glob:
8
+
9
+ *