structboost 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.
@@ -0,0 +1,219 @@
1
+ Metadata-Version: 2.4
2
+ Name: structboost
3
+ Version: 0.1.0
4
+ Summary: Boosting Autoencoders (BAE) and componentwise L2 boosting utilities for scverse-style workflows.
5
+ Project-URL: Homepage, https://github.com/NiklasBrunn/structboost
6
+ Project-URL: Repository, https://github.com/NiklasBrunn/structboost
7
+ Project-URL: Issues, https://github.com/NiklasBrunn/structboost/issues
8
+ Author: Niklas Brunn
9
+ License: MIT License
10
+
11
+ Copyright (c) 2026 niklas-br
12
+
13
+ Permission is hereby granted, free of charge, to any person obtaining a copy
14
+ of this software and associated documentation files (the "Software"), to deal
15
+ in the Software without restriction, including without limitation the rights
16
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17
+ copies of the Software, and to permit persons to whom the Software is
18
+ furnished to do so, subject to the following conditions:
19
+
20
+ The above copyright notice and this permission notice shall be included in all
21
+ copies or substantial portions of the Software.
22
+
23
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29
+ SOFTWARE.
30
+ License-File: LICENSE
31
+ Keywords: autoencoder,boosting,dimensionality-reduction,gene-selection,scverse,single-cell
32
+ Classifier: Development Status :: 3 - Alpha
33
+ Classifier: Intended Audience :: Science/Research
34
+ Classifier: License :: OSI Approved :: MIT License
35
+ Classifier: Programming Language :: Python :: 3
36
+ Classifier: Programming Language :: Python :: 3 :: Only
37
+ Classifier: Programming Language :: Python :: 3.10
38
+ Classifier: Programming Language :: Python :: 3.11
39
+ Classifier: Programming Language :: Python :: 3.12
40
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
41
+ Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
42
+ Requires-Python: >=3.10
43
+ Requires-Dist: numpy>=1.23
44
+ Provides-Extra: bae
45
+ Requires-Dist: anndata>=0.10; extra == 'bae'
46
+ Requires-Dist: pandas>=1.5; extra == 'bae'
47
+ Requires-Dist: scipy>=1.10; extra == 'bae'
48
+ Requires-Dist: torch>=2; extra == 'bae'
49
+ Requires-Dist: tqdm>=4.60; extra == 'bae'
50
+ Provides-Extra: dev
51
+ Requires-Dist: pre-commit>=3.6; extra == 'dev'
52
+ Requires-Dist: ruff<0.17,>=0.16; extra == 'dev'
53
+ Provides-Extra: docs
54
+ Requires-Dist: furo>=2024.1.29; extra == 'docs'
55
+ Requires-Dist: myst-parser>=2.0; extra == 'docs'
56
+ Requires-Dist: sphinx-copybutton>=0.5; extra == 'docs'
57
+ Requires-Dist: sphinx-design>=0.5; extra == 'docs'
58
+ Requires-Dist: sphinx>=7.2; extra == 'docs'
59
+ Provides-Extra: io
60
+ Requires-Dist: pandas>=1.5; extra == 'io'
61
+ Requires-Dist: pyarrow>=12; extra == 'io'
62
+ Provides-Extra: plot
63
+ Requires-Dist: matplotlib>=3.7; extra == 'plot'
64
+ Provides-Extra: test
65
+ Requires-Dist: anndata>=0.10; extra == 'test'
66
+ Requires-Dist: pandas>=1.5; extra == 'test'
67
+ Requires-Dist: pytest>=7.4; extra == 'test'
68
+ Requires-Dist: scipy>=1.10; extra == 'test'
69
+ Requires-Dist: torch>=2; extra == 'test'
70
+ Requires-Dist: tqdm>=4.60; extra == 'test'
71
+ Description-Content-Type: text/markdown
72
+
73
+ # structboost
74
+
75
+ > **Note that this package is under active development.** The API is still
76
+ > moving, and a minor version bump may break it.
77
+
78
+ **Structured representation learning for single-cell data. A latent space you can
79
+ read gene by gene.**
80
+
81
+ The **Boosting Autoencoder (BAE)** pairs a linear encoder fitted by componentwise
82
+ L2 boosting with an MLP decoder trained by gradient descent. Each training
83
+ iteration takes a gradient step on the latent code itself and hands the result to
84
+ the boosting fit as a regression target, so the encoder is fitted against the
85
+ negative gradient of the reconstruction loss rather than by backpropagation.
86
+ Componentwise boosting adds one gene at a time and shrinks each step, which keeps
87
+ the encoder weights sparse by construction rather than by a post-hoc threshold.
88
+
89
+ Each latent dimension is therefore a short, signed gene list, and `X_bae` is
90
+ exactly `X @ varm["BAE_encoder_weights"]`.
91
+
92
+ The package also ships `allboost`, the componentwise boosting routine on its own,
93
+ for sparse supervised problems with no autoencoder involved.
94
+
95
+ ## Relation to the original method
96
+
97
+ This is a scanpy-compatible Python re-implementation of the Boosting Autoencoder
98
+ introduced in [Hackenberg et al. (2025)](https://doi.org/10.1038/s42003-025-07872-9),
99
+ where the method and its componentwise boosting core were developed in Julia.
100
+
101
+ **Some methodological components differ from the original proposal.** Defaults
102
+ and several parts of the training procedure were re-derived here against
103
+ simulated data with known ground truth, and the measurements behind each are
104
+ recorded in the [user guide](https://niklasbrunn.github.io/structboost/guide/index.html)
105
+ next to the setting they justify. Results from this implementation should
106
+ therefore not be assumed identical to the original paper's.
107
+
108
+ 📖 **[Documentation](https://niklasbrunn.github.io/structboost)** ·
109
+ [User guide](https://niklasbrunn.github.io/structboost/guide/index.html) ·
110
+ [API reference](https://niklasbrunn.github.io/structboost/api/index.html) ·
111
+ [Changelog](CHANGELOG.md)
112
+
113
+ ## Installation
114
+
115
+ Requires Python 3.10 or newer. The core depends on NumPy alone, and everything
116
+ heavier is opt-in.
117
+
118
+ ```bash
119
+ pip install "structboost[bae,plot]" # the BAE
120
+ pip install structboost # allboost only, NumPy-only
121
+ ```
122
+
123
+ | Extra | Brings in | Needed for |
124
+ | --- | --- | --- |
125
+ | *(none)* | numpy | `allboost`, `stability_selection` |
126
+ | `bae` | torch, anndata, scipy, pandas, tqdm | `BAE`, the simulator, everything AnnData |
127
+ | `plot` | matplotlib | the `plot_*` functions |
128
+ | `io` | pyarrow | Parquet encoder-weight files |
129
+
130
+ Not on PyPI yet. Until it is, install from source or from TestPyPI. Pin the
131
+ version: TestPyPI also carries older pre-release builds under this name, and an
132
+ unpinned install resolves to one of those rather than to the current code.
133
+
134
+ ```bash
135
+ pip install --index-url https://test.pypi.org/simple/ \
136
+ --extra-index-url https://pypi.org/simple/ "structboost[bae]==0.1.0"
137
+ ```
138
+
139
+ See [Installation](https://niklasbrunn.github.io/structboost/installation.html)
140
+ for the from-source and development setups.
141
+
142
+ ## Quickstart
143
+
144
+ `adata.X` must be z-scored, which `sc.pp.scale` gives you.
145
+
146
+ ```python
147
+ from structboost import BAE, BAEConfig
148
+
149
+ model = BAE(adata.n_vars, BAEConfig(latent_dim=10))
150
+ model.fit(adata)
151
+
152
+ adata.obsm["X_bae"] # (n_cells, 10) latent space
153
+ adata.varm["BAE_encoder_weights"] # (n_genes, 10), sparse
154
+ ```
155
+
156
+ A single fit gives one gene list, and that list is **not reproducible**. In a
157
+ high-dimensional feature space with strongly correlated genes the encoder support
158
+ is not identifiable: many different sparse gene sets reconstruct the data about
159
+ equally well, and a fit returns one of them.
160
+
161
+ ```python
162
+ res = model.stability_selection(adata, mode="iteration")
163
+ genes = [adata.var_names[res.stable_support[:, j]] for j in range(res.frequency.shape[1])]
164
+ ```
165
+
166
+ Componentwise L2 boosting on its own, no autoencoder involved:
167
+
168
+ ```python
169
+ from structboost import allboost
170
+
171
+ betamat = allboost(sourcemat, targetmat_std, stepno=20, nu=0.1)
172
+ # (n_targets, n_features), sparse
173
+ ```
174
+
175
+ ## What else it does
176
+
177
+ Each of these has a guide page.
178
+
179
+ | | |
180
+ | --- | --- |
181
+ | [Batch integration](https://niklasbrunn.github.io/structboost/guide/tasks/batch-integration.html) | `batch_key` names the covariate and `batch_integration_mode` chooses whether it conditions the decoder, protects gene selection, or both. `transform` stays gene-only and needs no batch labels. |
182
+ | [Transfer](https://niklasbrunn.github.io/structboost/guide/tasks/transfer.html) | Carry a trained encoder matrix onto a new dataset with `from_reference`, aligned by gene name, with the prior programs frozen. |
183
+ | [Persistence](https://niklasbrunn.github.io/structboost/guide/tasks/persistence.html) | `save` and `load` a fitted model as one checkpoint, readable with `weights_only=True`. |
184
+ | [Interpretation](https://niklasbrunn.github.io/structboost/guide/tasks/interpreting.html) | Ranked gene lists per dimension, stored functional annotations, and a self-contained interactive HTML explorer. |
185
+ | [Simulation](https://niklasbrunn.github.io/structboost/guide/tasks/simulating.html) | Negative-binomial counts with planted gene programs and a cell-type hierarchy, so marker recovery can be scored against ground truth. |
186
+
187
+ ## Citation
188
+
189
+ If you use the **BAE**:
190
+
191
+ > Hackenberg, M., Brunn, N., Vogel, T. et al. *Infusing structural assumptions
192
+ > into dimensionality reduction for single-cell RNA sequencing data to identify
193
+ > small gene sets.* Commun Biol 8, 414 (2025).
194
+ > <https://doi.org/10.1038/s42003-025-07872-9>
195
+
196
+ If you use **allboost**:
197
+
198
+ > Binder, H., Schumacher, M. *Incorporating pathway information into boosting
199
+ > estimation of high-dimensional risk prediction models.* BMC Bioinformatics 10,
200
+ > 18 (2009). <https://doi.org/10.1186/1471-2105-10-18>
201
+
202
+ ## Development note
203
+
204
+ [Claude Code](https://claude.com/claude-code) (Anthropic) was used in building
205
+ this package, to support implementation, to write tests, and to write the
206
+ documentation. Individual commits record it as a co-author.
207
+
208
+ The methods, the design decisions, and the scientific claims are the authors'.
209
+ Everything committed was reviewed, and the behavioural claims in the docstrings
210
+ and the user guide are backed by the test suite or by the measurements cited
211
+ alongside them.
212
+
213
+ ## Contributing
214
+
215
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for the development setup, the versioning
216
+ policy, and what a pull request needs. Planned work is tracked in the
217
+ [issue tracker](https://github.com/NiklasBrunn/structboost/issues).
218
+
219
+ Licensed under the [MIT License](LICENSE).
@@ -0,0 +1,19 @@
1
+ structboost/__init__.py,sha256=ncxIpTmmanaAY0iYjntj7oQUYIrurIpUcsLgWORcXVk,2697
2
+ structboost/_annotation.py,sha256=cNnI8YXvoN75mklf10lFG5EtrJChXANvJ6wdQZWB71c,7856
3
+ structboost/_boosting.py,sha256=SCMs_J2tO5iFHS3CR2f9wrC298D42cGpUWsjVW4a5to,24713
4
+ structboost/_decoder.py,sha256=Z40q4TxfCJYlUsxHZ1NltRRfGkpSKZIpBnagwtYcDRU,3753
5
+ structboost/_encoder.py,sha256=FOXI4_LFyaUHs2MlGYspAzm8QPWxaCdZS0UBlt7cb6A,2781
6
+ structboost/_explorer.py,sha256=iDUC9_3UApp0RTtraVF6alZ8s9aK0AgS3shfgErrG40,27614
7
+ structboost/_io.py,sha256=c_2DKoujsolRGwKvUlK12N2D14Rx9MAzdergkfJr7mQ,11443
8
+ structboost/_model.py,sha256=_seWBkhfkuVvxUO3R9_CMBbS2ZLmzHjxHQrZpRPOYN4,161703
9
+ structboost/_persistence.py,sha256=GVN8lOfB40yUVoEHnITM-gtnon0cXu8HsgOLT7Y51bg,13929
10
+ structboost/_plotting.py,sha256=AM5rI2o7FFS22l7pWMdfueqsohy1B9RBw_SS6dPBhno,9945
11
+ structboost/_simulation.py,sha256=VsC37HA2B-1kPiVGFQzkV_PzOueguN1c5fiyeKsR5qE,34826
12
+ structboost/_stability.py,sha256=vO21nKAyAlInKcZrJHw3RhHp8SwSMIey5f3-lvuwxA8,19170
13
+ structboost/_types.py,sha256=ZIAFdUPP1te82tD11zluu91zeoCwzok4EyytveTL4QM,19908
14
+ structboost/_utils.py,sha256=OuykUPWpW0T4xX6gGNsrS0v7IHmN1kMswj2dL6u7qGc,17936
15
+ structboost/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
+ structboost-0.1.0.dist-info/METADATA,sha256=IvaliqScaFijXxIWORnleaTjfTgiTcUq0ERth6k0mfs,10029
17
+ structboost-0.1.0.dist-info/WHEEL,sha256=lCkmxWfQsSc9CfIClYeavTdQeEX2toPqufh9gI35EQA,87
18
+ structboost-0.1.0.dist-info/licenses/LICENSE,sha256=P057TCLBWXhAiz9l2IwmOx9PZ7JMcOepMU-G5-0s7PQ,1066
19
+ structboost-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.31.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 niklas-br
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.