Skip to main content

GOTClust

Grassmann-Optimal-Transport Clustering for Single-Cell Data

A subspace-aware clustering framework that represents each cell by a local principal subspace (capturing local transcriptional regulatory structure), then clusters these subspaces on the Grassmann manifold.


Why GOTClust?

Aspect Vector-space methods (Leiden, KMeans) GOTClust
Object being clustered Cell vector (expression values) Local subspace (covariance structure)
Distance Euclidean / cosine Grassmann projection distance
Rotations Sensitive Invariant
Batch robustness Low High (rotation-invariant)
Biological interpretation "Cells look similar" "Regulatory programs look similar"

GOTClust provides two algorithms:

  • GSC — Grassmann Spectral Clustering
  • GWC — Grassmann Wasserstein Clustering (Frechet-mean barycenters)

Installation

pip install GOTClust

With GPU acceleration (via the underlying grassmann-ot backends):

pip install GOTClust[gpu]

Quick start

import numpy as np
from gotclust import gotclust

# H: expression / composition matrix, shape (n_genes, n_cells)
H = np.random.randn(50, 300)

# ---- Grassmann Spectral Clustering (recommended) ----
labels, info = gotclust(
    H, n_clusters=4, method="spectral",
    k=30, p=3, backend="pca", affinity="local", random_state=42,
)

# ---- Grassmann Wasserstein Clustering ----
labels, info = gotclust(
    H, n_clusters=4, method="wasserstein",
    k=30, p=3, backend="pca", n_iter=50, init="kmeans++", random_state=42,
)

Returned info

Key Shape Description
U_list list[(r,p)] Per-cell Grassmann points
C (n,n) Pairwise Grassmann cost matrix
affinity (n,n) Affinity matrix (GSC only)
centroids list[(r,p)] Cluster barycenters (GWC only)
inertia list[float] Inertia history (GWC only)

Algorithm reference

gotclust(H, n_clusters, method, **kwargs)

Unified entry point.

  • method="spectral" → forwards to grassmann_spectral_clustering
  • method="wasserstein" → forwards to grassmann_wasserstein_clustering

grassmann_spectral_clustering(...)

Pipeline:

  1. cells_to_grassmann → local subspaces U_i
  2. grassmann_cost_matrix → cost matrix C
  3. grassmann_affinity → affinity matrix A (Zelnik-Perona local scaling)
  4. sklearn.SpectralClustering(affinity="precomputed")

grassmann_wasserstein_clustering(...)

Lloyd-style alternating optimization:

  • E-step — assign each cell to the nearest cluster center (Grassmann projection distance)
  • M-step — update each center to the Frechet mean of its members

grassmann_frechet_mean(V_list, weights, p)

Closed-form Grassmann barycenter: eigen-decomposition of Σ w_j V_j V_j^T, take top-p eigenvectors.

grassmann_affinity(C, method, sigma)

Build an affinity matrix from a Grassmann cost matrix. method ∈ {"local", "global", "knn"}.


Parameters

Parameter Default Meaning
k 30 Neighborhood size for local subspace construction
p 3 Subspace dimension
backend "pca" Subspace construction backend (loop/pca/batched/faiss/subsampling)
affinity "local" Affinity construction (local/global/knn)
n_iter 50 Lloyd iterations (GWC)
init "kmeans++" Centroid initialization (GWC)

Citation

Coming soon.


License

MIT

Metadata

Release files for GOTClust 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for GOTClust 0.1.1
File Size Uploaded Provenance Actions
gotclust-0.1.1.tar.gz 8.6 kB Without provenance Details for gotclust-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for GOTClust 0.1.1
File Interpreter ABI Platform Actions
gotclust-0.1.1-py3-none-any.whl Python 3 none any Details for gotclust-0.1.1-py3-none-any.whl

Total release size: 17.2 kB

Release files / gotclust-0.1.1.tar.gz

Download URL gotclust-0.1.1.tar.gz
Size 8.6 kB
Tags Source
SHA-256 checksum
How to use checksums
a9901a2be795b4e092e00ecf8590e140be757ed750998b062577b69226deb35b
BLAKE2b-256 checksum
How to use checksums
529962ef1a2336fc841726b8f3ba063ecf999e68e54dcc77b5dd16c5ed1b5080
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.18

Release files / gotclust-0.1.1-py3-none-any.whl

Download URL gotclust-0.1.1-py3-none-any.whl
Size 8.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
313659590400940fe46c6c3d6d6abb6a16587dce2f06a8fef13fcee9db467594
BLAKE2b-256 checksum
How to use checksums
bc354c6543ba0b46f03ad367cc829b54967295b5fd4174122a77496342d4f8f9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.18

Security for GOTClust 0.1.1

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.

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