Commit da5fe57
authored
Feat/primary pathway loss (#9)
* README.md:
- Remove duplicate [Research & Improvement Roadmap] link from the
Theory & Interpretability section; the single canonical reference
is in the Development Roadmap section.
- Fold the standalone "Future Directions & Clinical Collaborations"
section into the Development Roadmap's Longer-term bullet list and
attach the collaborator callout there, eliminating the separate
section and the content overlap.
docs/SC_BEST_PRACTICES.md:
- Simplify the two-point numbered intro to a single sentence.
- Collapse six functional ### category headers into three groups
(Vocabulary & Preprocessing / Training & Supervision /
Evaluation, Scale & Tooling) so items of related priority sit
together instead of being scattered across thin categories.
- Remove the #### "Architectural direction" sub-sub-header; promote
it to a bold inline lead paragraph so it reads as context rather
than a nested section.
- Remove the #### "Coverage trade-offs" sub-sub-header; replace it with
a plain lead sentence before the table.
- Update items 7–14 and the quick-reference table to reflect the
decoupleR + PROGENy reframing agreed in the March 2026 research
session (pathway activity as primary task, gene expression as
secondary head).
Signed-off-by: BenjaminIsaac0111 <12176376+BenjaminIsaac0111@users.noreply.github.com>
* feat(model): transition to pathway-exclusive architecture
Redesign the SpatialTranscriptFormer to directly learn from and predict biological pathway
activity scores from histology, completely removing gene-level reconstruction
and auxiliary loss components.
- Architectural Shift: The model now operates exclusively in pathway space,
utilizing learnable pathway tokens as bottleneck predictors via cosine
similarity with patch features.
- Simplified Objective: Dropped the auxiliary gene reconstruction task and
associated losses (ZINB, etc.) in favor of a direct pathway-level objective.
- Refactored Loss System: Introduced a clean `CompositeLoss` (MSE + PCC) for
direct pathway supervision, optimized for whole-slide spatial data.
- Cleanup: Removed legacy PrimaryPathwayLoss and unused MaskedHuberLoss
to streamline the training pipeline.
* - Cleaned up and adapted tests to new model pipeline. God this took a long time...
* chore: update .gitattributes for artefact data handling
- Applying black formatting.
* - Skipping the pathway data intergrety tests. Just skipping as this is typically used for local testing.
* refactor: remove redundant gene vocabulary loading and alignment
Transitioned the SpatialTranscriptFormer pipeline to a strictly
pathway-exclusive architecture. This change eliminates the memory
and I/O overhead associated with loading and aligning high-dimensional
gene expression matrices during training.
Key Changes:
- Dataset: Removed all gene-level loading logic and `num_genes`
parameters from HEST_Dataset and HEST_FeatureDataset.
- Alignment: Replaced gene matrix decoding with get_h5ad_valid_mask
for high-performance barcode-based patch filtering.
- Engine: Updated batch unpacking to treat genes as None, focusing
model training entirely on pre-computed pathway activity.
- CLI: Removed the --num-genes argument from arguments.py and
cleaned up the train.py entry point.
- Cleanup: Deleted redundant gene_vocab.py, build_vocab.py, and
associated CLI entry points in pyproject.toml.
Results:
- Reduced RAM usage and initialization time.
- Standardized dataloading across all HEST recipes.
- Verified stability with updated dataset test suite.
* - fixed the CI collection errors and implemented a local pre-commit hook to automate testing.
scripts/diagnose_collapse.py was still attempting to import the missing function, causing a collection error during the pytest run.
src/spatial_transcript_former/recipes/hest/dataset.py contained a docstring reference that was confusing the documentation/test collection.
---------
Signed-off-by: BenjaminIsaac0111 <12176376+BenjaminIsaac0111@users.noreply.github.com>1 parent 5581172 commit da5fe57
48 files changed
Lines changed: 2177 additions & 4192 deletions
File tree
- docs
- scripts
- src/spatial_transcript_former
- data
- models
- recipes/hest
- training
- tests
- data
- models
- recipes/hest
- training
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
1 | 2 | | |
2 | 3 | | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
182 | 182 | | |
183 | 183 | | |
184 | 184 | | |
185 | | - | |
| 185 | + | |
186 | 186 | | |
187 | | - | |
| 187 | + | |
188 | 188 | | |
189 | 189 | | |
190 | 190 | | |
| |||
213 | 213 | | |
214 | 214 | | |
215 | 215 | | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
216 | 219 | | |
217 | 220 | | |
218 | 221 | | |
219 | 222 | | |
220 | 223 | | |
221 | 224 | | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
32 | | - | |
| 31 | + | |
| 32 | + | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
| 35 | + | |
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
42 | | - | |
| 42 | + | |
43 | 43 | | |
44 | | - | |
45 | | - | |
46 | | - | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
47 | 48 | | |
48 | 49 | | |
49 | 50 | | |
| |||
61 | 62 | | |
62 | 63 | | |
63 | 64 | | |
| 65 | + | |
64 | 66 | | |
65 | 67 | | |
66 | 68 | | |
| |||
83 | 85 | | |
84 | 86 | | |
85 | 87 | | |
86 | | - | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
87 | 99 | | |
88 | 100 | | |
89 | 101 | | |
90 | 102 | | |
91 | 103 | | |
92 | 104 | | |
93 | | - | |
| 105 | + | |
94 | 106 | | |
95 | 107 | | |
96 | 108 | | |
97 | 109 | | |
98 | 110 | | |
99 | | - | |
| 111 | + | |
100 | 112 | | |
101 | 113 | | |
102 | 114 | | |
| |||
109 | 121 | | |
110 | 122 | | |
111 | 123 | | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
116 | 127 | | |
117 | 128 | | |
118 | 129 | | |
| |||
123 | 134 | | |
124 | 135 | | |
125 | 136 | | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
126 | 147 | | |
127 | 148 | | |
128 | 149 | | |
129 | 150 | | |
130 | 151 | | |
131 | 152 | | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
| 153 | + | |
| 154 | + | |
136 | 155 | | |
137 | | - | |
| 156 | + | |
138 | 157 | | |
139 | | - | |
140 | | - | |
141 | | - | |
| 158 | + | |
| 159 | + | |
142 | 160 | | |
143 | 161 | | |
144 | 162 | | |
145 | | - | |
146 | | - | |
147 | | - | |
| 163 | + | |
148 | 164 | | |
149 | 165 | | |
150 | 166 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
15 | | - | |
| 14 | + | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
0 commit comments