Skip to main content

Compute optimal transport based distances and mappings between point clouds, especially for cytometry data.

otcyto is a Python package for computing and visualizing optimal transport-based distances and mappings between point clouds, with a focus on cytometry-like data. It combines PyTorch, GeomLoss, and optional PyKeOps acceleration to deliver GPU-accelerated performance, clear APIs, and plotting tools for inspecting results.

Overview

The package is designed for researchers and engineers who need to:

  • Quantify distributional differences between samples

  • Map one sample onto another via an optimal transport plan or Brenier map.

  • Visualize the mapping process and alignment quality.

  • Integrate optimal transport distances into larger cytometry analysis pipelines.

Core functionality is centered on the OTDPairwise class for pairwise optimal transport distances, supported by utilities for generating synthetic data and producing high-quality figures.

Features

  • Pairwise Optimal Transport Distance (OTD) computation between lists of point clouds.

  • Multiple output formats — PyTorch tensor, NumPy array, and pandas DataFrame.

  • GPU acceleration via CUDA, with automatic device placement.

  • Optional PyKeOps backend for large-scale speedups.

  • Brenier map computation for geometric interpretation of transport.

  • Plotting utilities for OTD matrices, Brenier maps, and point cloud overlays.

  • Synthetic data generators for testing and demonstration.

Installation

Install from PyPI:

pip install otcyto

Or with uv for fast, reproducible installs:

uv pip install otcyto

Optional acceleration:

  • PyKeOps for GeomLoss speedups:

    pip install pykeops

Verify installation:

from otcyto.check_pykeops import check_pykeops
assert check_pykeops()

Minimal Working Example

Compute a 1x2 OTD matrix between one source and two shifted targets, plot the OTD heatmap, and visualize point clouds.

from otcyto.geomloss.create_sphere import create_sphere
from otcyto.otd_pairwise import OTDPairwise
from otcyto.plot.figure_clouds import figure_clouds

# Create synthetic point clouds
n = 1_000
source = create_sphere(n)[0]
target_1 = create_sphere(n)[0] + 1
target_2 = create_sphere(n)[0] + 2

# Compute pairwise OTD
otd = OTDPairwise([source], [target_1, target_2])
otd.compute()

# Inspect results
print(otd.otd_df)

# Plot and save OTD matrix
otd.plot().savefig("otd_matrix.png")

# Optional: plot Brenier map for first target
otd.plot_brenier(0, 0).savefig("brenier_map.png")
Optimal Transport Distance matrix Brenier map visualization

Usage Notes

  • The loss parameter of OTDPairwise accepts a custom geomloss.SamplesLoss instance for full control over Sinkhorn parameters.

Metadata

Release files for otcyto 0.1.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 otcyto 0.1.0
File Size Uploaded
otcyto-0.1.0.tar.gz 242.7 kB Details

Built distribution (wheel)

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

Total release size: 259.0 kB

Release files / otcyto-0.1.0.tar.gz

Download URL otcyto-0.1.0.tar.gz
Size 242.7 kB
Tags Source
SHA-256 checksum
How to use checksums
289cfa5480e8a2d067338fa575e46811f61e8182fca295454a41c1f152a8484d
BLAKE2b-256 checksum
How to use checksums
5f0b55090f925c2fe0d3f23fb091471102febebda5d10dcbbe7b56917bc396bb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.9

Release files / otcyto-0.1.0-py3-none-any.whl

Download URL otcyto-0.1.0-py3-none-any.whl
Size 16.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4c7739ca3448588bbfb5e24b32a6cefc0de937e859451bef12faa95d31c5f46c
BLAKE2b-256 checksum
How to use checksums
79b7601734d51102c962dc237baebb58c1028ddb41366c960f08a70bd36715a3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.9

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

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