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
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 methodbenchmark_plot.png— horizontal bar chart per metricbench.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
License: MIT
Metadata
Release files for gotmap-benchmark 0.2.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| gotmap_benchmark-0.2.3.tar.gz | 13.4 kB | Without provenance | Details for gotmap_benchmark-0.2.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| gotmap_benchmark-0.2.3-py3-none-any.whl | Python 3 | none | any | Details for gotmap_benchmark-0.2.3-py3-none-any.whl |
Total release size: 27.6 kB
Release files / gotmap_benchmark-0.2.3.tar.gz
| Download URL | gotmap_benchmark-0.2.3.tar.gz |
|---|---|
| Size | 13.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e402eac426affcb31c8cea24eff87729f5c23cb4c0562ad70f1bbd2ce514f24a
|
|
BLAKE2b-256 checksum How to use checksums |
719a43425920c995c6a92e53893626fab250fffc8593f00998d725a1daf261c2
|
| 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.2.3-py3-none-any.whl
| Download URL | gotmap_benchmark-0.2.3-py3-none-any.whl |
|---|---|
| Size | 14.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0b5fae3b7eee9ba9d70b9e22ab5a044ea1c17923f67bd69a2d6928939162afd2
|
|
BLAKE2b-256 checksum How to use checksums |
d82773d23590964bc5dd52b77337487760e0dbfad7ec1dea750beb1548188b92
|
| 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.2.3
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.