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 grassmann_sc

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

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

# ---- Grassmann Wasserstein Clustering ----
labels, info = grassmann_sc(
    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

grassmann_sc(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.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 GOTClust 0.1.0
File Size Uploaded Provenance Actions
gotclust-0.1.0.tar.gz 8.5 kB Without provenance Details for gotclust-0.1.0.tar.gz

Built distribution (wheel)

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

Total release size: 17.1 kB

Release files / gotclust-0.1.0.tar.gz

Download URL gotclust-0.1.0.tar.gz
Size 8.5 kB
Tags Source
SHA-256 checksum
How to use checksums
02f8547484c828dbbc5d1ff43838ea33311b1603d2b98d70ad15efcb56c44452
BLAKE2b-256 checksum
How to use checksums
64490d3ba5230e1b068308d24a8f1bc03a04f74568d89986e8a27ac876ba2e08
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.0-py3-none-any.whl

Download URL gotclust-0.1.0-py3-none-any.whl
Size 8.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
613b4c26063fd770accca3df0c2cd2f434a0e1b7a5c1afdee7dcf48c975b6c3d
BLAKE2b-256 checksum
How to use checksums
8b624dc8e2e618dc1c6ecea48b7217fe21de9db276d0f30e47860706495a190d
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.0

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