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")
Usage Notes
The loss parameter of OTDPairwise accepts a custom geomloss.SamplesLoss instance for full control over Sinkhorn parameters.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
289cfa5480e8a2d067338fa575e46811f61e8182fca295454a41c1f152a8484d
|
|
| MD5 |
c3e61a3d8d75b43a7915599899342212
|
|
| BLAKE2b-256 |
5f0b55090f925c2fe0d3f23fb091471102febebda5d10dcbbe7b56917bc396bb
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4c7739ca3448588bbfb5e24b32a6cefc0de937e859451bef12faa95d31c5f46c
|
|
| MD5 |
b6ef00cfbf3b2ff63e5be2f3b0c40cd9
|
|
| BLAKE2b-256 |
79b7601734d51102c962dc237baebb58c1028ddb41366c960f08a70bd36715a3
|