Skip to main content

gotmap-benchmark

Benchmark pipeline for gotmap — compare query-to-reference atlas mapping methods on real and synthetic single-cell data and get quantitative results + plots out of the box.

Positioning: this benchmark evaluates query → reference mapping quality, not symmetric batch mixing. It is designed for the gotmap use case (map a query onto a fixed atlas), not to compete with integration-tool comparisons.


Install

pip install gotmap grassmann-ot scanpy
# optional, for more baselines:
pip install scvi-tools harmonypy bbknn

Quick start (Python)

import scanpy as sc
from gotmap_benchmark import BenchmarkPipeline

adata = sc.datasets.pbmc68k_reduced()
if "X_pca" not in adata.obsm:
    sc.pp.normalize_total(adata); sc.pp.log1p(adata); sc.pp.pca(adata, n_comps=30)

label_key = "bulk_labels" if "bulk_labels" in adata.obs.columns else "louvain"
if label_key not in adata.obs.columns:
    sc.tl.louvain(adata, resolution=0.8, key_added="louvain"); label_key = "louvain"

import numpy as np
from sklearn.model_selection import train_test_split

idx = np.arange(adata.n_obs)
strat = adata.obs[label_key].values if label_key in adata.obs.columns else None
train_idx, test_idx = train_test_split(
    idx, test_size=0.3, shuffle=True, random_state=42, stratify=strat
)
ref, query = adata[train_idx].copy(), adata[test_idx].copy()

# --- alternative: split by batch (preferred for atlas mapping) ---
# ref, query = sc.pp.train_test_split(adata, test_size=0.3, random_state=42,
                                    stratify=label_key)

bench = BenchmarkPipeline(ref, query, label_key=label_key, use_rep="X_pca",
                          methods=["gotmap_nn", "gotmap_knn", "direct_knn"])
bench.run()
bench.save_results("benchmark_metrics.csv")
bench.plot(save="benchmark_plot.png")

Quick start (CLI)

gotmap-benchmark --ref ref.h5ad --query query.h5ad --label cell_type \
    --use-rep X_pca --methods gotmap_nn direct_knn \
    --output ./results

Tabula Sapiens benchmark

examples/benchmark_tabula_sapiens.py holds out one donor as the query and uses every other donor as the reference atlas. It supports both a local h5ad and a live slice from the CELLxGENE Census. Install the Census extra with pip install "gotmap-benchmark[tabula-sapiens]".

# local h5ad (recommended)
python examples/benchmark_tabula_sapiens.py \
    --h5ad tabula_sapiens.h5ad \
    --query_donor Donor1 \
    --tissues Lung,Liver \
    --subsample 5000

# live Census slice
python examples/benchmark_tabula_sapiens.py \
    --query_donor Donor1 \
    --tissues Lung \
    --subsample 30000

Included methods

Key Method Notes
gotmap_nn gotmap, neural-network mapping uses anchors + gamma
gotmap_knn gotmap, kNN mapping non-parametric
scArches scVI + scArches needs scvi-tools
harmony_project Harmony project needs R harmony + rpy2
BBKNN_align BBKNN symmetric, then extracts query
direct_knn kNN (no correction) baseline

Metrics reported

  • Label Transfer Accuracy / Weighted F1 — ground-truth label recovery
  • kNN Preservation (kNP) — overlap of reference-neighbourhoods before/after mapping
  • Cell-type Silhouette — separation of types in mapped space
  • Mean Confidence / Mapping Rate — placement certainty
  • Runtime (s)

Output

  • benchmark_metrics.csv — one row per method
  • benchmark_plot.png — horizontal bar chart per metric
  • bench.results_ — full per-method outputs (mapped AnnData, labels, confidence)

Project layout

gotmap-benchmark/
├── pyproject.toml
├── README.md
├── gotmap_benchmark/
│   ├── __init__.py
│   ├── cli.py            # command-line entry point
│   ├── pipeline.py       # BenchmarkPipeline + plotting
│   ├── methods.py        # method wrappers
│   ├── metrics.py        # evaluation metrics
│   └── datasets.py       # dataset loaders + ref/query splitting
└── examples/
    ├── run_pbmc_benchmark.py
    └── benchmark_tabula_sapiens.py

License: MIT

Metadata

Release files for gotmap-benchmark 0.4.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 gotmap-benchmark 0.4.0
File Size Uploaded Provenance Actions
gotmap_benchmark-0.4.0.tar.gz 14.4 kB Without provenance Details for gotmap_benchmark-0.4.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for gotmap-benchmark 0.4.0
File Interpreter ABI Platform Actions
gotmap_benchmark-0.4.0-py3-none-any.whl Python 3 none any Details for gotmap_benchmark-0.4.0-py3-none-any.whl

Total release size: 30.0 kB

Release files / gotmap_benchmark-0.4.0.tar.gz

Download URL gotmap_benchmark-0.4.0.tar.gz
Size 14.4 kB
Tags Source
SHA-256 checksum
How to use checksums
af9209a8de4e08c29705a952e1eaf11d7f949416c3c005b6dd5b5b63d3064c2b
BLAKE2b-256 checksum
How to use checksums
1b3b2e7e26782a764302dc49cd5694d73469ddfcce6f9b425ec42643f0be05d3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.18

Release files / gotmap_benchmark-0.4.0-py3-none-any.whl

Download URL gotmap_benchmark-0.4.0-py3-none-any.whl
Size 15.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
31bf63bf39b80acfcb00703deeeb9bf203c8eb51d61ce25f93753c16da1de626
BLAKE2b-256 checksum
How to use checksums
42d8ee71ae71f2b5ca7c435e88927c6fc85ffacd55952dbf73bf8d6d422c65c0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.18

Security for gotmap-benchmark 0.4.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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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