Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copilot Instructions for CellMapper

Canonical repo guidance lives in:

- `AGENTS.md` — architecture, invariants, and validation commands
- `REVIEW_GUIDE.md` — PR review workflow, risk areas, and changed-path test lookup

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,6 @@ jobs:
- test
runs-on: ubuntu-latest
steps:
- uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}
- uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ default_stages:
minimum_pre_commit_version: 2.16.0
repos:
- repo: https://github.com/biomejs/pre-commit
rev: v2.5.3
rev: v2.6.8
hooks:
- id: biome-format
exclude: ^\.cruft\.json$ # inconsistent indentation with cruft - file never to be modified manually.
- repo: https://github.com/tox-dev/pyproject-fmt
rev: v2.25.3
rev: v2.31.2
hooks:
- id: pyproject-fmt
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.15.21
rev: v0.17.6
hooks:
- id: ruff-check
types_or: [python, pyi, jupyter]
Expand Down
25 changes: 13 additions & 12 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ RAPIDS cuML.
## Trust Order

When sources disagree:

1. PR description and changed code
2. This file (`AGENTS.md`)
3. `REVIEW_GUIDE.md`
Expand All @@ -23,18 +24,18 @@ table below — everything else is delegated.

## Where To Find What

| Topic | Source of truth |
|-------|----------------|
| User-facing overview, use cases, quickstart | `README.md` |
| Public API reference | `docs/api.md` and autosummary under `docs/generated/` |
| Tutorials (query→reference, spatial mapping, spatial smoothing, data denoising) | `docs/notebooks/tutorials/` |
| Contributor setup, environments, docs build | `docs/contributing.md` |
| Release notes | `docs/changelog.md` |
| PR review workflow and risk areas | `REVIEW_GUIDE.md` |
| Test fixtures | `tests/conftest.py`, `tests/data/` |
| Kernel taxonomy and tunable thresholds (sklearn warning cutoff, spectral threshold) | `src/cellmapper/constants.py` |
| Optional-dependency gating | `src/cellmapper/check.py` |
| Method-level behavior (parameters, return shapes) | docstrings in `src/cellmapper/model/` |
| Topic | Source of truth |
| ----------------------------------------------------------------------------------- | ----------------------------------------------------- |
| User-facing overview, use cases, quickstart | `README.md` |
| Public API reference | `docs/api.md` and autosummary under `docs/generated/` |
| Tutorials (query→reference, spatial mapping, spatial smoothing, data denoising) | `docs/notebooks/tutorials/` |
| Contributor setup, environments, docs build | `docs/contributing.md` |
| Release notes | `docs/changelog.md` |
| PR review workflow and risk areas | `REVIEW_GUIDE.md` |
| Test fixtures | `tests/conftest.py`, `tests/data/` |
| Kernel taxonomy and tunable thresholds (sklearn warning cutoff, spectral threshold) | `src/cellmapper/constants.py` |
| Optional-dependency gating | `src/cellmapper/check.py` |
| Method-level behavior (parameters, return shapes) | docstrings in `src/cellmapper/model/` |

## Review Guidelines

Expand Down
27 changes: 24 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,31 @@ and this project adheres to [Semantic Versioning][].
## [Unreleased]

### Changed

- Dropped Python 3.11 support; the minimum supported version is now Python 3.12, aligning with `cellrank` (≥2.1 requires Python ≥3.12) and unpinning the `tutorials` extra from the old `cellrank` 2.0.7 {pr}`81`
- The `gpcca-fast` dependency group now delegates `petsc4py`/`slepc4py` to `cellrank[petsc]>=2.3.1` (mpi4py-free) instead of hardcoding them, keeping only an explicit `slepc` to work around slepc4py's missing runtime metadata {pr}`82`

### Fixed

- Fixed intermittent `OSError: Can't synchronously read data (filter returned failure during read)` when running the test suite under `pytest -n auto`, caused by xdist workers racing on scanpy's shared `pbmc3k_raw.h5ad` dataset cache. Each worker now uses its own cache directory.

