cellmapper 0.2.3__tar.gz → 0.2.4__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 (67) hide show
  1. {cellmapper-0.2.3 → cellmapper-0.2.4}/.cruft.json +3 -3
  2. cellmapper-0.2.4/.github/copilot-instructions.md +196 -0
  3. {cellmapper-0.2.3 → cellmapper-0.2.4}/.github/workflows/test.yaml +7 -3
  4. {cellmapper-0.2.3 → cellmapper-0.2.4}/.gitignore +1 -0
  5. {cellmapper-0.2.3 → cellmapper-0.2.4}/.pre-commit-config.yaml +5 -14
  6. cellmapper-0.2.4/.readthedocs.yaml +15 -0
  7. {cellmapper-0.2.3 → cellmapper-0.2.4}/PKG-INFO +7 -6
  8. {cellmapper-0.2.3 → cellmapper-0.2.4}/README.md +1 -1
  9. {cellmapper-0.2.3 → cellmapper-0.2.4}/biome.jsonc +3 -2
  10. {cellmapper-0.2.3 → cellmapper-0.2.4}/docs/contributing.md +129 -13
  11. {cellmapper-0.2.3 → cellmapper-0.2.4}/pyproject.toml +8 -6
  12. {cellmapper-0.2.3 → cellmapper-0.2.4}/tests/model/test_self_mapping.py +2 -2
  13. cellmapper-0.2.3/.readthedocs.yaml +0 -16
  14. {cellmapper-0.2.3 → cellmapper-0.2.4}/.codecov.yaml +0 -0
  15. {cellmapper-0.2.3 → cellmapper-0.2.4}/.editorconfig +0 -0
  16. {cellmapper-0.2.3 → cellmapper-0.2.4}/.github/ISSUE_TEMPLATE/bug_report.yml +0 -0
  17. {cellmapper-0.2.3 → cellmapper-0.2.4}/.github/ISSUE_TEMPLATE/config.yml +0 -0
  18. {cellmapper-0.2.3 → cellmapper-0.2.4}/.github/ISSUE_TEMPLATE/feature_request.yml +0 -0
  19. {cellmapper-0.2.3 → cellmapper-0.2.4}/.github/workflows/build.yaml +0 -0
  20. {cellmapper-0.2.3 → cellmapper-0.2.4}/.github/workflows/release.yaml +0 -0
  21. {cellmapper-0.2.3 → cellmapper-0.2.4}/.vscode/extensions.json +0 -0
  22. {cellmapper-0.2.3 → cellmapper-0.2.4}/.vscode/launch.json +0 -0
  23. {cellmapper-0.2.3 → cellmapper-0.2.4}/.vscode/settings.json +0 -0
  24. {cellmapper-0.2.3 → cellmapper-0.2.4}/CHANGELOG.md +0 -0
  25. {cellmapper-0.2.3 → cellmapper-0.2.4}/LICENSE +0 -0
  26. {cellmapper-0.2.3 → cellmapper-0.2.4}/docs/_static/.gitkeep +0 -0
  27. {cellmapper-0.2.3 → cellmapper-0.2.4}/docs/_static/css/custom.css +0 -0
  28. {cellmapper-0.2.3 → cellmapper-0.2.4}/docs/_static/images/cellmapper_logo_dark.svg +0 -0
  29. {cellmapper-0.2.3 → cellmapper-0.2.4}/docs/_static/images/cellmapper_logo_light.svg +0 -0
  30. {cellmapper-0.2.3 → cellmapper-0.2.4}/docs/_templates/.gitkeep +0 -0
  31. {cellmapper-0.2.3 → cellmapper-0.2.4}/docs/_templates/autosummary/class.rst +0 -0
  32. {cellmapper-0.2.3 → cellmapper-0.2.4}/docs/api.md +0 -0
  33. {cellmapper-0.2.3 → cellmapper-0.2.4}/docs/changelog.md +0 -0
  34. {cellmapper-0.2.3 → cellmapper-0.2.4}/docs/conf.py +0 -0
  35. {cellmapper-0.2.3 → cellmapper-0.2.4}/docs/extensions/typed_returns.py +0 -0
  36. {cellmapper-0.2.3 → cellmapper-0.2.4}/docs/index.md +0 -0
  37. {cellmapper-0.2.3 → cellmapper-0.2.4}/docs/notebooks/tutorials/data_denoising.ipynb +0 -0
  38. {cellmapper-0.2.3 → cellmapper-0.2.4}/docs/notebooks/tutorials/index.rst +0 -0
  39. {cellmapper-0.2.3 → cellmapper-0.2.4}/docs/notebooks/tutorials/query_to_reference_mapping.ipynb +0 -0
  40. {cellmapper-0.2.3 → cellmapper-0.2.4}/docs/notebooks/tutorials/spatial_mapping.ipynb +0 -0
  41. {cellmapper-0.2.3 → cellmapper-0.2.4}/docs/notebooks/tutorials/spatial_smoothing.ipynb +0 -0
  42. {cellmapper-0.2.3 → cellmapper-0.2.4}/docs/references.bib +0 -0
  43. {cellmapper-0.2.3 → cellmapper-0.2.4}/docs/references.md +0 -0
  44. {cellmapper-0.2.3 → cellmapper-0.2.4}/src/cellmapper/__init__.py +0 -0
  45. {cellmapper-0.2.3 → cellmapper-0.2.4}/src/cellmapper/_docs.py +0 -0
  46. {cellmapper-0.2.3 → cellmapper-0.2.4}/src/cellmapper/check.py +0 -0
  47. {cellmapper-0.2.3 → cellmapper-0.2.4}/src/cellmapper/constants.py +0 -0
  48. {cellmapper-0.2.3 → cellmapper-0.2.4}/src/cellmapper/logging.py +0 -0
  49. {cellmapper-0.2.3 → cellmapper-0.2.4}/src/cellmapper/model/_knn_backend.py +0 -0
  50. {cellmapper-0.2.3 → cellmapper-0.2.4}/src/cellmapper/model/cellmapper.py +0 -0
  51. {cellmapper-0.2.3 → cellmapper-0.2.4}/src/cellmapper/model/embedding.py +0 -0
  52. {cellmapper-0.2.3 → cellmapper-0.2.4}/src/cellmapper/model/evaluate.py +0 -0
  53. {cellmapper-0.2.3 → cellmapper-0.2.4}/src/cellmapper/model/kernel.py +0 -0
  54. {cellmapper-0.2.3 → cellmapper-0.2.4}/src/cellmapper/model/mapping_operator.py +0 -0
  55. {cellmapper-0.2.3 → cellmapper-0.2.4}/src/cellmapper/model/neighbors.py +0 -0
  56. {cellmapper-0.2.3 → cellmapper-0.2.4}/src/cellmapper/utils.py +0 -0
  57. {cellmapper-0.2.3 → cellmapper-0.2.4}/tests/conftest.py +0 -0
  58. {cellmapper-0.2.3 → cellmapper-0.2.4}/tests/data/precomputed_leiden.csv +0 -0
  59. {cellmapper-0.2.3 → cellmapper-0.2.4}/tests/model/test_embedding.py +0 -0
  60. {cellmapper-0.2.3 → cellmapper-0.2.4}/tests/model/test_evaluate.py +0 -0
  61. {cellmapper-0.2.3 → cellmapper-0.2.4}/tests/model/test_kernel.py +0 -0
  62. {cellmapper-0.2.3 → cellmapper-0.2.4}/tests/model/test_mapping_operator.py +0 -0
  63. {cellmapper-0.2.3 → cellmapper-0.2.4}/tests/model/test_neighbors.py +0 -0
  64. {cellmapper-0.2.3 → cellmapper-0.2.4}/tests/model/test_query_to_reference_mapping.py +0 -0
  65. {cellmapper-0.2.3 → cellmapper-0.2.4}/tests/test_basic.py +0 -0
  66. {cellmapper-0.2.3 → cellmapper-0.2.4}/tests/test_check.py +0 -0
  67. {cellmapper-0.2.3 → cellmapper-0.2.4}/tests/test_utils.py +0 -0
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "template": "https://github.com/scverse/cookiecutter-scverse",
3
- "commit": "d4bdfc5ec4c5029aebf7c0cba65609e20358144d",
4
- "checkout": null,
3
+ "commit": "d383d94fadff9e4e6fdb59d77c68cb900d7cedec",
4
+ "checkout": "v0.6.0",
5
5
  "context": {
6
6
  "cookiecutter": {
7
7
  "project_name": "cellmapper",
@@ -36,7 +36,7 @@
36
36
  "trim_blocks": true
37
37
  },
38
38
  "_template": "https://github.com/scverse/cookiecutter-scverse",
39
- "_commit": "d4bdfc5ec4c5029aebf7c0cba65609e20358144d"
39
+ "_commit": "d383d94fadff9e4e6fdb59d77c68cb900d7cedec"
40
40
  }
