Skip to main content

CellMapper

Tests Coverage Pre-commit.ci PyPI Documentation Downloads Zenodo

k-NN-based mapping of cells across representations to transfer 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.

Inspired by previous tools, including scanpy's ingest and the HNOCA-tools packages. Check out the 📚 docs to learn more, in particular our tutorials.

✨ Key use cases

  • 🧬 Transfer cell type labels and expression values from dissociated to spatial datasets.
  • ↔️ Transfer embeddings between arbitrary query and reference datasets.
  • 📊 Compute presence scores for query datasets in large reference atlasses.
  • 🗺️ Identify niches in spatial datasets by contextualizing latent spaces in spatial coordinates.
  • 📈 Evaluate the results of transferring labels, embeddings and feature spaces using a variety of metrics.

The core idea of CellMapper is to separate the method (k-NN graph with some kernel applied to get a mapping matrix) from the application (mapping across arbitrary representations), to be flexible and fast. The tool currently supports pynndescent, sklearn, faiss and rapids for neighborhood search, implements a variety of graph kernels, and is closely integrated with AnnData objects.

📦 Installation

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:

  • 🚀 Install the latest release from PyPI:

    pip install cellmapper
    
  • 🛠️ Install the latest development version:

    pip install git+https://github.com/quadbio/cellmapper.git@main
    

🏁 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!

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

from cellmapper import CellMapper

cmap = CellMapper(query, reference).map(
    use_rep="X_joint", obs_keys="celltype", obsm_keys="X_umap", layer_key="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.

📝 Release notes

See the release notes.

📬 Contact

If you found a bug, please use the issue tracker.

📖 Citation

Please use our zenodo entry to cite this software.

Metadata

Release files for cellmapper 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cellmapper 0.3.0
File Size Uploaded Provenance Actions
cellmapper-0.3.0.tar.gz 10.7 MB With provenance Details for cellmapper-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for cellmapper 0.3.0
File Interpreter ABI Platform Actions
cellmapper-0.3.0-py3-none-any.whl Python 3 none any Details for cellmapper-0.3.0-py3-none-any.whl

Total release size: 10.8 MB

Release files / cellmapper-0.3.0.tar.gz

Download URL cellmapper-0.3.0.tar.gz
Size 10.7 MB
Tags Source
SHA-256 checksum
How to use checksums
9cdff05c1984b4687a534227bf67839786a68a6086b8d2373703bf0b52855f53
BLAKE2b-256 checksum
How to use checksums
b3e38f019a129511c423f7d6824eff11429ba86c829b88e24f2f4a4655c5e2f3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.

Transparency log

Release files / cellmapper-0.3.0-py3-none-any.whl

Download URL cellmapper-0.3.0-py3-none-any.whl
Size 53.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3c1a40ff385920c7eaa811f57a0cb90271b08205648ff0dfab9ac4238839edde
BLAKE2b-256 checksum
How to use checksums
52ae890e7b3dda162e6d8d352266f6833fdbdf2d978df00f8c836a22a7cdfdf7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.

Transparency log

Security for cellmapper 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for cellmapper-0.3.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page