spatialfusion 0.1.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 (56) hide show
  1. spatialfusion-0.1.0/.gitignore +209 -0
  2. spatialfusion-0.1.0/LICENSE +21 -0
  3. spatialfusion-0.1.0/PKG-INFO +350 -0
  4. spatialfusion-0.1.0/README.md +297 -0
  5. spatialfusion-0.1.0/docs/api/embed.md +3 -0
  6. spatialfusion-0.1.0/docs/api/finetune.md +3 -0
  7. spatialfusion-0.1.0/docs/api/index.md +3 -0
  8. spatialfusion-0.1.0/docs/api/models_gcn.md +3 -0
  9. spatialfusion-0.1.0/docs/api/models_multi_ae.md +3 -0
  10. spatialfusion-0.1.0/docs/api/utils_ae.md +4 -0
  11. spatialfusion-0.1.0/docs/api/utils_embed_gcn.md +3 -0
  12. spatialfusion-0.1.0/docs/api/utils_gcn.md +3 -0
  13. spatialfusion-0.1.0/docs/concepts.md +8 -0
  14. spatialfusion-0.1.0/docs/data.md +18 -0
  15. spatialfusion-0.1.0/docs/faq.md +9 -0
  16. spatialfusion-0.1.0/docs/images/overview.png +0 -0
  17. spatialfusion-0.1.0/docs/index.md +22 -0
  18. spatialfusion-0.1.0/docs/installation.md +112 -0
  19. spatialfusion-0.1.0/docs/quickstart.md +38 -0
  20. spatialfusion-0.1.0/docs/tutorials.md +19 -0
  21. spatialfusion-0.1.0/mkdocs.yml +36 -0
  22. spatialfusion-0.1.0/pyproject.toml +88 -0
  23. spatialfusion-0.1.0/setup.cfg +4 -0
  24. spatialfusion-0.1.0/src/.DS_Store +0 -0
  25. spatialfusion-0.1.0/src/spatialfusion/.DS_Store +0 -0
  26. spatialfusion-0.1.0/src/spatialfusion/__init__.py +0 -0
  27. spatialfusion-0.1.0/src/spatialfusion/data/checkpoint_dir_ae/spatialfusion-multimodal-ae.pt +0 -0
  28. spatialfusion-0.1.0/src/spatialfusion/data/checkpoint_dir_gcn/spatialfusion-full-gcn.pt +0 -0
  29. spatialfusion-0.1.0/src/spatialfusion/data/checkpoint_dir_gcn/spatialfusion-he-gcn.pt +0 -0
  30. spatialfusion-0.1.0/src/spatialfusion/embed/__init__.py +0 -0
  31. spatialfusion-0.1.0/src/spatialfusion/embed/embed.py +746 -0
  32. spatialfusion-0.1.0/src/spatialfusion/finetune/__init__.py +0 -0
  33. spatialfusion-0.1.0/src/spatialfusion/finetune/finetune.py +823 -0
  34. spatialfusion-0.1.0/src/spatialfusion/models/__init__.py +0 -0
  35. spatialfusion-0.1.0/src/spatialfusion/models/baseline_multi_ae.py +215 -0
  36. spatialfusion-0.1.0/src/spatialfusion/models/gcn.py +152 -0
  37. spatialfusion-0.1.0/src/spatialfusion/models/multi_ae.py +202 -0
  38. spatialfusion-0.1.0/src/spatialfusion/utils/__init__.py +0 -0
  39. spatialfusion-0.1.0/src/spatialfusion/utils/ae_data_loader.py +137 -0
  40. spatialfusion-0.1.0/src/spatialfusion/utils/baseline_ae_data_loader.py +170 -0
  41. spatialfusion-0.1.0/src/spatialfusion/utils/embed_ae_utils.py +338 -0
  42. spatialfusion-0.1.0/src/spatialfusion/utils/embed_gcn_utils.py +298 -0
  43. spatialfusion-0.1.0/src/spatialfusion/utils/gcn_utils.py +126 -0
  44. spatialfusion-0.1.0/src/spatialfusion/utils/pkg_ckpt.py +11 -0
  45. spatialfusion-0.1.0/src/spatialfusion.egg-info/PKG-INFO +350 -0
  46. spatialfusion-0.1.0/src/spatialfusion.egg-info/SOURCES.txt +54 -0
  47. spatialfusion-0.1.0/src/spatialfusion.egg-info/dependency_links.txt +1 -0
  48. spatialfusion-0.1.0/src/spatialfusion.egg-info/requires.txt +35 -0
  49. spatialfusion-0.1.0/src/spatialfusion.egg-info/top_level.txt +1 -0
  50. spatialfusion-0.1.0/tests/__init__.py +0 -0
  51. spatialfusion-0.1.0/tests/test_basic.py +25 -0
  52. spatialfusion-0.1.0/tests/test_finetune.py +88 -0
  53. spatialfusion-0.1.0/tests/test_imports.py +12 -0
  54. spatialfusion-0.1.0/tutorials/.DS_Store +0 -0
  55. spatialfusion-0.1.0/tutorials/data/.DS_Store +0 -0
  56. spatialfusion-0.1.0/tutorials/embed-and-finetune-sample.ipynb +3104 -0
