laior 0.6.0__tar.gz

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.
Files changed (67) hide show
  1. laior-0.6.0/LICENSE +21 -0
  2. laior-0.6.0/MANIFEST.in +8 -0
  3. laior-0.6.0/PKG-INFO +264 -0
  4. laior-0.6.0/README.md +200 -0
  5. laior-0.6.0/laior/__init__.py +7 -0
  6. laior-0.6.0/laior/agent.py +452 -0
  7. laior-0.6.0/laior/benchmarking.py +338 -0
  8. laior-0.6.0/laior/distributions/EuclideanNormal/__init__.py +15 -0
  9. laior-0.6.0/laior/distributions/EuclideanNormal/arguments.py +3 -0
  10. laior-0.6.0/laior/distributions/EuclideanNormal/distribution.py +26 -0
  11. laior-0.6.0/laior/distributions/EuclideanNormal/layers.py +35 -0
  12. laior-0.6.0/laior/distributions/EuclideanNormal/prior.py +18 -0
  13. laior-0.6.0/laior/distributions/HWNormal/__init__.py +15 -0
  14. laior-0.6.0/laior/distributions/HWNormal/arguments.py +3 -0
  15. laior-0.6.0/laior/distributions/HWNormal/distribution.py +56 -0
  16. laior-0.6.0/laior/distributions/HWNormal/layers.py +44 -0
  17. laior-0.6.0/laior/distributions/HWNormal/prior.py +24 -0
  18. laior-0.6.0/laior/distributions/LearnablePGMNormal/__init__.py +24 -0
  19. laior-0.6.0/laior/distributions/LearnablePGMNormal/arguments.py +4 -0
  20. laior-0.6.0/laior/distributions/LearnablePGMNormal/distribution.py +81 -0
  21. laior-0.6.0/laior/distributions/LearnablePGMNormal/layers.py +218 -0
  22. laior-0.6.0/laior/distributions/LearnablePGMNormal/prior.py +18 -0
  23. laior-0.6.0/laior/distributions/PGMNormal/__init__.py +24 -0
  24. laior-0.6.0/laior/distributions/PGMNormal/arguments.py +4 -0
  25. laior-0.6.0/laior/distributions/PGMNormal/distribution.py +71 -0
  26. laior-0.6.0/laior/distributions/PGMNormal/layers.py +82 -0
  27. laior-0.6.0/laior/distributions/PGMNormal/prior.py +18 -0
  28. laior-0.6.0/laior/distributions/PoincareNormal/__init__.py +16 -0
  29. laior-0.6.0/laior/distributions/PoincareNormal/arguments.py +4 -0
  30. laior-0.6.0/laior/distributions/PoincareNormal/ars.py +133 -0
  31. laior-0.6.0/laior/distributions/PoincareNormal/distribution.py +56 -0
  32. laior-0.6.0/laior/distributions/PoincareNormal/hyperbolic_radius.py +360 -0
  33. laior-0.6.0/laior/distributions/PoincareNormal/hyperbolic_uniform.py +43 -0
  34. laior-0.6.0/laior/distributions/PoincareNormal/layers.py +45 -0
  35. laior-0.6.0/laior/distributions/PoincareNormal/prior.py +18 -0
  36. laior-0.6.0/laior/distributions/__init__.py +0 -0
  37. laior-0.6.0/laior/distributions/utils.py +21 -0
  38. laior-0.6.0/laior/environment.py +548 -0
  39. laior-0.6.0/laior/examples/encoder_example.py +58 -0
  40. laior-0.6.0/laior/interpretation.py +1205 -0
  41. laior-0.6.0/laior/mixin.py +829 -0
  42. laior-0.6.0/laior/model.py +412 -0
  43. laior-0.6.0/laior/module.py +463 -0
  44. laior-0.6.0/laior/ode_functions.py +313 -0
  45. laior-0.6.0/laior/unified_models/__init__.py +53 -0
  46. laior-0.6.0/laior/unified_models/base_model.py +361 -0
  47. laior-0.6.0/laior/unified_models/cellblast_model.py +349 -0
  48. laior-0.6.0/laior/unified_models/clear_model.py +258 -0
  49. laior-0.6.0/laior/unified_models/gmvae_model.py +560 -0
  50. laior-0.6.0/laior/unified_models/scalex_model.py +352 -0
  51. laior-0.6.0/laior/unified_models/scdac_model.py +269 -0
  52. laior-0.6.0/laior/unified_models/scdeepcluster_model.py +300 -0
  53. laior-0.6.0/laior/unified_models/scdhmap_model.py +454 -0
  54. laior-0.6.0/laior/unified_models/scdiffusion_model.py +479 -0
  55. laior-0.6.0/laior/unified_models/scgcc_model.py +374 -0
  56. laior-0.6.0/laior/unified_models/scgnn_model.py +210 -0
  57. laior-0.6.0/laior/unified_models/scsmd_model.py +387 -0
  58. laior-0.6.0/laior/unified_models/sivae_model.py +460 -0
  59. laior-0.6.0/laior/utils.py +481 -0
  60. laior-0.6.0/laior.egg-info/PKG-INFO +264 -0
  61. laior-0.6.0/laior.egg-info/SOURCES.txt +65 -0
  62. laior-0.6.0/laior.egg-info/dependency_links.txt +1 -0
  63. laior-0.6.0/laior.egg-info/requires.txt +18 -0
  64. laior-0.6.0/laior.egg-info/top_level.txt +1 -0
  65. laior-0.6.0/pyproject.toml +92 -0
  66. laior-0.6.0/setup.cfg +4 -0
  67. laior-0.6.0/setup.py +11 -0
