GOTDiff 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- gotdiff/__init__.py +72 -0
- gotdiff/_adata.py +205 -0
- gotdiff/_branching.py +188 -0
- gotdiff/_core.py +365 -0
- gotdiff/_grassmann_dist.py +324 -0
- gotdiff/_plot.py +175 -0
- gotdiff/_pseudotime.py +196 -0
- gotdiff/_trajectory.py +293 -0
- gotdiff-0.1.0.dist-info/METADATA +188 -0
- gotdiff-0.1.0.dist-info/RECORD +12 -0
- gotdiff-0.1.0.dist-info/WHEEL +4 -0
- gotdiff-0.1.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: GOTDiff
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Differentiation path / trajectory inference via geodesic distance on the Grassmann manifold, with AnnData support.
|
|
5
|
+
Project-URL: Homepage, https://github.com/ZengFLab/GOTDiff
|
|
6
|
+
Project-URL: Issues, https://github.com/ZengFLab/GOTDiff/issues
|
|
7
|
+
Author: GOTDiff Developers
|
|
8
|
+
License: MIT
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Keywords: differentiation,grassmann,optimal-transport,pseudotime,single-cell,trajectory-inference
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Science/Research
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
|
|
20
|
+
Requires-Python: >=3.9
|
|
21
|
+
Requires-Dist: anndata>=0.9
|
|
22
|
+
Requires-Dist: grassmann-ot>=0.3.1
|
|
23
|
+
Requires-Dist: numpy>=1.24
|
|
24
|
+
Requires-Dist: scanpy>=1.9
|
|
25
|
+
Requires-Dist: scikit-learn>=1.3
|
|
26
|
+
Requires-Dist: scipy>=1.10
|
|
27
|
+
Requires-Dist: torch>=2.0
|
|
28
|
+
Provides-Extra: all
|
|
29
|
+
Requires-Dist: faiss-gpu; extra == 'all'
|
|
30
|
+
Requires-Dist: matplotlib>=3.7; extra == 'all'
|
|
31
|
+
Requires-Dist: plotly>=5.18; extra == 'all'
|
|
32
|
+
Requires-Dist: seaborn>=0.12; extra == 'all'
|
|
33
|
+
Provides-Extra: faiss
|
|
34
|
+
Requires-Dist: faiss-cpu; extra == 'faiss'
|
|
35
|
+
Provides-Extra: gpu
|
|
36
|
+
Requires-Dist: faiss-gpu; extra == 'gpu'
|
|
37
|
+
Provides-Extra: plot
|
|
38
|
+
Requires-Dist: matplotlib>=3.7; extra == 'plot'
|
|
39
|
+
Requires-Dist: seaborn>=0.12; extra == 'plot'
|
|
40
|
+
Description-Content-Type: text/markdown
|
|
41
|
+
|
|
42
|
+
# GOTDiff
|
|
43
|
+
|
|
44
|
+
> **G**rassmann-**O**ptimal-**T**ransport **Diff**erentiation inference
|
|
45
|
+
|
|
46
|
+
Single-cell trajectory inference based on the **geodesic distance accumulated
|
|
47
|
+
along a differentiation path on the Grassmann manifold**.
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## Why?
|
|
52
|
+
|
|
53
|
+
Each cell can be represented by a low-dimensional *subspace* of active
|
|
54
|
+
regulatory programs (NMF components, scVI / Harmony loadings, ...). This
|
|
55
|
+
subspace is a point on a Grassmann manifold. A differentiation trajectory is
|
|
56
|
+
therefore a **curve on that manifold**, and the **geodesic distance
|
|
57
|
+
accumulated along the curve** is the total amount of regulatory re-wiring a
|
|
58
|
+
cell has undergone since the root (most primitive) state.
|
|
59
|
+
|
|
60
|
+
```
|
|
61
|
+
differentiation distance = Σ d_G( Γ(t), Γ(t + Δt) )
|
|
62
|
+
t
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
That scalar — the **total "调控变化量"** along the分化路程 — is the central
|
|
66
|
+
output of GOTDiff.
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## Install
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
pip install GOTDiff
|
|
74
|
+
# with GPU / plotting extras
|
|
75
|
+
pip install "GOTDiff[all]"
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## Quick start
|
|
81
|
+
|
|
82
|
+
### Raw arrays
|
|
83
|
+
|
|
84
|
+
```python
|
|
85
|
+
import numpy as np
|
|
86
|
+
from gotdiff import GOTDiff
|
|
87
|
+
|
|
88
|
+
# H comes from any external tool: NMF, scVI, Harmony, ...
|
|
89
|
+
# shape: (n_gene_programs, n_cells)
|
|
90
|
+
H = np.random.rand(20, 500)
|
|
91
|
+
|
|
92
|
+
gd = GOTDiff(k=30, p=3, metric="geodesic", backend="faiss")
|
|
93
|
+
gd.fit(H)
|
|
94
|
+
|
|
95
|
+
adata.obs["gotdiff_pseudotime"] # 伪时间
|
|
96
|
+
adata.obs["gotdiff_diff_distance"] # 分化路程(核心输出)
|
|
97
|
+
adata.obsm["X_gotdiff_grassmann"] # 每个细胞的 Grassmann 坐标
|
|
98
|
+
adata.uns["gotdiff"] # 参数、分支点等元信息
|
|
99
|
+
|
|
100
|
+
# compare total differentiation "cost" of each lineage
|
|
101
|
+
lineage_costs = gd.branch_path_lengths(adata.obs["cell_type"])
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### AnnData (recommended)
|
|
105
|
+
|
|
106
|
+
```python
|
|
107
|
+
import scanpy as sc
|
|
108
|
+
from gotdiff import GOTDiff
|
|
109
|
+
|
|
110
|
+
adata = sc.read_h5ad("hematopoiesis.h5ad")
|
|
111
|
+
|
|
112
|
+
# If you already have a factor matrix (NMF / scVI / Harmony), point GOTDiff at it:
|
|
113
|
+
gd = GOTDiff(k=30, p=3, backend="faiss")
|
|
114
|
+
gd.fit_anndata(adata, use_rep="X_pca") # or
|
|
115
|
+
|
|
116
|
+
# If you don't, GOTDiff runs NMF for you and stores adata.obsm['X_nmf']:
|
|
117
|
+
gd.fit_anndata(adata, n_programs=25)
|
|
118
|
+
|
|
119
|
+
# Results are written into adata in-place:
|
|
120
|
+
# adata.obs['gotdiff_pseudotime']
|
|
121
|
+
# adata.obs['gotdiff_diff_distance']
|
|
122
|
+
# adata.obsm['X_gotdiff_grassmann']
|
|
123
|
+
# adata.uns['gotdiff']
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Plotting
|
|
127
|
+
|
|
128
|
+
```python
|
|
129
|
+
from gotdiff._plot import scatter, diffusion_landscape
|
|
130
|
+
|
|
131
|
+
scatter(adata, color="gotdiff_diff_distance", basis="X_umap", show_root=True)
|
|
132
|
+
diffusion_landscape(adata, color="cell_type")
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
## Pipeline
|
|
138
|
+
|
|
139
|
+
```
|
|
140
|
+
expression matrix / factor matrix (H)
|
|
141
|
+
│
|
|
142
|
+
▼
|
|
143
|
+
cells_to_grassmann ──────────────── (from grassmann-ot)
|
|
144
|
+
→ U_list : (n_cells, d, p) each cell = a subspace
|
|
145
|
+
│
|
|
146
|
+
▼
|
|
147
|
+
grassmann_pseudotime ─────────────── intrinsic to Grassmann space
|
|
148
|
+
→ pseudotime, root
|
|
149
|
+
│
|
|
150
|
+
▼
|
|
151
|
+
accumulate_geodesic_distance ────── ★ the differentiation path length
|
|
152
|
+
→ diff_distance for every cell
|
|
153
|
+
│
|
|
154
|
+
▼
|
|
155
|
+
detect_branch_points ─────────────── curvature + local anisotropy
|
|
156
|
+
→ branch indices & scores
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
---
|
|
160
|
+
|
|
161
|
+
## API summary
|
|
162
|
+
|
|
163
|
+
| Object | Purpose |
|
|
164
|
+
|--------|---------|
|
|
165
|
+
| `GOTDiff` | Main estimator — `fit(H)` or `fit_anndata(adata)` |
|
|
166
|
+
| `grassmann_geodesic_distance` | Pairwise geodesic distance on Gr(p, d) |
|
|
167
|
+
| `grassmann_chordal_distance` | Cheaper Frobenius projector distance |
|
|
168
|
+
| `accumulate_geodesic_distance` | ★ Differentiation path length |
|
|
169
|
+
| `grassmann_pseudotime` | Intrinsic Grassmann pseudotime |
|
|
170
|
+
| `fit_geodesic_curve` | Smooth curve through Grassmann points |
|
|
171
|
+
| `detect_branch_points` | Branch / lineage divergence points |
|
|
172
|
+
| `extract_H_from_adata` | Read a factor matrix from AnnData |
|
|
173
|
+
| `write_results_to_adata` | Persist every result to AnnData |
|
|
174
|
+
|
|
175
|
+
---
|
|
176
|
+
|
|
177
|
+
## Relation to `grassmann-ot`
|
|
178
|
+
|
|
179
|
+
GOTDiff **builds on** [`grassmann-ot`](https://github.com/ZengFLab/grassmann-ot):
|
|
180
|
+
it reuses `cells_to_grassmann` to map cells to Grassmann points, then adds a
|
|
181
|
+
full **trajectory-inference layer** on top (pseudotime, path-length, branching,
|
|
182
|
+
AnnData I/O, plotting).
|
|
183
|
+
|
|
184
|
+
---
|
|
185
|
+
|
|
186
|
+
## License
|
|
187
|
+
|
|
188
|
+
MIT
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
gotdiff/__init__.py,sha256=afluoNNP9_xOEa8ET27C_oNZdozhIVFmcMvm9-K8UrA,2026
|
|
2
|
+
gotdiff/_adata.py,sha256=6S6vMzLNJAtuQiG7mWns2Kc3R1JaopxKgeoAGMok2n0,6825
|
|
3
|
+
gotdiff/_branching.py,sha256=z3JxvB0vbn7uYNLflF_JUl_vXuOlxXYwrvxz2na0wXE,6519
|
|
4
|
+
gotdiff/_core.py,sha256=GDHSh4E9T2hPsOtgk_o1J1TBsXSr6vEhcCxq5QpAUek,12653
|
|
5
|
+
gotdiff/_grassmann_dist.py,sha256=URAQ0FLqK_y-PG40NoPtwuINjdzcWer_rFsc2hodmIw,10916
|
|
6
|
+
gotdiff/_plot.py,sha256=HFk9gdAYycm02vZDId_aHDuWcEncGgnaoWufqst9a8s,5657
|
|
7
|
+
gotdiff/_pseudotime.py,sha256=m9O8xP2L_D8ukHz0jTOY4QnlOfM_mDOEhtAFuIwZQ0E,6251
|
|
8
|
+
gotdiff/_trajectory.py,sha256=0emr5T1_-OTU36AOm-LLEUvrZf0sKWiC2Qu36VVymi8,10374
|
|
9
|
+
gotdiff-0.1.0.dist-info/METADATA,sha256=Dog9lLRH4xjq5aRmnXy70B_PqB8egIG4YzVO6MRptGQ,5841
|
|
10
|
+
gotdiff-0.1.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
|
|
11
|
+
gotdiff-0.1.0.dist-info/licenses/LICENSE,sha256=a8MfFnv1fCs5FQpcSxLNLf3H9o7zP6Evg5CqUKevUeE,1075
|
|
12
|
+
gotdiff-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 GOTDiff Developers
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|