@@ -0,0 +1,209 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[codz]
4
+ *$py.class
5
+
6
+ .DS_Store
7
+
8
+ # C extensions
9
+ *.so
10
+
11
+ # Distribution / packaging
12
+ .Python
13
+ build/
14
+ develop-eggs/
15
+ dist/
16
+ downloads/
17
+ eggs/
18
+ .eggs/
19
+ lib/
20
+ lib64/
21
+ parts/
22
+ sdist/
23
+ var/
24
+ wheels/
25
+ share/python-wheels/
26
+ *.egg-info/
27
+ .installed.cfg
28
+ *.egg
29
+ MANIFEST
30
+
31
+ # PyInstaller
32
+ # Usually these files are written by a python script from a template
33
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
34
+ *.manifest
35
+ *.spec
36
+
37
+ # Installer logs
38
+ pip-log.txt
39
+ pip-delete-this-directory.txt
40
+
41
+ # Unit test / coverage reports
42
+ htmlcov/
43
+ .tox/
44
+ .nox/
45
+ .coverage
46
+ .coverage.*
47
+ .cache
48
+ nosetests.xml
49
+ coverage.xml
50
+ *.cover
51
+ *.py.cover
52
+ .hypothesis/
53
+ .pytest_cache/
54
+ cover/
55
+
56
+ # Translations
57
+ *.mo
58
+ *.pot
59
+
60
+ # Django stuff:
61
+ *.log
62
+ local_settings.py
63
+ db.sqlite3
64
+ db.sqlite3-journal
65
+
66
+ # Flask stuff:
67
+ instance/
68
+ .webassets-cache
69
+
70
+ # Scrapy stuff:
71
+ .scrapy
72
+
73
+ # Sphinx documentation
74
+ docs/_build/
75
+
76
+ # PyBuilder
77
+ .pybuilder/
78
+ target/
79
+
80
+ # Jupyter Notebook
81
+ .ipynb_checkpoints
82
+
83
+ # IPython
84
+ profile_default/
85
+ ipython_config.py
86
+
87
+ # pyenv
88
+ # For a library or package, you might want to ignore these files since the code is
89
+ # intended to run in multiple environments; otherwise, check them in:
90
+ # .python-version
91
+
92
+ # pipenv
93
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
94
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
95
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
96
+ # install all needed dependencies.
97
+ #Pipfile.lock
98
+
99
+ # UV
100
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
101
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
102
+ # commonly ignored for libraries.
103
+ #uv.lock
104
+
105
+ # poetry
106
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
107
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
108
+ # commonly ignored for libraries.
109
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
110
+ #poetry.lock
111
+ #poetry.toml
112
+
113
+ # pdm
114
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
115
+ # pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
116
+ # https://pdm-project.org/en/latest/usage/project/#working-with-version-control
117
+ #pdm.lock
118
+ #pdm.toml
119
+ .pdm-python
120
+ .pdm-build/
121
+
122
+ # pixi
123
+ # Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
124
+ #pixi.lock
125
+ # Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
126
+ # in the .venv directory. It is recommended not to include this directory in version control.
127
+ .pixi
128
+
129
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
130
+ __pypackages__/
131
+
132
+ # Celery stuff
133
+ celerybeat-schedule
134
+ celerybeat.pid
135
+
136
+ # SageMath parsed files
137
+ *.sage.py
138
+
139
+ # Environments
140
+ .env
141
+ .envrc
142
+ .venv
143
+ env/
144
+ venv/
145
+ ENV/
146
+ env.bak/
147
+ venv.bak/
148
+
149
+ # Spyder project settings
150
+ .spyderproject
151
+ .spyproject
152
+
153
+ # Rope project settings
154
+ .ropeproject
155
+
156
+ # mkdocs documentation
157
+ /site
158
+
159
+ # mypy
160
+ .mypy_cache/
161
+ .dmypy.json
162
+ dmypy.json
163
+
164
+ # Pyre type checker
165
+ .pyre/
166
+
167
+ # pytype static type analyzer
168
+ .pytype/
169
+
170
+ # Cython debug symbols
171
+ cython_debug/
172
+
173
+ # PyCharm
174
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
175
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
176
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
177
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
178
+ #.idea/
179
+
180
+ # Abstra
181
+ # Abstra is an AI-powered process automation framework.
182
+ # Ignore directories containing user credentials, local state, and settings.
183
+ # Learn more at https://abstra.io/docs
184
+ .abstra/
185
+
186
+ # Visual Studio Code
187
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
188
+ # that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
189
+ # and can be added to the global gitignore or merged into this file. However, if you prefer,
190
+ # you could uncomment the following to ignore the entire vscode folder
191
+ # .vscode/
192
+
193
+ # Ruff stuff:
194
+ .ruff_cache/
195
+
196
+ # PyPI configuration file
197
+ .pypirc
198
+
199
+ # Cursor
200
+ # Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
201
+ # exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
202
+ # refer to https://docs.cursor.com/context/ignore-files
203
+ .cursorignore
204
+ .cursorindexingignore
205
+
206
+ # Marimo
207
+ marimo/_static/
208
+ marimo/_lsp/
209
+ __marimo__/
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Broad Institute Spatial Foundation
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,350 @@
1
+ Metadata-Version: 2.4
2
+ Name: spatialfusion
3
+ Version: 0.1.0
4
+ Summary: SpatialFusion: Deep learning models for spatial omics data analysis.
5
+ Author-email: "Yates, Josephine" <yatesjos@broadinstitute.org>
6
+ Maintainer-email: "Yates, Josephine" <yatesjos@broadinstitute.org>, "Camp, Sabrina" <scamp@broadinstitute.org>
7
+ License: MIT
8
+ Project-URL: Homepage, https://github.com/your-org/spatialfusion
9
+ Project-URL: Documentation, https://readthedocs.org/projects/your-docs
10
+ Project-URL: Issues, https://github.com/your-org/spatialfusion/issues
11
+ Keywords: spatial omics,deep learning,bioinformatics,multi-omics
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Intended Audience :: Science/Research
16
+ Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
17
+ Requires-Python: >=3.9
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE
20
+ Requires-Dist: numpy<3.0,>=1.24
21
+ Requires-Dist: pandas<3.0,>=2.0
22
+ Requires-Dist: scipy<2.0,>=1.10
23
+ Requires-Dist: pyarrow>=12
24
+ Requires-Dist: tqdm>=4.65
25
+ Requires-Dist: hydra-core>=1.3
26
+ Requires-Dist: omegaconf>=2.3
27
+ Requires-Dist: scanpy<2.0,>=1.9
28
+ Requires-Dist: anndata<0.12,>=0.10
29
+ Requires-Dist: matplotlib>=3.7
30
+ Requires-Dist: Pillow>=9.5
31
+ Requires-Dist: tifffile>=2023.7.10
32
+ Requires-Dist: scikit-learn>=1.2
33
+ Requires-Dist: seaborn>=0.12
34
+ Requires-Dist: shapely>=2.0
35
+ Requires-Dist: tensorboard>=2.12
36
+ Requires-Dist: imagecodecs>=2023.1.23
37
+ Requires-Dist: networkx<3.4,>=3.2
38
+ Requires-Dist: h5py>=3.8
39
+ Provides-Extra: cpu
40
+ Requires-Dist: torch<2.6,>=2.3; extra == "cpu"
41
+ Requires-Dist: torchvision<0.21,>=0.18; extra == "cpu"
42
+ Provides-Extra: docs
43
+ Requires-Dist: sphinx>=7.0; extra == "docs"
44
+ Requires-Dist: myst-parser>=2.0; extra == "docs"
45
+ Requires-Dist: sphinx-rtd-theme>=2.0; extra == "docs"
46
+ Provides-Extra: dev
47
+ Requires-Dist: pytest>=8; extra == "dev"
48
+ Requires-Dist: pytest-cov>=5; extra == "dev"
49
+ Requires-Dist: ruff>=0.5; extra == "dev"
50
+ Requires-Dist: black>=24.0; extra == "dev"
51
+ Requires-Dist: pre-commit>=3.6; extra == "dev"
52
+ Dynamic: license-file
53
+
54
+ # SpatialFusion
55
+
56
+ [![Docs](https://img.shields.io/badge/docs-online-blue.svg)](
57
+ https://uhlerlab.github.io/spatialfusion/
58
+ )
59
+
60
+ **SpatialFusion** is a Python package for deep learning–based analysis of spatial omics data.
61
+ It provides a lightweight framework that integrates **spatial transcriptomics (ST)** with **H&E histopathology** to learn **joint multimodal embeddings** of cellular neighborhoods and group them into **spatial niches**.
62
+
63
+ The method operates at **single-cell resolution**, and can be applied to:
64
+
65
+ * paired ST + H&E datasets
66
+ * H&E whole-slide images alone
67
+
68
+ By combining molecular and morphological features, SpatialFusion captures coordinated patterns of tissue architecture and gene expression. A key design principle is a biologically informed definition of niches: not simply spatial neighborhoods, but **reproducible microenvironments** characterized by pathway-level activation signatures and functional coherence across tissues. To reflect this prior, the latent space of the model is trained to encode biologically meaningful pathway activations, enabling robust discovery of integrated niches.
69
+
70
+ The method is described in the paper: **XXX** (citation forthcoming).
71
+
72
+ You can find detailed documentation at https://uhlerlab.github.io/spatialfusion/
73
+
74
+ ---
75
+
76
+ ## Installation
77
+
78
+ We provide pretrained weights for the **multimodal autoencoder (AE)** and **graph convolutional masked autoencoder (GCN)** under `data/`.
79
+
80
+ SpatialFusion depends on **PyTorch** and **DGL**, which have different builds for CPU and GPU systems. You can install it using **pip** or inside a **conda/mamba** environment.
81
+
82
+ ---
83
+
84
+ ### 1. Create mamba environment
85
+
86
+ ```bash
87
+ mamba create -n spatialfusion python=3.10 -y
88
+ mamba activate spatialfusion
89
+ # Then install GPU or CPU version below
90
+ ```
91
+
92
+ ### 2. Install platform-specific libraries (GPU vs CPU)
93
+
94
+ #### GPU (CUDA 12.4)
95
+
96
+ ```bash
97
+ pip install "torch==2.4.1" "torchvision==0.19.1" \
98
+ --index-url https://download.pytorch.org/whl/cu124
99
+ conda install -c dglteam/label/th24_cu124 dgl
100
+ ```
101
+
102
+ **Note:** TorchText issues exist for this version:
103
+ [https://github.com/pytorch/text/issues/2272](https://github.com/pytorch/text/issues/2272) — this may affect scGPT.
104
+
105
+ ---
106
+
107
+ #### GPU (CUDA 12.1) — *Recommended if using scGPT*
108
+
109
+ ```bash
110
+ pip install torch==2.3.0 torchvision==0.18.0 torchaudio==2.3.0 \
111
+ --index-url https://download.pytorch.org/whl/cu121
112
+ conda install -c dglteam/label/th21_cu121 dgl
113
+
114
+ # Optional: embeddings used by scGPT
115
+ pip install --no-cache-dir torchtext==0.18.0 torchdata==0.9.0
116
+
117
+ # Optional: UNI (H&E embedding model)
118
+ pip install timm
119
+ ```
120
+
121
+ ---
122
+
123
+ #### CPU-only
124
+
125
+ ```bash
126
+ pip install "torch==2.4.1" "torchvision==0.19.1" \
127
+ --index-url https://download.pytorch.org/whl/cpu
128
+ pip install dgl -f https://data.dgl.ai/wheels/torch-2.4/repo.html
129
+
130
+ # Optional, used for scGPT
131
+ pip install --no-cache-dir torchtext==0.18.0 torchdata==0.9.0
132
+
133
+ # Optional, used for UNI
134
+ pip install timm
135
+ ```
136
+
137
+ > 💡 Replace `cu124` with the CUDA version matching your system (e.g., `cu121`).
138
+
139
+ ---
140
+
141
+ ### 3. Install SpatialFusion package
142
+
143
+ #### Basic installation — *Recommended for users*
144
+ ```bash
145
+ cd spatialfusion/
146
+ pip install -e .
147
+ ```
148
+ ---
149
+ #### Developer installation - *Recommended for contributors*
150
+ Includes: `pytest`, `black`, `ruff`, `sphinx`, `matplotlib`, `seaborn`.
151
+
152
+ ```bash
153
+ cd spatialfusion/
154
+ pip install -e ".[dev,docs]"
155
+ ```
156
+
157
+
158
+
159
+ ---
160
+
161
+ ### 4. Verify Installation
162
+
163
+ ```bash
164
+ python - <<'PY'
165
+ import torch, dgl, spatialfusion
166
+ print("Torch:", torch.__version__, "CUDA available:", torch.cuda.is_available())
167
+ print("DGL:", dgl.__version__)
168
+ print("SpatialFusion OK")
169
+ PY
170
+ ```
171
+
172
+ ---
173
+
174
+ ### 5. Notes
175
+
176
+ * Default output directory is:
177
+
178
+ ```
179
+ $HOME/spatialfusion_runs
180
+ ```
181
+
182
+ Override with:
183
+
184
+ ```
185
+ export SPATIALFUSION_ROOT=/your/path
186
+ ```
187
+ * CPU installations work everywhere but are significantly slower.
188
+
189
+ ---
190
+
191
+ ## Usage Example
192
+
193
+ A minimal example showing how to embed a dataset using the pretrained AE and GCN:
194
+
195
+ ```python
196
+ from spatialfusion.embed.embed import AEInputs, run_full_embedding
197
+ import pandas as pd
198
+ import scanpy as sc
199
+
200
+ # Load external embeddings (UNI + scGPT)
201
+ uni_df = pd.read_parquet('UNI.parquet')
202
+ scgpt_df = pd.read_parquet('scGPT.parquet')
203
+
204
+ # Load AnnData object
205
+ adata = sc.read_h5ad("object.h5ad")
206
+
207
+ # Mapping sample_name -> AEInputs
208
+ sample_name = 'sample1'
209
+ ae_inputs_by_sample = {
210
+ sample_name: AEInputs(
211
+ adata=adata,
212
+ z_uni=uni_df,
213
+ z_scgpt=scgpt_df,
214
+ ),
215
+ }
216
+
217
+ # Run the multimodal embedding pipeline
218
+ emb_df = run_full_embedding(
219
+ ae_inputs_by_sample=ae_inputs_by_sample,
220
+ device="cuda:0", # if cpu, "cpu"
221
+ combine_mode="average",
222
+ spatial_key='spatial',
223
+ celltype_key='major_celltype',
224
+ save_ae_dir=None, # optional
225
+ )
226
+ ```
227
+
228
+ This produces a DataFrame containing the final integrated embedding for all cells/nuclei.
229
+
230
+ ---
231
+
232
+ ## Required Inputs
233
+
234
+ SpatialFusion operates on a **single-cell AnnData object** paired with an **H&E whole-slide image**. It also accepts only a WSI with cell coordinates in the H&E only mode.
235
+
236
+ ### **AnnData fields**
237
+
238
+ | Key | Description |
239
+ | ---------------------------------- | ----------------------------------------------------------------- |
240
+ | `adata.obsm['spatial']` | X/Y centroid coordinates of each cell/nucleus in WSI pixel space. |
241
+ | `adata.X` | Raw counts (cell × gene). Must be single-cell resolution. |
242
+ | `adata.obs['celltype']` (optional) | Annotated cell types (`major_celltype` in examples). |
243
+
244
+ ### **Whole-Slide Image (WSI)**
245
+
246
+ A high-resolution H&E image corresponding to the same tissue section used for ST.
247
+ Used to compute morphology embeddings such as **UNI**.
248
+
249
+ ---
250
+
251
+ ## Typical Workflow
252
+
253
+ 1. **Prepare ST AnnData and the matched H&E WSI**
254
+ 2. **Run scGPT** to compute molecular embeddings
255
+ 3. **Run UNI** to compute morphology embeddings
256
+ 4. **Run SpatialFusion** to integrate all modalities into joint embeddings
257
+ 5. **Cluster & visualize**
258
+
259
+ * Leiden clustering
260
+ * UMAP
261
+ * Spatial niche maps
262
+
263
+ ---
264
+
265
+ ## Tutorials
266
+
267
+ A complete tutorial notebook is available at:
268
+
269
+ ```
270
+ tutorials/embed-and-finetune-sample.ipynb
271
+ ```
272
+
273
+ Additional required packages (scGPT, UNI dependencies) must be installed manually.
274
+ Follow the instructions at: [https://github.com/bowang-lab/scGPT](https://github.com/bowang-lab/scGPT)
275
+
276
+ We also provide a ready-to-use environment file:
277
+
278
+ ```
279
+ spatialfusion_env.yml
280
+ ```
281
+
282
+ Tutorial data is available on Zenodo:
283
+ [https://zenodo.org/records/17594071](https://zenodo.org/records/17594071)
284
+
285
+ ---
286
+
287
+ ## Repository Structure
288
+
289
+ ```
290
+ .
291
+ ├── LICENSE
292
+ ├── pyproject.toml
293
+ ├── README.md
294
+ ├── src
295
+ │ └── spatialfusion
296
+ │ ├── data
297
+ │ │ ├── checkpoint_dir_ae
298
+ │ │ │ └── spatialfusion-multimodal-ae.pt
299
+ │ │ └── checkpoint_dir_gcn
300
+ │ │ ├── spatialfusion-full-gcn.pt
301
+ │ │ └── spatialfusion-he-gcn.pt
302
+ │ ├── embed/
303
+ │ ├── finetune/
304
+ │ ├── models/
305
+ │ └── utils/
306
+ ├── tests
307
+ │ ├── test_basic.py
308
+ │ ├── test_finetune.py
309
+ │ └── test_imports.py
310
+ └── tutorials
311
+ ├── data
312
+ └── embed-and-finetune-sample.ipynb
313
+ ```
314
+
315
+ **Highlights:**
316
+
317
+ * **src/spatialfusion/data/** — packaged pretrained AE and GCN checkpoints
318
+ * **src/spatialfusion/** — main library modules
319
+
320
+ * **embed/** — embedding utilities & pipeline
321
+ * **finetune/** — niche-level finetuning
322
+ * **models/** — neural network architectures
323
+ * **utils/** — loaders, graph utilities, checkpoint code
324
+ * **tests/** — basic test suite
325
+ * **tutorials/** — practical examples and sample data
326
+
327
+ ---
328
+
329
+ ## Citing
330
+
331
+ If you use SpatialFusion, please cite:
332
+
333
+ > Broad Institute Spatial Foundation, *SpatialFusion* (2025).
334
+ > [https://github.com/broadinstitute/spatialfusion](https://github.com/broadinstitute/spatialfusion)
335
+
336
+ Full manuscript citation will be added when available.
337
+
338
+ ---
339
+
340
+ ## Version
341
+
342
+ ### Version
343
+
344
+ This is the initial public release (**v0.1.0**).
345
+
346
+ ---
347
+
348
+ ## License
349
+
350
+ MIT License. See `LICENSE` for details.