Skip to main content

Optimal transport for cytometry data

Project description

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.

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

otcyto-0.1.0.tar.gz (242.7 kB view details)

Uploaded Source

Built Distribution

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

otcyto-0.1.0-py3-none-any.whl (16.3 kB view details)

Uploaded Python 3

File details

Details for the file otcyto-0.1.0.tar.gz.

File metadata

  • Download URL: otcyto-0.1.0.tar.gz
  • Upload date:
  • Size: 242.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.9

File hashes

Hashes for otcyto-0.1.0.tar.gz
Algorithm Hash digest
SHA256 289cfa5480e8a2d067338fa575e46811f61e8182fca295454a41c1f152a8484d
MD5 c3e61a3d8d75b43a7915599899342212
BLAKE2b-256 5f0b55090f925c2fe0d3f23fb091471102febebda5d10dcbbe7b56917bc396bb

See more details on using hashes here.

File details

Details for the file otcyto-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: otcyto-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 16.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.9

File hashes

Hashes for otcyto-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4c7739ca3448588bbfb5e24b32a6cefc0de937e859451bef12faa95d31c5f46c
MD5 b6ef00cfbf3b2ff63e5be2f3b0c40cd9
BLAKE2b-256 79b7601734d51102c962dc237baebb58c1028ddb41366c960f08a70bd36715a3

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