laior-0.6.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Zeyu Fu
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.
@@ -0,0 +1,8 @@
1
+ include README.md
2
+ include LICENSE
3
+ include pyproject.toml
4
+ recursive-include laior *.py
5
+ prune laior/tests
6
+ prune liora/examples
7
+ global-exclude __pycache__
8
+ global-exclude *.py[co]
laior-0.6.0/PKG-INFO ADDED
@@ -0,0 +1,264 @@
1
+ Metadata-Version: 2.4
2
+ Name: laior
3
+ Version: 0.6.0
4
+ Summary: LAIOR: Lorentz Attentive Interpretable ODE Regularized VAE for single-cell omics analysis
5
+ Author-email: Zeyu Fu <fuzeyu99@126.com>
6
+ Maintainer-email: Zeyu Fu <fuzeyu99@126.com>
7
+ License: MIT License
8
+
9
+ Copyright (c) 2025 Zeyu Fu
10
+
11
+ Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ of this software and associated documentation files (the "Software"), to deal
13
+ in the Software without restriction, including without limitation the rights
14
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ copies of the Software, and to permit persons to whom the Software is
16
+ furnished to do so, subject to the following conditions:
17
+
18
+ The above copyright notice and this permission notice shall be included in all
19
+ copies or substantial portions of the Software.
20
+
21
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27
+ SOFTWARE.
28
+
29
+ Project-URL: Homepage, https://github.com/PeterPonyu/Liora
30
+ Project-URL: Repository, https://github.com/PeterPonyu/Liora
31
+ Project-URL: Issues, https://github.com/PeterPonyu/Liora/issues
32
+ Project-URL: Documentation, https://github.com/PeterPonyu/Liora#readme
33
+ Keywords: single-cell,rna-seq,scRNA-seq,vae,variational-autoencoder,neural-ode,ode,manifold,lorentz,hyperbolic,transformer,trajectory-inference,bioinformatics
34
+ Classifier: Development Status :: 3 - Alpha
35
+ Classifier: Intended Audience :: Science/Research
36
+ Classifier: Programming Language :: Python :: 3
37
+ Classifier: Programming Language :: Python :: 3.9
38
+ Classifier: Programming Language :: Python :: 3.10
39
+ Classifier: Programming Language :: Python :: 3.11
40
+ Classifier: Programming Language :: Python :: 3.12
41
+ Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
42
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
43
+ Classifier: Topic :: Scientific/Engineering :: Medical Science Apps.
44
+ Requires-Python: >=3.9
45
+ Description-Content-Type: text/markdown
46
+ License-File: LICENSE
47
+ Requires-Dist: torch>=2.1
48
+ Requires-Dist: torchdiffeq>=0.2.3
49
+ Requires-Dist: numpy>=1.23
50
+ Requires-Dist: scipy>=1.9
51
+ Requires-Dist: scikit-learn>=1.1
52
+ Requires-Dist: anndata>=0.9
53
+ Requires-Dist: tqdm>=4.65
54
+ Provides-Extra: test
55
+ Requires-Dist: pytest>=7.0; extra == "test"
56
+ Requires-Dist: pytest-cov>=4.0; extra == "test"
57
+ Provides-Extra: dev
58
+ Requires-Dist: pytest>=7.0; extra == "dev"
59
+ Requires-Dist: pytest-cov>=4.0; extra == "dev"
60
+ Requires-Dist: black>=23.0; extra == "dev"
61
+ Requires-Dist: isort>=5.12; extra == "dev"
62
+ Requires-Dist: flake8>=6.0; extra == "dev"
63
+ Dynamic: license-file
64
+
65
+ # LAIOR: Lorentz Attentive Interpretable ODE Regularized VAE
66
+
67
+ **A deep learning framework for single-cell omics analysis combining geometric manifold learning, latent dynamics, and comprehensive interpretability.**
68
+
69
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
70
+ [![Python 3.9+](https://img.shields.io/badge/python-3.9+-blue.svg)](https://www.python.org/downloads/)
71
+ [![PyPI](https://img.shields.io/pypi/v/liora)](https://pypi.org/project/liora/)
72
+
73
+ LAIOR (Lorentz Attentive Interpretable ODE Regularized VAE) is a PyTorch-based unified framework for single-cell RNA-seq and ATAC-seq analysis (AnnData format) that learns low-dimensional embeddings from **raw count matrices** using count-likelihood objectives (NB/ZINB/Poisson/ZIP). It integrates (1) Lorentz geometric regularization for hierarchical structure, (2) dual-path information bottleneck architecture for coordinated biological programs, (3) Neural ODE regularization for temporal trajectory stability, and (4) transformer-based attention mechanisms for capturing long-range dependencies.
74
+
75
+ ## Key Features
76
+
77
+ - **Advanced VAE Architecture**: Dimensionality reduction with count-based likelihoods (NB, ZINB, Poisson, ZIP)
78
+ - **Geometric Manifold Learning**: Lorentz (hyperbolic) or Euclidean regularization for hierarchical structure
79
+ - **Neural ODE Trajectories**: Latent dynamics solved with `torchdiffeq` (CPU by design). Supports ODE function types `legacy`, `time_mlp` (time-conditioned), and `gru`.
80
+ - **Comprehensive Interpretability**: Attribution analysis for Genes → Latents (discriminative) and Latents → Genes (reconstructive) pathways.
81
+ - **Flexible Encoders**: Standard MLP or Transformer-based with self-attention for capturing complex feature dependencies.
82
+ - **Information Bottleneck**: Hierarchical representation with controllable compression via the `i_dim` parameter.
83
+
84
+ ## Data Requirements
85
+
86
+ - `adata.layers[layer]` must contain **raw, non-negative integer-like counts** (UMI counts).
87
+ LAIOR checks this heuristically and raises a `ValueError` if the layer looks normalized/log-transformed.
88
+ - LAIOR applies its own `log1p` + clipping / adaptive normalization internally for training.
89
+
90
+ ## Installation
91
+
92
+ ```bash
93
+ pip install liora
94
+ ```
95
+
96
+ Or install from source:
97
+
98
+ ```bash
99
+ git clone https://github.com/PeterPonyu/Liora.git
100
+ cd Liora
101
+ pip install -e .
102
+ ```
103
+
104
+ ## Quick Start
105
+
106
+ ### Basic Usage
107
+
108
+ ```python
109
+ import scanpy as sc
110
+ from liora import LAIOR
111
+
112
+ # Load your data
113
+ adata = sc.read_h5ad('data.h5ad')
114
+
115
+ # Train with default settings
116
+ model = LAIOR(
117
+ adata,
118
+ layer='counts',
119
+ hidden_dim=128,
120
+ latent_dim=10,
121
+ i_dim=2,
122
+ )
123
+ model.fit(epochs=100)
124
+
125
+ # Extract embeddings
126
+ latent = model.get_latent()
127
+ ```
128
+
129
+ ### Advanced Configuration
130
+
131
+ ```python
132
+ # Transformer encoder + Neural ODE trajectory inference
133
+ model = LAIOR(
134
+ adata,
135
+ layer='counts',
136
+ hidden_dim=128,
137
+ latent_dim=10,
138
+ i_dim=2,
139
+ # Encoder configuration
140
+ encoder_type='transformer',
141
+ attn_embed_dim=64,
142
+ attn_num_heads=4,
143
+ attn_num_layers=2,
144
+ attn_seq_len=32,
145
+ # ODE configuration
146
+ use_ode=True,
147
+ ode_type='time_mlp',
148
+ ode_time_cond='concat',
149
+ ode_hidden_dim=64,
150
+ ode_solver_method='dopri5',
151
+ ode_rtol=1e-5,
152
+ ode_atol=1e-7,
153
+ # Loss weights
154
+ lorentz=5.0,
155
+ beta=1.0,
156
+ )
157
+ model.fit(epochs=200, patience=20)
158
+
159
+ # Extract results
160
+ latent = model.get_latent() # Latent embeddings
161
+ bottleneck = model.get_bottleneck() # Information bottleneck
162
+ pseudotime = model.get_time() # Predicted pseudotime
163
+ transitions = model.get_transition() # Transition matrix
164
+ ```
165
+
166
+ > Note: `get_time()` and `get_transition()` require `use_ode=True`.
167
+
168
+ ## Configuration Guide
169
+
170
+ ### Architecture Parameters
171
+
172
+ | Parameter | Type | Default | Description |
173
+ |-----------|------|---------|-------------|
174
+ | `hidden_dim` | int | 128 | Hidden layer dimension |
175
+ | `latent_dim` | int | 10 | Primary latent space size |
176
+ | `i_dim` | int | 2 | Information bottleneck dimension |
177
+
178
+ ### Encoder Options
179
+
180
+ | Parameter | Type | Default | Description |
181
+ |-----------|------|---------|-------------|
182
+ | `encoder_type` | str | `'mlp'` | `'mlp'` or `'transformer'` |
183
+ | `attn_embed_dim` | int | 64 | Transformer embedding dimension |
184
+ | `attn_num_heads` | int | 4 | Number of attention heads |
185
+ | `attn_num_layers` | int | 2 | Transformer encoder layers |
186
+ | `attn_seq_len` | int | 32 | Token sequence length |
187
+
188
+ ### ODE Configuration
189
+
190
+ | Parameter | Type | Default | Description |
191
+ |-----------|------|---------|-------------|
192
+ | `use_ode` | bool | False | Enable Neural ODE |
193
+ | `ode_type` | str | `'time_mlp'` | `'legacy'`, `'time_mlp'`, or `'gru'` |
194
+ | `ode_time_cond` | str | `'concat'` | `'concat'`, `'film'`, or `'add'` |
195
+ | `ode_hidden_dim` | int | None | ODE network hidden size |
196
+ | `ode_solver_method` | str | `'rk4'` | Solver: `'rk4'`, `'dopri5'`, `'adams'`, etc. |
197
+ | `ode_step_size` | float | None | Fixed-step size or `'auto'` |
198
+ | `ode_rtol` | float | None | Relative tolerance (adaptive solvers) |
199
+ | `ode_atol` | float | None | Absolute tolerance (adaptive solvers) |
200
+
201
+ ### Loss Configuration
202
+
203
+ | Parameter | Type | Default | Description |
204
+ |-----------|------|---------|-------------|
205
+ | `recon` | float | 1.0 | Reconstruction loss weight |
206
+ | `irecon` | float | 0.0 | Bottleneck reconstruction weight |
207
+ | `lorentz` | float | 0.0 | Manifold regularization weight |
208
+ | `beta` | float | 1.0 | KL divergence weight (β-VAE) |
209
+ | `dip` | float | 0.0 | DIP-VAE loss weight |
210
+ | `tc` | float | 0.0 | Total Correlation loss weight |
211
+ | `info` | float | 0.0 | MMD loss weight |
212
+ | `loss_type` | str | `'nb'` | `'nb'`, `'zinb'`, `'poisson'`, or `'zip'` |
213
+
214
+ ### Training Parameters
215
+
216
+ | Parameter | Type | Default | Description |
217
+ |-----------|------|---------|-------------|
218
+ | `lr` | float | 1e-4 | Learning rate |
219
+ | `batch_size` | int | 128 | Mini-batch size |
220
+ | `train_size` | float | 0.7 | Training set proportion |
221
+ | `val_size` | float | 0.15 | Validation set proportion |
222
+ | `test_size` | float | 0.15 | Test set proportion |
223
+
224
+ ## Methods
225
+
226
+ ### Training
227
+ ```python
228
+ model.fit(epochs=400, patience=25, val_every=5, early_stop=True)
229
+ ```
230
+
231
+ ### Extraction
232
+ ```python
233
+ latent = model.get_latent() # Latent representations
234
+ bottleneck = model.get_bottleneck() # Information bottleneck embeddings
235
+ pseudotime = model.get_time() # Pseudotime (ODE mode)
236
+ transitions = model.get_transition() # Transition probabilities (ODE mode)
237
+ ```
238
+
239
+ ## Citation
240
+
241
+ If you use Liora in your research, please cite:
242
+
243
+ ```bibtex
244
+ @software{laior2025,
245
+ title = {LAIOR: Lorentz Attentive Interpretable ODE Regularized VAE},
246
+ author = {Zeyu Fu and Jiawei Fu and Chunlin Chen and Keyang Zhang and Junping Wang and Song Wang},
247
+ year = {2025},
248
+ url = {https://github.com/PeterPonyu/Liora}
249
+ }
250
+ ```
251
+
252
+ ## License
253
+
254
+ MIT License - see [LICENSE](LICENSE) file for details.
255
+
256
+ ## Contributing
257
+
258
+ Contributions are welcome! See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
259
+
260
+ ## Support
261
+
262
+ - **Issues**: [GitHub Issues](https://github.com/PeterPonyu/Liora/issues)
263
+ - **Email**: fuzeyu99@126.com
264
+ - **Documentation**: [GitHub Repository](https://github.com/PeterPonyu/Liora)
laior-0.6.0/README.md ADDED
@@ -0,0 +1,200 @@
1
+ # LAIOR: Lorentz Attentive Interpretable ODE Regularized VAE
2
+
3
+ **A deep learning framework for single-cell omics analysis combining geometric manifold learning, latent dynamics, and comprehensive interpretability.**
4
+
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
+ [![Python 3.9+](https://img.shields.io/badge/python-3.9+-blue.svg)](https://www.python.org/downloads/)
7
+ [![PyPI](https://img.shields.io/pypi/v/liora)](https://pypi.org/project/liora/)
8
+
9
+ LAIOR (Lorentz Attentive Interpretable ODE Regularized VAE) is a PyTorch-based unified framework for single-cell RNA-seq and ATAC-seq analysis (AnnData format) that learns low-dimensional embeddings from **raw count matrices** using count-likelihood objectives (NB/ZINB/Poisson/ZIP). It integrates (1) Lorentz geometric regularization for hierarchical structure, (2) dual-path information bottleneck architecture for coordinated biological programs, (3) Neural ODE regularization for temporal trajectory stability, and (4) transformer-based attention mechanisms for capturing long-range dependencies.
10
+
11
+ ## Key Features
12
+
13
+ - **Advanced VAE Architecture**: Dimensionality reduction with count-based likelihoods (NB, ZINB, Poisson, ZIP)
14
+ - **Geometric Manifold Learning**: Lorentz (hyperbolic) or Euclidean regularization for hierarchical structure
15
+ - **Neural ODE Trajectories**: Latent dynamics solved with `torchdiffeq` (CPU by design). Supports ODE function types `legacy`, `time_mlp` (time-conditioned), and `gru`.
16
+ - **Comprehensive Interpretability**: Attribution analysis for Genes → Latents (discriminative) and Latents → Genes (reconstructive) pathways.
17
+ - **Flexible Encoders**: Standard MLP or Transformer-based with self-attention for capturing complex feature dependencies.
18
+ - **Information Bottleneck**: Hierarchical representation with controllable compression via the `i_dim` parameter.
19
+
20
+ ## Data Requirements
21
+
22
+ - `adata.layers[layer]` must contain **raw, non-negative integer-like counts** (UMI counts).
23
+ LAIOR checks this heuristically and raises a `ValueError` if the layer looks normalized/log-transformed.
24
+ - LAIOR applies its own `log1p` + clipping / adaptive normalization internally for training.
25
+
26
+ ## Installation
27
+
28
+ ```bash
29
+ pip install liora
30
+ ```
31
+
32
+ Or install from source:
33
+
34
+ ```bash
35
+ git clone https://github.com/PeterPonyu/Liora.git
36
+ cd Liora
37
+ pip install -e .
38
+ ```
39
+
40
+ ## Quick Start
41
+
42
+ ### Basic Usage
43
+
44
+ ```python
45
+ import scanpy as sc
46
+ from liora import LAIOR
47
+
48
+ # Load your data
49
+ adata = sc.read_h5ad('data.h5ad')
50
+
51
+ # Train with default settings
52
+ model = LAIOR(
53
+ adata,
54
+ layer='counts',
55
+ hidden_dim=128,
56
+ latent_dim=10,
57
+ i_dim=2,
58
+ )
59
+ model.fit(epochs=100)
60
+
61
+ # Extract embeddings
62
+ latent = model.get_latent()
63
+ ```
64
+
65
+ ### Advanced Configuration
66
+
67
+ ```python
68
+ # Transformer encoder + Neural ODE trajectory inference
69
+ model = LAIOR(
70
+ adata,
71
+ layer='counts',
72
+ hidden_dim=128,
73
+ latent_dim=10,
74
+ i_dim=2,
75
+ # Encoder configuration
76
+ encoder_type='transformer',
77
+ attn_embed_dim=64,
78
+ attn_num_heads=4,
79
+ attn_num_layers=2,
80
+ attn_seq_len=32,
81
+ # ODE configuration
82
+ use_ode=True,
83
+ ode_type='time_mlp',
84
+ ode_time_cond='concat',
85
+ ode_hidden_dim=64,
86
+ ode_solver_method='dopri5',
87
+ ode_rtol=1e-5,
88
+ ode_atol=1e-7,
89
+ # Loss weights
90
+ lorentz=5.0,
91
+ beta=1.0,
92
+ )
93
+ model.fit(epochs=200, patience=20)
94
+
95
+ # Extract results
96
+ latent = model.get_latent() # Latent embeddings
97
+ bottleneck = model.get_bottleneck() # Information bottleneck
98
+ pseudotime = model.get_time() # Predicted pseudotime
99
+ transitions = model.get_transition() # Transition matrix
100
+ ```
101
+
102
+ > Note: `get_time()` and `get_transition()` require `use_ode=True`.
103
+
104
+ ## Configuration Guide
105
+
106
+ ### Architecture Parameters
107
+
108
+ | Parameter | Type | Default | Description |
109
+ |-----------|------|---------|-------------|
110
+ | `hidden_dim` | int | 128 | Hidden layer dimension |
111
+ | `latent_dim` | int | 10 | Primary latent space size |
112
+ | `i_dim` | int | 2 | Information bottleneck dimension |
113
+
114
+ ### Encoder Options
115
+
116
+ | Parameter | Type | Default | Description |
117
+ |-----------|------|---------|-------------|
118
+ | `encoder_type` | str | `'mlp'` | `'mlp'` or `'transformer'` |
119
+ | `attn_embed_dim` | int | 64 | Transformer embedding dimension |
120
+ | `attn_num_heads` | int | 4 | Number of attention heads |
121
+ | `attn_num_layers` | int | 2 | Transformer encoder layers |
122
+ | `attn_seq_len` | int | 32 | Token sequence length |
123
+
124
+ ### ODE Configuration
125
+
126
+ | Parameter | Type | Default | Description |
127
+ |-----------|------|---------|-------------|
128
+ | `use_ode` | bool | False | Enable Neural ODE |
129
+ | `ode_type` | str | `'time_mlp'` | `'legacy'`, `'time_mlp'`, or `'gru'` |
130
+ | `ode_time_cond` | str | `'concat'` | `'concat'`, `'film'`, or `'add'` |
131
+ | `ode_hidden_dim` | int | None | ODE network hidden size |
132
+ | `ode_solver_method` | str | `'rk4'` | Solver: `'rk4'`, `'dopri5'`, `'adams'`, etc. |
133
+ | `ode_step_size` | float | None | Fixed-step size or `'auto'` |
134
+ | `ode_rtol` | float | None | Relative tolerance (adaptive solvers) |
135
+ | `ode_atol` | float | None | Absolute tolerance (adaptive solvers) |
136
+
137
+ ### Loss Configuration
138
+
139
+ | Parameter | Type | Default | Description |
140
+ |-----------|------|---------|-------------|
141
+ | `recon` | float | 1.0 | Reconstruction loss weight |
142
+ | `irecon` | float | 0.0 | Bottleneck reconstruction weight |
143
+ | `lorentz` | float | 0.0 | Manifold regularization weight |
144
+ | `beta` | float | 1.0 | KL divergence weight (β-VAE) |
145
+ | `dip` | float | 0.0 | DIP-VAE loss weight |
146
+ | `tc` | float | 0.0 | Total Correlation loss weight |
147
+ | `info` | float | 0.0 | MMD loss weight |
148
+ | `loss_type` | str | `'nb'` | `'nb'`, `'zinb'`, `'poisson'`, or `'zip'` |
149
+
150
+ ### Training Parameters
151
+
152
+ | Parameter | Type | Default | Description |
153
+ |-----------|------|---------|-------------|
154
+ | `lr` | float | 1e-4 | Learning rate |
155
+ | `batch_size` | int | 128 | Mini-batch size |
156
+ | `train_size` | float | 0.7 | Training set proportion |
157
+ | `val_size` | float | 0.15 | Validation set proportion |
158
+ | `test_size` | float | 0.15 | Test set proportion |
159
+
160
+ ## Methods
161
+
162
+ ### Training
163
+ ```python
164
+ model.fit(epochs=400, patience=25, val_every=5, early_stop=True)
165
+ ```
166
+
167
+ ### Extraction
168
+ ```python
169
+ latent = model.get_latent() # Latent representations
170
+ bottleneck = model.get_bottleneck() # Information bottleneck embeddings
171
+ pseudotime = model.get_time() # Pseudotime (ODE mode)
172
+ transitions = model.get_transition() # Transition probabilities (ODE mode)
173
+ ```
174
+
175
+ ## Citation
176
+
177
+ If you use Liora in your research, please cite:
178
+
179
+ ```bibtex
180
+ @software{laior2025,
181
+ title = {LAIOR: Lorentz Attentive Interpretable ODE Regularized VAE},
182
+ author = {Zeyu Fu and Jiawei Fu and Chunlin Chen and Keyang Zhang and Junping Wang and Song Wang},
183
+ year = {2025},
184
+ url = {https://github.com/PeterPonyu/Liora}
185
+ }
186
+ ```
187
+
188
+ ## License
189
+
190
+ MIT License - see [LICENSE](LICENSE) file for details.
191
+
192
+ ## Contributing
193
+
194
+ Contributions are welcome! See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
195
+
196
+ ## Support
197
+
198
+ - **Issues**: [GitHub Issues](https://github.com/PeterPonyu/Liora/issues)
199
+ - **Email**: fuzeyu99@126.com
200
+ - **Documentation**: [GitHub Repository](https://github.com/PeterPonyu/Liora)
@@ -0,0 +1,7 @@
1
+ from .agent import LAIOR
2
+
3
+ # Backward compatibility alias
4
+ Liora = LAIOR
5
+
6
+ __all__ = ['LAIOR', 'Liora']
7
+ __version__ = '0.6.0'