41
41
  },
42
42
  "directory": null
@@ -0,0 +1,196 @@
1
+ # Copilot Instructions for CellMapper
2
+
3
+ ## Important Notes
4
+ - Avoid drafting summary documents or endless markdown files. Just summarize in chat what you did, why, and any open questions.
5
+ - Don't update Jupyter notebooks - those are managed manually.
6
+ - When running terminal commands, activate the appropriate environment first (`mamba activate cellmapper`).
7
+ - Rather than making assumptions, ask for clarification when uncertain.
8
+ - **GitHub workflows**: Use GitHub CLI (`gh`) when possible. For GitHub MCP server tools, ensure Docker Desktop is running first (`open -a "Docker Desktop"`).
9
+
10
+ ## Project Overview
11
+
12
+ **CellMapper** is a k-NN-based tool for mapping cells across representations to transfer labels, embeddings, and expression values. It works for millions of cells, on CPU and GPU, across molecular modalities, between spatial and non-spatial data. The core idea is to separate the method (k-NN graph with kernels) from the application (mapping across arbitrary representations).
13
+
14
+ ### Domain Context (Brief)
15
+ - **AnnData**: Standard single-cell data structure. Contains `.X`, `.obs`, `.var`, `.obsm` (embeddings), `.layers`.
16
+ - **k-NN mapping**: Compute k-nearest neighbors between query and reference datasets, apply graph kernel to create mapping matrix, use it to transfer labels/embeddings/expression.
17
+ - **Joint embeddings**: CellMapper expects pre-computed joint embeddings in `.obsm` from tools like scVI, scANVI, GimVI, ENVI, GLUE, or implements baseline methods (PCA, CCA).
18
+ - **Use cases**: Transfer labels from dissociated to spatial data, map embeddings between datasets, compute presence scores in atlases, identify spatial niches, evaluate mapping quality.
19
+
20
+ ### Key Dependencies
21
+ - **Core**: anndata, scanpy, numpy, pandas, scipy, scikit-learn
22
+ - **k-NN backends**: pynndescent, sklearn, faiss (CPU/GPU), rapids (GPU)
23
+ - **Optional**: squidpy (for spatial), scvi-tools, harmony-pytorch (for tutorials)
24
+
25
+ ## Architecture & Code Organization
26
+
27
+ ### Module Structure (follows scverse conventions)
28
+ - Use `AnnData` objects as primary data structure
29
+ - Type annotations use modern syntax: `str | None` instead of `Optional[str]`
30
+ - Supports Python 3.11, 3.12, 3.13 (see `pyproject.toml`)
31
+ - Avoid local imports unless necessary for circular import resolution
32
+
33
+ ### Core Components
34
+ 1. **`src/cellmapper/model/cellmapper.py`**: Main `CellMapper` class with `map()` method
35
+ - Inherits from `EvaluationMixin` and `EmbeddingMixin`
36
+ - Handles both query-to-reference and self-mapping modes
37
+ - Core methods: `map()`, `map_obs()`, `map_obsm()`, `map_layers()`
38
+ 2. **`src/cellmapper/model/neighbors.py`**: k-NN graph computation with multiple backends
39
+ 3. **`src/cellmapper/model/kernel.py`**: Graph kernels for creating mapping matrices
40
+ 4. **`src/cellmapper/model/mapping_operator.py`**: Encapsulates mapping matrix with matrix powers for diffusion
41
+ 5. **`src/cellmapper/model/evaluate.py`**: Metrics for evaluating label/expression transfer quality
42
+ 6. **`src/cellmapper/model/embedding.py`**: Baseline joint embedding methods (PCA, CCA)
43
+ 7. **`src/cellmapper/utils.py`**: Utilities (library size adjustment, imputed data creation)
44
+
45
+ ## Development Workflow
46
+
47
+ ### Environment Management (Hatch-based)
48
+ ```bash
49
+ # Testing - NEVER use pytest directly
50
+ hatch test # test with highest Python version
51
+ hatch test --all # test all Python 3.11, 3.13, pre-release deps
52
+
53
+ # Documentation
54
+ hatch run docs:build # build Sphinx docs
55
+ hatch run docs:open # open in browser
56
+ hatch run docs:clean # clean build artifacts
57
+
58
+ # Environment inspection
59
+ hatch env show # list environments
60
+ hatch env find hatch-test # find test environment paths
61
+ ```
62
+
63
+ ### Testing Strategy
64
+ - Test matrix defined in `[[tool.hatch.envs.hatch-test.matrix]]` in `pyproject.toml`
65
+ - Tests Python 3.11 & 3.13 with stable deps, 3.13 with pre-release deps
66
+ - CI extracts test config from pyproject.toml (`.github/workflows/test.yaml`)
67
+ - Tests live in `tests/`, fixtures in `tests/conftest.py`
68
+ - **Always run tests via `hatch test`**, NOT standalone pytest
69
+
70
+ ### Code Quality Tools
71
+ - **Ruff**: Linting and formatting (120 char line length)
72
+ - **Biome**: JSON/JSONC formatting with trailing commas
73
+ - **Pre-commit**: Auto-runs ruff, biome. Install with `pre-commit install`
74
+ - Use `git pull --rebase` if pre-commit.ci commits to your branch
75
+
76
+ ## Documentation Conventions
77
+
78
+ ### Docstring Style (NumPy format via Napoleon)
79
+ ```python
80
+ def map_obs(
81
+ self,
82
+ obs_keys: str | list[str],
83
+ *, # keyword-only marker
84
+ prediction_postfix: str = "_predicted",
85
+ confidence_postfix: str = "_confidence",
86
+ ) -> pd.DataFrame:
87
+ """Short one-line description.
88
+
89
+ Extended description if needed.
90
+
91
+ Parameters
92
+ ----------
93
+ obs_keys
94
+ Keys in reference.obs to transfer to query.
95
+ prediction_postfix
96
+ Suffix for predicted column names.
97
+ confidence_postfix
98
+ Suffix for confidence score column names.
99
+
100
+ Returns
101
+ -------
102
+ DataFrame with transferred labels and confidence scores.
103
+ """
104
+ ```
105
+
106
+ ### Sphinx & Documentation
107
+ - API docs auto-generated from `docs/api.md` using `autosummary`
108
+ - Tutorials in `docs/notebooks/tutorials/` rendered via myst-nb (`.ipynb` only)
109
+ - Add external packages to `intersphinx_mapping` in `docs/conf.py`
110
+ - See `docs/contributing.md` for detailed documentation guidelines
111
+
112
+ ## Key Configuration Files
113
+
114
+ ### `pyproject.toml`
115
+ - **Build**: `hatchling` with `hatch-vcs` for git-based versioning
116
+ - **Dependencies**: Minimal runtime deps; optional extras for `[test]`, `[doc]`, `[tutorials]`
117
+ - **Ruff**: 120 char line length, NumPy docstring convention
118
+ - **Test matrix**: Python 3.11 & 3.13 (stable), 3.13 (pre-release)
119
+
120
+ ### Version Management
121
+ - Version from git tags via `hatch-vcs`
122
+ - Release: Create GitHub release with tag `vX.X.X`
123
+ - Follows **Semantic Versioning**
124
+
125
+ ## Project-Specific Patterns
126
+
127
+ ### Basic Usage Pattern
128
+ ```python
129
+ from cellmapper import CellMapper
130
+
131
+ # Assume query and reference have joint embedding in .obsm["X_joint"]
132
+ cmap = CellMapper(query, reference).map(
133
+ use_rep="X_joint",
134
+ obs_keys="celltype", # transfer labels
135
+ obsm_keys="X_umap", # transfer UMAP
136
+ layer_key="counts", # transfer expression
137
+ )
138
+
139
+ # Self-mapping (for spatial contextualization, denoising)
140
+ cmap_self = CellMapper(query).map(
141
+ use_rep="X_pca",
142
+ layer_key="counts",
143
+ )
144
+ ```
145
+
146
+ ### k-NN Backends
147
+ - **pynndescent**: Fast approximate k-NN, CPU-only
148
+ - **sklearn**: Exact k-NN, CPU-only, slower for large datasets
149
+ - **faiss**: Exact/approximate k-NN, supports CPU and GPU (via faiss-gpu)
150
+ - **rapids**: GPU-accelerated k-NN using cuML
151
+
152
+ ### Mapping Workflow
153
+ 1. Compute k-NN graph between query and reference (or self)
154
+ 2. Apply kernel to k-NN graph to create mapping matrix M
155
+ 3. Transfer data: `query_data = M @ reference_data`
156
+ 4. Optionally apply matrix powers `M^t` for diffusion
157
+ 5. Evaluate transfer quality with metrics
158
+
159
+ ### AnnData Conventions
160
+ - Check matrix format: `adata.X` may be sparse or dense
161
+ - Use `adata.layers[key]` for alternative representations (e.g., counts, log-normalized)
162
+ - Joint embeddings stored in `adata.obsm["X_<method>"]`
163
+ - Transferred data goes back into query's `.obs`, `.obsm`, `.layers`
164
+
165
+ ### Testing with AnnData
166
+ ```python
167
+ # From conftest.py - example fixture pattern
168
+ @pytest.fixture
169
+ def adata_spatial():
170
+ """Small spatial AnnData object with spatial coordinates."""
171
+ adata = ad.AnnData(
172
+ X=np.random.randn(100, 50).astype(np.float32),
173
+ obs=pd.DataFrame({"celltype": ["A", "B"] * 50}),
174
+ obsm={"spatial": np.random.rand(100, 2)},
175
+ )
176
+ sc.pp.pca(adata)
177
+ return adata
178
+ ```
179
+
180
+ ## Common Gotchas
181
+
182
+ 1. **Hatch for testing**: Always use `hatch test`, never standalone `pytest`. CI matches hatch test matrix.
183
+ 2. **Joint embeddings required**: Most use cases require pre-computed joint embedding in `.obsm`. Don't assume PCA is sufficient for complex mappings.
184
+ 3. **Sparse matrices**: Check `scipy.sparse.issparse(adata.X)` before operations. Mapping matrices are typically dense.
185
+ 4. **Self-mapping mode**: If `reference` is `None` or same as `query`, automatically enters self-mapping mode.
186
+ 5. **k-NN backends**: faiss requires `faiss-cpu` or `faiss-gpu`, rapids requires CUDA environment. Handle gracefully with fallbacks.
187
+ 6. **Pre-commit conflicts**: Use `git pull --rebase` to integrate pre-commit.ci fixes.
188
+ 7. **Line length**: Ruff set to 120 chars, but keep docstrings readable (~80 chars per line).
189
+
190
+ ## Related Resources
191
+
192
+ - **Contributing guide**: `docs/contributing.md`
193
+ - **Tutorials**: `docs/notebooks/tutorials/`
194
+ - **scanpy docs**: https://scanpy.readthedocs.io/
195
+ - **faiss docs**: https://github.com/facebookresearch/faiss
196
+ - **squidpy docs**: https://squidpy.readthedocs.io/ (for spatial analysis)
@@ -78,11 +78,15 @@ jobs:
78
78
  MPLBACKEND: agg