## [v0.2.5]

### Added

- Added `batch_size` parameter to `Kernel.compute_neighbors()` for backend-agnostic batching {pr}`60`
- Added `subset` parameter to `plot_confusion_matrix()` for filtering cells {pr}`60`
- Added Python 3.14 support {pr}`62`

### Changed

- Default postfixes now include underscore: `"_pred"` and `"_conf"` instead of `"pred"` and `"conf"` {pr}`60`
- Switched from MathJax to KaTeX for documentation math rendering {pr}`61`
- Updated GitHub Actions to latest versions (checkout v5, setup-uv v7) {pr}`61`
- Updated test matrix to Python 3.11/3.14 {pr}`62`

### Fixed

- Fixed `PackageNotFoundError` when checking rapids availability in conda environments {pr}`60`
- Fixed stale k-NN state when `compute_neighbors()` fails {pr}`60`
- Fixed `plot_confusion_matrix()` handling of NaN values in both y_true and y_pred {pr}`60`
Expand All @@ -41,59 +46,71 @@ and this project adheres to [Semantic Versioning][].
## [v0.2.4]

### Changed

- Deprecated Python 3.10 support {pr}`55`
- Updated to cookiecutter-scverse template v0.6.0 {pr}`54`

## [v0.2.3]

### Changed

- Improved returning probabilities (after mapping categorical obs fields) to always return a DataFrame {pr}`49`

### Added

- Add the possibility to adjust the library size after `.map_layers` {pr}`50`
- Added the option to turn off post-processing of the presence scores, so that they can be first smoothed and then processed, like in HNOCA-tools {pr}`51`

## [v0.2.2]

### Added

- Enabled subsetting categories before mapping .obs values {pr}`46`

### Changed

- Updated the README a bit {pr}`44`
- Updated tutorials to work with new parameter names {pr}`43`

### Fixed

- Fixed a small bug where hvg masks would not be propagated correctly to joint pca computation {pr}`48`

## [v0.2.1]

### Changed

- Move some duplicated docstrings into a central _docs.py file {pr}`41`

### Added

- Added some tests for edge cases in the `MappingOperator` class {pr}`41`
- Treat faiss-cpu and faiss-gpu separately {pr}`41`


## [v0.2.0]

### Added

- Added a tutorial on same-modality query to reference mapping {pr}`38`
- Added a tutorial on data smoothing {pr}`37`
- Added an option to return the mapping probabilities for categorical `.obs` mapping {pr}`39`
- Added a `MappingOperator` class which allows for iterative mapping matrix applicatino in self-mapping mode {pr}`35`
- Add the `umap` method to compute symmetric k-NN connectivities in self-mapping mode {pr}`34`

### Changed
- Refectored the neighbors classes into a `Neighobrs` and a `Kernel` class and moved symmetrization into the `Kernel` class {pr}`36`

- Refectored the neighbors classes into a `Neighobrs` and a `Kernel` class and moved symmetrization into the `Kernel` class {pr}`36`

## [v0.1.4]

### Changed
- Rename mapping methods to `map_obs`, `map_obsm`, and `map_layers`, and improve support for numerical `.obs` annotations {pr}`30`.

- Rename mapping methods to `map_obs`, `map_obsm`, and `map_layers`, and improve support for numerical `.obs` annotations {pr}`30`.

## [v0.1.3]

### Added

- Added a tutorial on spatial contextualization and niche identification {pr}`23`.
- Implemented a self-mapping mode with only a query dataset {pr}`21`.
- Allow importing a pre-computed dataset of transfered expression values {pr}`21`.
Expand All @@ -104,6 +121,7 @@ and this project adheres to [Semantic Versioning][].
## [v0.1.2]

### Added

