Skip to main content

Tools for single-cell geometric analysis, clustering and visualization.

Project description

Latest PyPI version License: MIT Documentation Status Downloads Twitter

About TopoMetry

TopoMetry is a geometry-aware Python toolkit for exploring high-dimensional data via diffusion/Laplacian operators. It learns neighborhood graphs → Laplace–Beltrami–type operators → spectral scaffolds → refined graphs and then finds clusters and builds low-dimensional layouts for analysis and visualization.

  • AnnData/Scanpy wrappers for single-cell workflows
  • scikit-learn–style transformers with a high-level orchestrator
  • Fixed-time & multiscale spectral scaffolds (no .X mutation; namespaced outputs)
  • Operator-native metrics to quantify geometry preservation and Riemannian diagnostics to evaluate distortion in visualizations
  • Designed for large, diverse datasets (e.g., single-cell omics)

For background, see our preprint: https://doi.org/10.1101/2022.03.14.484134

Geometry-first rationale (short)

We approximate the Laplace–Beltrami operator (LBO) by learning well-weighted similarity graphs and their Laplacian/diffusion operators. The eigenfunctions of these operators form an orthonormal basis—the spectral scaffold—that captures the dataset’s intrinsic geometry across scales. This view connects to Diffusion Maps, Laplacian Eigenmaps, and related kernel eigenmaps, and enables downstream tasks such as clustering and graph-layout optimization with geometry preserved.

When to use TopoMetry

Use TopoMetry when you want:

  • Geometry-faithful representations beyond variance maximization (e.g., PCA)
  • Robust low-dimensional views and clustering from operator-grounded features
  • Quantitative operator-native metrics to compare methods and parameter choices
  • Reproducible, non-destructive pipelines (no mutation of adata.X)

Empirically, TopoMetry often outperforms PCA-based pipelines and stand-alone layouts. Still, let the data decide—TopoMetry includes metrics and reports to support evidence-based choices.

When not to use TopoMetry

  • Very small sample sizes where the manifold hypothesis is weak
  • Workflows needing streaming/online updates or inverse transforms (embedding new points without recomputing operators is not currently supported). If that’s critical, consider UMAP or parametric/autoencoder approaches—and you can still use TopoMetry to audit geometry or estimate intrinsic dimensionality to guide model design.

Installation

Prior to installing TopoMetry, make sure you have cmake, scikit-build and setuptools available in your system. If using Linux:

sudo apt-get install cmake
pip install scikit-build setuptools

Then you can install TopoMetry from PyPI:

pip install topometry

Tutorials and documentation

Check TopoMetry's documentation for tutorials, guided analyses and other documentation.

Minimal example (current API)

import scanpy as sc
import topo as tp

adata = sc.datasets.pbmc3k_processed()

# Fit TopoMetry end-to-end (non-destructive; outputs are namespaced)
tg = tp.sc.fit_adata(adata, n_jobs=1, verbosity=0, random_state=7)

# Plot some results
sc.pl.embedding(adata, basis='spectral_scaffold', color='topo_clusters')
sc.pl.embedding(adata, basis='TopoMAP', color='topo_clusters')
sc.pl.embedding(adata, basis='TopoPaCMAP', color='topo_clusters')

# Save cleanly (I/O-safe)
adata.write_h5ad("pbmc3k_topometry.h5ad")

Changelog

v1.1.0 — Batch integration and data mapping

  • CCA-anchor batch correction (Seurat v3-style) via tp.sc.run_cca_integration
  • Reference atlas persistence (save_cca_reference / load_cca_reference) and sequential query mapping (map_to_cca_reference)
  • High-level preparation utilities (prepare_for_integration, prepare_for_mapping, find_mapping_order)
  • Neighbourhood-based integration quality metrics (compute_all_integration_metrics: kNN purity, kNN mixing, iLISI, cLISI, ARI, NMI)

v1.0.x — Complete overhaul

  • Redesigned user API with tp.sc.fit_adata and tp.sc.run_and_report one-liner workflows
  • New utilities for single-cell analysis: intrinsic dimensionality, spectral selectivity, feature modes, graph-signal filtering, imputation
  • Overhauled geometry-preservation metrics (PF1, PJS, SP) and Riemannian diagnostics (pullback metric, deformation maps)
  • Full compatibility with the scverse ecosystem (scanpy, scVelo, AnnData)

Citation


@article {Oliveira2022.03.14.484134,
	author = {Oliveira, David S and Domingos, Ana I. and Velloso, Licio A},
	title = {TopoMetry systematically learns and evaluates the latent geometry of single-cell data},
	elocation-id = {2022.03.14.484134},
	year = {2025},
	doi = {10.1101/2022.03.14.484134},
	publisher = {Cold Spring Harbor Laboratory},
	URL = {https://www.biorxiv.org/content/early/2025/10/15/2022.03.14.484134},
	eprint = {https://www.biorxiv.org/content/early/2025/10/15/2022.03.14.484134.full.pdf},
	journal = {bioRxiv}
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

topometry-1.1.0.tar.gz (231.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

topometry-1.1.0-py3-none-any.whl (240.1 kB view details)

Uploaded Python 3

File details

Details for the file topometry-1.1.0.tar.gz.

File metadata

  • Download URL: topometry-1.1.0.tar.gz
  • Upload date:
  • Size: 231.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.18

File hashes

Hashes for topometry-1.1.0.tar.gz
Algorithm Hash digest
SHA256 5bb09958ba4d79078be3c6816070e60b2963ea1245537aabe3400f591c5ea4e4
MD5 254013702af5587a72e84cc4d92da411
BLAKE2b-256 a8071dfff7bdebb6ff6462e50c1fe13e1ff2a2d57ebb0b431e0fde5b33f1780e

See more details on using hashes here.

File details

Details for the file topometry-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: topometry-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 240.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.18

File hashes

Hashes for topometry-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1ed10960b8eb7df1ba3210a310697e87e317e7029867bb5b728ea3c7d2c5b9ac
MD5 257bd827fa4e1f32af3fb3e6f3889e4d
BLAKE2b-256 5f44eadab50f896d0ca28b61f98d754c29660539ce6b6a6c055f0c8a388bcef8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page