79
79
  PLATFORM: ${{ matrix.os }}
80
80
  DISPLAY: :42
81
- run: uvx hatch run ${{ matrix.env.name }}:run-cov
81
+ run: uvx hatch run ${{ matrix.env.name }}:run-cov -v --color=yes -n auto
82
82
  - name: generate coverage report
83
- run: uvx hatch run ${{ matrix.env.name }}:coverage xml
83
+ run: |
84
+ # See https://coverage.readthedocs.io/en/latest/config.html#run-patch
85
+ test -f .coverage || uvx hatch run ${{ matrix.env.name }}:cov-combine
86
+ uvx hatch run ${{ matrix.env.name }}:cov-report # report visibly
87
+ uvx hatch run ${{ matrix.env.name }}:coverage xml # create report for upload
84
88
  - name: Upload coverage
85
- uses: codecov/codecov-action@v4
89
+ uses: codecov/codecov-action@v5
86
90
  with:
87
91
  token: ${{ secrets.CODECOV_TOKEN }}
88
92
 
@@ -14,6 +14,7 @@ __pycache__/
14
14
  # Tests and coverage
15
15
  /data/
16
16
  /node_modules/
17
+ /.coverage*
17
18
 
18
19
  # docs
19
20
  /docs/generated/
@@ -7,24 +7,24 @@ default_stages:
7
7
  minimum_pre_commit_version: 2.16.0