- Included tests for the `check` module, and more tests for the main classes {pr}`15`.
- Implemented the computation of presence scores, following HNOCA-tools {pr}`16`.
- Added a `groupby` parameter to expression transfer evaluation {pr}`16`.
Expand All @@ -113,10 +131,13 @@ and this project adheres to [Semantic Versioning][].
## [v0.1.1]

### Changed

- Switched to `vcs`-based versioning {pr}`5`.

### Added

- Added PyPI badge.

## [v0.1.0]

Initial package release.
13 changes: 6 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ The core idea of `CellMapper` is to separate the method (k-NN graph with some ke
You need to have 🐍 Python 3.12 or newer installed on your system.
If you don't have Python installed, we recommend installing [uv][].

There are two alternative options to install ``cellmapper``:
There are two alternative options to install `cellmapper`:

- 🚀 Install the latest release from [PyPI][]:

Expand All @@ -51,9 +51,10 @@ There are two alternative options to install ``cellmapper``:

## 🏁 Getting started

This package assumes that you have ``query`` and ``reference`` AnnData objects, with a joint embedding computed and stored in ``.obsm``. While we implement some baseline approaches to compute joint embeddings (PCA and a fast reimplementation of CCA), we typically expect you to provide a pre-computed joint embedding from some task-specific representation learning tools, 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!
This package assumes that you have `query` and `reference` AnnData objects, with a joint embedding computed and stored in `.obsm`. While we implement some baseline approaches to compute joint embeddings (PCA and a fast reimplementation of CCA), we typically expect you to provide a pre-computed joint embedding from some task-specific representation learning tools, 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!

With a joint embedding in `.obsm["X_joint"]` at hand, the simplest way to use `CellMapper` is as follows:

With a joint embedding in ``.obsm["X_joint"]`` at hand, the simplest way to use ``CellMapper`` is as follows:
```Python
from cellmapper import CellMapper

Expand All @@ -62,7 +63,7 @@ cmap = CellMapper(query, reference).map(
)
```

This will transfer data from the reference to the query dataset, including celltype labels stored in ``reference.obs``, a UMAP embedding stored in ``reference.obsm``, and expression values stored in ``reference.X``.
This will transfer data from the reference to the query dataset, including celltype labels stored in `reference.obs`, a UMAP embedding stored in `reference.obsm`, and expression values stored in `reference.X`.

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. The tool also implements a `self-mapping` mode (only a query object, no reference), which is useful for spatial contextualization and data denoising. Check out the 📚 [docs][] to learn more.

Expand All @@ -75,6 +76,7 @@ See the [changelog][].
If you found a bug, please use the [issue tracker][].

## 📖 Citation

Please use our [zenodo][] entry to cite this software.

[uv]: https://github.com/astral-sh/uv
Expand All @@ -89,15 +91,12 @@ Please use our [zenodo][] entry to cite this software.
[pypi]: https://pypi.org/project/cellmapper/
[downloads]: https://pepy.tech/project/cellmapper
[zenodo]: https://doi.org/10.5281/zenodo.15683594

[faiss]: https://github.com/facebookresearch/faiss
[pynndescent]: https://github.com/lmcinnes/pynndescent
[sklearn]: https://scikit-learn.org/stable/modules/neighbors.html
[rapids]: https://docs.rapids.ai/api/cuml/stable/api/#nearest-neighbors

[ingest]: https://scanpy.readthedocs.io/en/stable/generated/scanpy.tl.ingest.html
[HNOCA-tools]: https://devsystemslab.github.io/HNOCA-tools/

[GimVI]: https://docs.scvi-tools.org/en/stable/api/reference/scvi.external.GIMVI.html#
[ENVI]: https://scenvi.readthedocs.io/en/latest/#
[GLUE]: https://scglue.readthedocs.io/en/latest/
Expand Down
28 changes: 14 additions & 14 deletions REVIEW_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,25 @@ Pointers only — see `AGENTS.md` for the actual invariants.

Tests mirror the source tree.

| Changed path | Primary tests |
|--------------|---------------|
| `src/cellmapper/model/cellmapper.py` | `tests/model/test_query_to_reference_mapping.py`, `tests/model/test_self_mapping.py` |
| `src/cellmapper/model/kernel.py` | `tests/model/test_kernel.py` |
| `src/cellmapper/model/mapping_operator.py` | `tests/model/test_mapping_operator.py` |
| `src/cellmapper/model/neighbors.py` | `tests/model/test_neighbors.py` |
| `src/cellmapper/model/embedding.py` | `tests/model/test_embedding.py` |
| `src/cellmapper/model/evaluate.py` | `tests/model/test_evaluate.py` |
| `src/cellmapper/model/_knn_backend.py` | `tests/model/test_neighbors.py`, `tests/model/test_kernel.py` |
| `src/cellmapper/check.py` | `tests/test_check.py` |
| `src/cellmapper/utils.py` | `tests/test_utils.py` |
| End-to-end behavioral change | also `tests/test_basic.py` |
| Fixture changes | `tests/conftest.py`, `tests/data/` |
| Changed path | Primary tests |
| ------------------------------------------ | ------------------------------------------------------------------------------------ |
| `src/cellmapper/model/cellmapper.py` | `tests/model/test_query_to_reference_mapping.py`, `tests/model/test_self_mapping.py` |
| `src/cellmapper/model/kernel.py` | `tests/model/test_kernel.py` |
| `src/cellmapper/model/mapping_operator.py` | `tests/model/test_mapping_operator.py` |
| `src/cellmapper/model/neighbors.py` | `tests/model/test_neighbors.py` |
| `src/cellmapper/model/embedding.py` | `tests/model/test_embedding.py` |
| `src/cellmapper/model/evaluate.py` | `tests/model/test_evaluate.py` |
| `src/cellmapper/model/_knn_backend.py` | `tests/model/test_neighbors.py`, `tests/model/test_kernel.py` |
| `src/cellmapper/check.py` | `tests/test_check.py` |
| `src/cellmapper/utils.py` | `tests/test_utils.py` |
| End-to-end behavioral change | also `tests/test_basic.py` |
| Fixture changes | `tests/conftest.py`, `tests/data/` |

## Testing

- **New code** should be covered. Reuse fixtures from `tests/conftest.py`; prefer `pytest.mark.parametrize`; favor few meaningful tests over many redundant ones.
- **Failing CI** is not to be waved through. Distinguish critical regressions from flakes; escalate critical ones.
- **Modified tests** — scrutinize *how*. Relaxed tolerances, removed assertions, deleted cases, or loosened matrices are red flags. Require explicit justification in the PR body.
- **Modified tests** — scrutinize _how_. Relaxed tolerances, removed assertions, deleted cases, or loosened matrices are red flags. Require explicit justification in the PR body.

## Documentation Impact

Expand Down
2 changes: 1 addition & 1 deletion docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ the [scientific Python tutorials][], or the [scanpy developer guide][].
[scientific Python tutorials]: https://learn.scientific-python.org/development/tutorials/
[scanpy developer guide]: https://scanpy.readthedocs.io/en/latest/dev/index.html

:::{tip} The *hatch* project manager
:::{tip} The _hatch_ project manager

We highly recommend to familiarize yourself with [`hatch`][hatch].
Hatch is a Python project manager that
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ classifiers = [
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Programming Language :: Python :: 3.15",
]
dynamic = [ "version" ]
dependencies = [
Expand Down Expand Up @@ -209,11 +210,11 @@ strict = true
testpaths = [ "tests" ]

[tool.coverage]
run.source = [ "cellmapper" ]
run.omit = [
"**/test_*.py",
]
run.patch = [ "subprocess" ]
run.source = [ "cellmapper" ]

[tool.cruft]
skip = [
Expand Down
Loading