Metadata-Version: 2.4
Name: gotvis
Version: 0.1.0
Summary: Grassmann / Optimal-Transport embeddings for single-cell data (Sinkhorn-gamma aware)
Author: GOTVis Developers
License: MIT
Project-URL: Homepage, https://github.com/ZengFLab/gotvis
Project-URL: Documentation, https://github.com/ZengFLab/gotvis#readme
Project-URL: Repository, https://github.com/ZengFLab/gotvis
Project-URL: Issues, https://github.com/ZengFLab/gotvis/issues
Keywords: single-cell,embedding,visualization,grassmann-manifold,optimal-transport,sinkhorn,single-cell-rna-seq,computational-biology
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
Classifier: Topic :: Scientific/Engineering :: Mathematics
Classifier: Topic :: Scientific/Engineering :: Visualization
Classifier: Operating System :: OS Independent
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy>=1.20
Requires-Dist: scipy>=1.6
Provides-Extra: gotclust
Requires-Dist: grassmann-ot>=0.3.0; extra == "gotclust"
Provides-Extra: anndata
Requires-Dist: anndata>=0.8; extra == "anndata"
Provides-Extra: plot
Requires-Dist: matplotlib>=3.3; extra == "plot"
Requires-Dist: seaborn>=0.11; extra == "plot"
Provides-Extra: tsne
Requires-Dist: scikit-learn>=0.24; extra == "tsne"
Provides-Extra: opentsne
Requires-Dist: openTSNE>=1.0; extra == "opentsne"
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: pytest-cov>=4.0; extra == "dev"
Requires-Dist: numpy>=1.20; extra == "dev"
Requires-Dist: scipy>=1.6; extra == "dev"
Requires-Dist: scikit-learn>=0.24; extra == "dev"
Requires-Dist: POT>=0.9.0; extra == "dev"
Provides-Extra: all
Requires-Dist: anndata>=0.8; extra == "all"
Requires-Dist: matplotlib>=3.3; extra == "all"
Requires-Dist: seaborn>=0.11; extra == "all"
Requires-Dist: scikit-learn>=0.24; extra == "all"
Requires-Dist: grassmann-ot>=0.3.0; extra == "all"
Dynamic: license-file

# GOTVis

**Grassmann / Optimal-Transport embeddings for single-cell data.**

GOTVis is the visualisation companion to
[GOTClust](https://github.com/gotclust/gotclust).  It turns the objects
produced by Grassmann-optimal-transport clustering — above all the
**Sinkhorn transport plan `gamma`** returned by GSSC — into 2-D / 3-D
coordinates suitable for plotting, downstream QC and publication figures.

## Why a separate package?

GOTClust ships a single functional-proximity embedding
(`grassmann_functional_embedding`).  That embedding is *cell-centric*: it
preserves Grassmann cost C and says nothing about cluster membership.
GSSC (Grassmann Sinkhorn Spectral Clustering) introduces a **prototype
membership matrix `gamma`**, which carries a completely different kind of
geometry — simplex geometry over prototypes.  Rather than overload
GOTClust's embedding namespace, GOTVis owns that geometry and keeps the
dependency surface tiny.

## Install

```bash
pip install gotvis                 # core: numpy + scipy only
pip install "gotvis[all]"         # + anndata, sklearn, plotting, grassmann-ot
pip install "gotvis[tsne]"        # + scikit-learn TSNE backend
pip install "gotvis[opentsne]"    # + openTSNE backend
```

## What's inside

| Embedding | Input | Geometry | Cost |
|---|---|---|---|
| `sinkhorn_embedding(method="svd")` | gamma | truncated SVD of centred gamma — one axis per membership direction | O(n m²) |
| `sinkhorn_embedding(method="barycentric")` | gamma | Aitchison ilr / clr on the (m−1)-simplex | O(n m) |
| `sinkhorn_embedding(method="spectral")` | gamma | Laplacian eigenmaps on ΓΓᵀ / Jensen-Shannon affinity | O(n² m) |
| `gammagram_embedding()` | gamma | MDS / t-SNE on ‖gᵢ−gⱼ‖ | O(n²) |
| `functional_embedding()` | H / U_list / C | Laplacian Eigenmaps or classical MDS on Grassmann cost | O(n²) |
| `mds_embedding()` / `tsne_embedding()` | any distance | generic fallback | O(n³)/O(n²) |

## Quick start

### From a Sinkhorn gamma

```python
import numpy as np
import gotvis

# gamma: (n_cells, n_prototypes) non-negative soft assignment
Y = gotvis.sinkhorn_embedding(gamma, method="svd")
Y = gotvis.sinkhorn_embedding(gamma, method="barycentric", transform="ilr")
Y, info = gotvis.sinkhorn_embedding(
    gamma, method="spectral", affinity="kl", return_info=True
)
```

### Straight from a GOTClust GSSC run

```python
from gotclust import grassmann_sinkhorn_clustering
import gotvis

labels, info = grassmann_sinkhorn_clustering(H, n_clusters=5)

# info dict is accepted directly — no plumbing
Y = gotvis.sinkhorn_embedding(info, method="svd")
Y = gotvis.sinkhorn_embedding(info, method="barycentric")
```

### From Grassmann cost (classic functional proximity)

```python
Y = gotvis.functional_embedding(C=C, method="laplacian", knn=15)
Y = gotvis.functional_embedding(H=H, p=3, k=30, method="mds",
                                landmarks=500)
```

### With AnnData

```python
import gotvis.tools as gt

gt.gamma_from_gotclust(info, adata)              # adata.uns["gamma"]
gt.embed(adata, method="svd", key_added="X_gotvis")
ax = gt.plot_embedding(adata, color="cell_type", basis="X_gotvis")
```

## Design notes

* **Core is numpy + scipy only.**  `anndata`, `matplotlib`, `sklearn`,
  `POT` and `grassmann-ot` are all optional.  GOTVis never imports them at
  module scope.
* **`gamma` is validated everywhere.**  Negative, NaN/Inf and degenerate
  shapes raise immediately with an actionable message; all-zero rows are
  tolerated (they embed at the origin).
* **Sign / rotation ambiguity is handled.**  SVD axes are
  sign-stabilised so repeated runs agree.

## Relationship to GOTClust embeddings

GOTVis's `functional_embedding` is a **portable re-implementation** of
`gotclust.grassmann_functional_embedding` — same Laplacian-Eigenmaps /
MDS semantics, but with no GOTClust import required and an optional
landmark-MDS fast path.  The genuinely new content is the whole
`gamma`-based family, which GOTClust does not provide.

## License

MIT