8
8
  repos:
9
9
  - repo: https://github.com/biomejs/pre-commit
10
- rev: v1.9.4
10
+ rev: v2.2.6
11
11
  hooks:
12
12
  - id: biome-format
13
13
  exclude: ^\.cruft\.json$ # inconsistent indentation with cruft - file never to be modified manually.
14
14
  - repo: https://github.com/tox-dev/pyproject-fmt
15
- rev: v2.5.1
15
+ rev: v2.11.0
16
16
  hooks:
17
17
  - id: pyproject-fmt
18
18
  - repo: https://github.com/astral-sh/ruff-pre-commit
19
- rev: v0.11.10
19
+ rev: v0.14.1
20
20
  hooks:
21
- - id: ruff
21
+ - id: ruff-check
22
22
  types_or: [python, pyi, jupyter]
23
23
  args: [--fix, --exit-non-zero-on-fix]
24
24
  - id: ruff-format
25
25
  types_or: [python, pyi, jupyter]
26
26
  - repo: https://github.com/pre-commit/pre-commit-hooks
27
- rev: v5.0.0
27
+ rev: v6.0.0
28
28
  hooks:
29
29
  - id: detect-private-key
30
30
  - id: check-ast
@@ -36,12 +36,3 @@ repos:
36
36
  # Check that there are no merge conflicts (could be generated by template sync)
37
37
  - id: check-merge-conflict
38
38
  args: [--assume-in-merge]
39
- - repo: local
40
- hooks:
41
- - id: forbid-to-commit
42
- name: Don't commit rej files
43
- entry: |
44
- Cannot commit .rej files. These indicate merge conflicts that arise during automated template updates.
45
- Fix the merge conflicts manually and remove the .rej files.
46
- language: fail
47
- files: '.*\.rej$'
@@ -0,0 +1,15 @@
1
+ # https://docs.readthedocs.io/en/stable/config-file/v2.html
2
+ version: 2
3
+ build:
4
+ os: ubuntu-24.04
5
+ tools:
6
+ python: "3.12"
7
+ jobs:
8
+ create_environment:
9
+ - asdf plugin add uv
10
+ - asdf install uv latest
11
+ - asdf global uv latest
12
+ build:
13
+ html:
14
+ - uvx hatch run docs:build
15
+ - mv docs/_build $READTHEDOCS_OUTPUT
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cellmapper
3
- Version: 0.2.3
3
+ Version: 0.2.4
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
@@ -30,11 +30,11 @@ License: MIT License
30
30
  SOFTWARE.
31
31
  License-File: LICENSE
32
32
  Classifier: Programming Language :: Python :: 3 :: Only
33
- Classifier: Programming Language :: Python :: 3.10
34
33
  Classifier: Programming Language :: Python :: 3.11
35
34
  Classifier: Programming Language :: Python :: 3.12
36
35
  Classifier: Programming Language :: Python :: 3.13
37
- Requires-Python: >=3.10
36
+ Classifier: Programming Language :: Python :: 3.14
37
+ Requires-Python: >=3.11
38
38
  Requires-Dist: anndata>=0.11
39
39
  Requires-Dist: docrep
40
40
  Requires-Dist: numpy
@@ -59,13 +59,14 @@ Requires-Dist: sphinx-autodoc-typehints; extra == 'doc'
59
59
  Requires-Dist: sphinx-book-theme>=1; extra == 'doc'
60
60
  Requires-Dist: sphinx-copybutton; extra == 'doc'
61
61
  Requires-Dist: sphinx-tabs; extra == 'doc'
62
- Requires-Dist: sphinx>=4; extra == 'doc'
62
+ Requires-Dist: sphinx>=8.1; extra == 'doc'
63
63
  Requires-Dist: sphinxcontrib-bibtex>=1; extra == 'doc'
64
64
  Requires-Dist: sphinxext-opengraph; extra == 'doc'
65
65
  Provides-Extra: test
66
- Requires-Dist: coverage; extra == 'test'
66
+ Requires-Dist: coverage>=7.10; extra == 'test'
67
67
  Requires-Dist: faiss-cpu; extra == 'test'
68
68
  Requires-Dist: pytest; extra == 'test'
69
+ Requires-Dist: pytest-cov; extra == 'test'
69
70
  Requires-Dist: squidpy>=1.6; extra == 'test'
70
71
  Provides-Extra: tutorials
71
72
  Requires-Dist: harmony-pytorch; extra == 'tutorials'
@@ -112,7 +113,7 @@ The core idea of `CellMapper` is to separate the method (k-NN graph with some ke
112
113
 
113
114
  ## 📦 Installation
114
115
 
115
- You need to have 🐍 Python 3.10 or newer installed on your system.
116
+ You need to have 🐍 Python 3.11 or newer installed on your system.
116
117
  If you don't have Python installed, we recommend installing [uv][].
117
118
 
118
119
  There are two alternative options to install ``cellmapper``:
@@ -32,7 +32,7 @@ The core idea of `CellMapper` is to separate the method (k-NN graph with some ke
32
32
 
33
33
  ## 📦 Installation
34
34
 
35
- You need to have 🐍 Python 3.10 or newer installed on your system.
35
+ You need to have 🐍 Python 3.11 or newer installed on your system.
36
36
  If you don't have Python installed, we recommend installing [uv][].
37
37
 
38
38
  There are two alternative options to install ``cellmapper``:
@@ -1,9 +1,10 @@
1
1
  {
2
- "$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
2
+ "$schema": "https://biomejs.dev/schemas/2.2.0/schema.json",
3
+ "vcs": { "enabled": true, "clientKind": "git", "useIgnoreFile": true },
3
4
  "formatter": { "useEditorconfig": true },
4
5
  "overrides": [
5
6
  {
6
- "include": ["./.vscode/*.json", "**/*.jsonc"],
7
+ "includes": ["./.vscode/*.json", "**/*.jsonc"],
7
8
  "json": {
8
9
  "formatter": { "trailingCommas": "all" },
9
10
  "parser": {
@@ -1,14 +1,33 @@
1
1
  # Contributing guide
2
2
 
3
- Scanpy provides extensive [developer documentation][scanpy developer guide], most of which applies to this project, too.
4
- This document will not reproduce the entire content from there.
5
- Instead, it aims at summarizing the most important information to get you started on contributing.
6
-
3
+ This document aims at summarizing the most important information for getting you started on contributing to this project.
7
4
  We assume that you are already familiar with git and with making pull requests on GitHub.
8
- If not, please refer to the [scanpy developer guide][].
9
5
 
6
+ For more extensive tutorials, that also cover the absolute basics,
7
+ please refer to other resources such as the [pyopensci tutorials][],
8
+ the [scientific Python tutorials][], or the [scanpy developer guide][].
9
+
10
+ [pyopensci tutorials]: https://www.pyopensci.org/learn.html
11
+ [scientific Python tutorials]: https://learn.scientific-python.org/development/tutorials/
10
12
  [scanpy developer guide]: https://scanpy.readthedocs.io/en/latest/dev/index.html
11
13
 
14
+ :::{tip} The *hatch* project manager
15
+
16
+ We highly recommend to familiarize yourself with [`hatch`][hatch].
17
+ Hatch is a Python project manager that
18
+
19
+ - manages virtual environments, separately for development, testing and building the documentation.
20
+ Separating the environments is useful to avoid dependency conflicts.
21
+ - allows to run tests locally in different environments (e.g. different python versions)
22
+ - allows to run tasks defined in `pyproject.toml`, e.g. to build documentation.
23
+
24
+ While the project is setup with `hatch` in mind,
25
+ it is still possible to use different tools to manage dependencies, such as `uv` or `pip`.
26
+
27
+ :::
28
+
29
+ [hatch]: https://hatch.pypa.io/latest/
30
+
12
31
  ## Installing dev dependencies
13
32
 
14
33
  In addition to the packages needed to _use_ this package,
@@ -16,29 +35,103 @@ you need additional python packages to [run tests](#writing-tests) and [build th
16
35
 
17
36
  :::::{tabs}
18
37
  ::::{group-tab} Hatch
19
- The easiest way is to get familiar with [hatch environments][], with which these tasks are simply:
38
+
39
+ On the command line, you typically interact with hatch through its command line interface (CLI).
40
+ Running one of the following commands will automatically resolve the environments for testing and
41
+ building the documentation in the background:
20
42
 
21
43
  ```bash
22
44
  hatch test # defined in the table [tool.hatch.envs.hatch-test] in pyproject.toml
23
45
  hatch run docs:build # defined in the table [tool.hatch.envs.docs]
24
46
  ```
25
47
 
48
+ When using an IDE such as VS Code,
49
+ you’ll have to point the editor at the paths to the virtual environments manually.
50
+ The environment you typically want to use as your main development environment is the `hatch-test`
51
+ environment with the latest Python version.
52
+
53
+ To get a list of all environments for your projects, run
54
+
55
+ ```bash
56
+ hatch env show -i
57
+ ```
58
+
59
+ This will list “Standalone” environments and a table of “Matrix” environments like the following:
60
+
61
+ ```
62
+ +------------+---------+--------------------------+----------+---------------------------------+-------------+
63
+ | Name | Type | Envs | Features | Dependencies | Scripts |
64
+ +------------+---------+--------------------------+----------+---------------------------------+-------------+
65
+ | hatch-test | virtual | hatch-test.py3.10-stable | dev | coverage-enable-subprocess==1.0 | cov-combine |
66
+ | | | hatch-test.py3.13-stable | test | coverage[toml]~=7.4 | cov-report |
67
+ | | | hatch-test.py3.13-pre | | pytest-mock~=3.12 | run |
68
+ | | | | | pytest-randomly~=3.15 | run-cov |
69
+ | | | | | pytest-rerunfailures~=14.0 | |
70
+ | | | | | pytest-xdist[psutil]~=3.5 | |
71
+ | | | | | pytest~=8.1 | |
72
+ +------------+---------+--------------------------+----------+---------------------------------+-------------+
73
+ ```
74
+
75
+ From the `Envs` column, select the environment name you want to use for development.
76
+ In this example, it would be `hatch-test.py3.13-stable`.
77
+
78
+ Next, create the environment with
79
+
80
+ ```bash
81
+ hatch env create hatch-test.py3.13-stable
82
+ ```
83
+
84
+ Then, obtain the path to the environment using
85
+
86
+ ```bash
87
+ hatch env find hatch-test.py3.13-stable
88
+ ```
89
+
90
+ In case you are using VScode, now open the command palette (Ctrl+Shift+P) and search for `Python: Select Interpreter`.
91
+ Choose `Enter Interpreter Path` and paste the path to the virtual environment from above.
92
+
93
+ In this future, this may become easier through a hatch vscode extension.
94
+
95
+ ::::
96
+
97
+ ::::{group-tab} uv
98
+
99
+ A popular choice for managing virtual environments is [uv][].
100
+ The main disadvantage compared to hatch is that it supports only a single environment per project at a time,
101
+ which requires you to mix the dependencies for running tests and building docs.
102
+ This can have undesired side-effects,
103
+ such as requiring to install a lower version of a library your project depends on,
104
+ only because an outdated sphinx plugin pins an older version.
105
+
106
+ To initalize a virtual environment in the `.venv` directory of your project, simply run
107
+
108
+ ```bash
109
+ uv sync --all-extras
110
+ ```
111
+
112
+ The `.venv` directory is typically automatically discovered by IDEs such as VS Code.
113
+
26
114
  ::::
27
115
 
28
116
  ::::{group-tab} Pip
29
- If you prefer managing environments manually, you can use `pip`:
117
+
118
+ Pip is nowadays mostly superseded by environment manager such as [hatch][].
119
+ However, for the sake of completeness, and since it’s ubiquitously available,
120
+ we describe how you can manage environments manually using `pip`:
30
121
 
31
122
  ```bash
32
- cd cellmapper
33
123
  python3 -m venv .venv
34
124
  source .venv/bin/activate
35
125
  pip install -e ".[dev,test,doc]"
36
126
  ```
37
127
 
128
+ The `.venv` directory is typically automatically discovered by IDEs such as VS Code.
129
+
38
130
  ::::
39
131
  :::::
40
132
 
41
133
  [hatch environments]: https://hatch.pypa.io/latest/tutorials/environment/basic-usage/
134
+ [uv]: https://docs.astral.sh/uv/
42
135
 
43
136
  ## Code-style
44
137
 
@@ -55,7 +148,7 @@ in the root of the repository.
55
148
  Pre-commit will automatically download all dependencies when it is run for the first time.
56
149
 
57
150
  Alternatively, you can rely on the [pre-commit.ci][] service enabled on GitHub.
58
- If you didn't run `pre-commit` before pushing changes to GitHub it will automatically commit fixes to your pull request, or show an error message.
151
+ If you didn’t run `pre-commit` before pushing changes to GitHub it will automatically commit fixes to your pull request, or show an error message.
59
152
 
60
153
  If pre-commit.ci added a commit on a branch you still have been working on locally, simply use
61
154
 
@@ -102,6 +195,14 @@ hatch test --all # test with all supported Python versions
102
195
 
103
196
  ::::
104
197
 
198
+ ::::{group-tab} uv
199
+
200
+ ```bash
201
+ uv run pytest
202
+ ```
203
+
204
+ ::::
205
+
105
206
  ::::{group-tab} Pip
106
207
 
107
208
  ```bash
@@ -118,12 +219,17 @@ in the root of the repository.
118
219
 
119
220
  ### Continuous integration
120
221
 
121
- Continuous integration will automatically run the tests on all pull requests and test
222
+ Continuous integration via GitHub actions will automatically run the tests on all pull requests and test
122
223
  against the minimum and maximum supported Python version.
123
224
 
124
- Additionally, there's a CI job that tests against pre-releases of all dependencies (if there are any).
225
+ Additionally, there’s a CI job that tests against pre-releases of all dependencies (if there are any).
125
226
  The purpose of this check is to detect incompatibilities of new package versions early on and
126
- gives you time to fix the issue or reach out to the developers of the dependency before the package is released to a wider audience.
227
+ gives you time to fix the issue or reach out to the developers of the dependency before the package
228
+ is released to a wider audience.
229
+
230
+ The CI job is defined in `.github/workflows/test.yaml`,
231
+ however the single point of truth for CI jobs is the Hatch test matrix defined in `pyproject.toml`.
232
+ This means that local testing via hatch and remote testing on CI tests against the same python versions and uses the same environments.
127
233
 
128
234
  ## Publishing a release
129
235
 
@@ -188,7 +294,7 @@ please check out [this feature request][issue-render-notebooks] in the `cookiecu
188
294
 
189
295
  (docs-building)=
190
296
 
191
- #### Building the docs locally
297
+ ### Building the docs locally
192
298
 
193
299
  :::::{tabs}
194
300
  ::::{group-tab} Hatch
@@ -200,6 +306,16 @@ hatch run docs:open
200
306
 
201
307
  ::::
202
308
 
309
+ ::::{group-tab} uv
310
+
311
+ ```bash
312
+ cd docs
313
+ uv run sphinx-build -M html . _build -W
314
+ (xdg-)open _build/html/index.html
315
+ ```
316
+
317
+ ::::
318
+
203
319
  ::::{group-tab} Pip
204
320
 
205
321
  ```bash
@@ -13,13 +13,13 @@ maintainers = [
13
13
  authors = [
14
14
  { name = "Marius Lange" },
15
15
  ]
16
- requires-python = ">=3.10"
16
+ requires-python = ">=3.11"
17
17
  classifiers = [
18
18
  "Programming Language :: Python :: 3 :: Only",
19
- "Programming Language :: Python :: 3.10",
20
19
  "Programming Language :: Python :: 3.11",
21
20
  "Programming Language :: Python :: 3.12",
22
21
  "Programming Language :: Python :: 3.13",
22
+ "Programming Language :: Python :: 3.14",
23
23
  ]
24
24
  dynamic = [ "version" ]
25
25
  dependencies = [
@@ -47,7 +47,7 @@ optional-dependencies.doc = [
47
47
  "pandas",
48
48
  # Until pybtex >0.24.0 releases: https://bitbucket.org/pybtex-devs/pybtex/issues/169/
49
49
  "setuptools",
50
- "sphinx>=4",
50
+ "sphinx>=8.1",
51
51
  "sphinx-autodoc-typehints",
52
52
  "sphinx-book-theme>=1",
53
53
  "sphinx-copybutton",
@@ -56,9 +56,10 @@ optional-dependencies.doc = [
56
56
  "sphinxext-opengraph",
57
57
  ]
58
58
  optional-dependencies.test = [
59
- "coverage",
59
+ "coverage>=7.10",
60
60
  "faiss-cpu",
61
61
  "pytest",
62
+ "pytest-cov", # For VS Code's coverage functionality
62
63
  "squidpy>=1.6",
63
64
  ]
64
65
  optional-dependencies.tutorials = [
@@ -93,7 +94,7 @@ scripts.clean = "git clean -fdX -- {args:docs}"
93
94
  # Test the lowest and highest supported Python versions with normal deps
94
95
  [[tool.hatch.envs.hatch-test.matrix]]
95
96
  deps = [ "stable" ]
96
- python = [ "3.10", "3.13" ]
97
+ python = [ "3.11", "3.13" ]
97
98
 
98
99
  # Test the newest supported Python version also with pre-release deps
99
100
  [[tool.hatch.envs.hatch-test.matrix]]
@@ -101,7 +102,7 @@ deps = [ "pre" ]
101
102
  python = [ "3.13" ]
102
103
 
103
104
  [tool.hatch.envs.hatch-test]
104
- features = [ "test" ]
105
+ features = [ "dev", "test" ]
105
106
 
106
107
  [tool.hatch.envs.hatch-test.overrides]
107
108
  # If the matrix variable `deps` is set to "pre",
@@ -159,6 +160,7 @@ addopts = [
159
160
 
160
161
  [tool.coverage.run]
161
162
  source = [ "cellmapper" ]
163
+ patch = [ "subprocess" ]
162
164
  omit = [
163
165
  "**/test_*.py",
164
166
  ]
@@ -475,7 +475,7 @@ class TestCellMapperImputation:
475
475
 
476
476
  # Assert high similarity
477
477
  assert cell_corrs.mean() > 0.99, f"Cell correlations not high enough: {cell_corrs.mean():.6f}"
478
- assert gene_corrs.mean() > 0.95, f"Gene correlations not high enough: {gene_corrs.mean():.6f}"
478
+ assert gene_corrs.mean() > 0.92, f"Gene correlations not high enough: {gene_corrs.mean():.6f}"
479
479
 
480
480
  def test_iterative_vs_partial_spectral_similarity(self, adata_pbmc3k):
481
481
  """Test that iterative and partial spectral approaches give highly similar results."""
@@ -501,4 +501,4 @@ class TestCellMapperImputation:
501
501
 
502
502
  # Assert high similarity
503
503
  assert cell_corrs.mean() > 0.99, f"Cell correlations not high enough: {cell_corrs.mean():.6f}"
504
- assert gene_corrs.mean() > 0.95, f"Gene correlations not high enough: {gene_corrs.mean():.6f}"
504
+ assert gene_corrs.mean() > 0.92, f"Gene correlations not high enough: {gene_corrs.mean():.6f}"
@@ -1,16 +0,0 @@
1
- # https://docs.readthedocs.io/en/stable/config-file/v2.html
2
- version: 2
3
- build:
4
- os: ubuntu-20.04
5
- tools:
6
- python: "3.10"
7
- sphinx:
8
- configuration: docs/conf.py
9
- # disable this for more lenient docs builds
10
- fail_on_warning: false
11
- python:
12
- install:
13
- - method: pip
14
- path: .
15
- extra_requirements:
16
- - doc
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes