fusemap 1.1.2__tar.gz → 1.1.3__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 (42) hide show
  1. fusemap-1.1.3/CHANGELOG.md +46 -0
  2. fusemap-1.1.3/MANIFEST.in +3 -0
  3. {fusemap-1.1.2 → fusemap-1.1.3}/PKG-INFO +39 -6
  4. fusemap-1.1.3/README.md +76 -0
  5. fusemap-1.1.3/RELEASE_VALIDATION.md +58 -0
  6. {fusemap-1.1.2 → fusemap-1.1.3}/fusemap/__init__.py +2 -0
  7. {fusemap-1.1.2 → fusemap-1.1.3}/fusemap/training/train_model.py +1 -0
  8. {fusemap-1.1.2 → fusemap-1.1.3}/fusemap.egg-info/PKG-INFO +39 -6
  9. {fusemap-1.1.2 → fusemap-1.1.3}/fusemap.egg-info/SOURCES.txt +8 -1
  10. {fusemap-1.1.2 → fusemap-1.1.3}/fusemap.egg-info/requires.txt +9 -0
  11. fusemap-1.1.3/pyproject.toml +3 -0
  12. fusemap-1.1.3/requirements-agent-v2.txt +11 -0
  13. fusemap-1.1.3/requirements.txt +3 -0
  14. {fusemap-1.1.2 → fusemap-1.1.3}/setup.py +7 -2
  15. fusemap-1.1.3/tests/test_map_validation.py +59 -0
  16. fusemap-1.1.2/README.md +0 -51
  17. {fusemap-1.1.2 → fusemap-1.1.3}/LICENSE +0 -0
  18. {fusemap-1.1.2 → fusemap-1.1.3}/fusemap/api.py +0 -0
  19. {fusemap-1.1.2 → fusemap-1.1.3}/fusemap/config.py +0 -0
  20. {fusemap-1.1.2 → fusemap-1.1.3}/fusemap/data/__init__.py +0 -0
  21. {fusemap-1.1.2 → fusemap-1.1.3}/fusemap/data/graph.py +0 -0
  22. {fusemap-1.1.2 → fusemap-1.1.3}/fusemap/data/loaders.py +0 -0
  23. {fusemap-1.1.2 → fusemap-1.1.3}/fusemap/logger.py +0 -0
  24. {fusemap-1.1.2 → fusemap-1.1.3}/fusemap/metrics.py +0 -0
  25. {fusemap-1.1.2 → fusemap-1.1.3}/fusemap/models/__init__.py +0 -0
  26. {fusemap-1.1.2 → fusemap-1.1.3}/fusemap/models/losses.py +0 -0
  27. {fusemap-1.1.2 → fusemap-1.1.3}/fusemap/models/network.py +0 -0
  28. {fusemap-1.1.2 → fusemap-1.1.3}/fusemap/permutation.py +0 -0
  29. {fusemap-1.1.2 → fusemap-1.1.3}/fusemap/pl.py +0 -0
  30. {fusemap-1.1.2 → fusemap-1.1.3}/fusemap/postprocess/__init__.py +0 -0
  31. {fusemap-1.1.2 → fusemap-1.1.3}/fusemap/postprocess/imputation.py +0 -0
  32. {fusemap-1.1.2 → fusemap-1.1.3}/fusemap/postprocess/niche_align.py +0 -0
  33. {fusemap-1.1.2 → fusemap-1.1.3}/fusemap/postprocess/stage_b_script.py +0 -0
  34. {fusemap-1.1.2 → fusemap-1.1.3}/fusemap/training/__init__.py +0 -0
  35. {fusemap-1.1.2 → fusemap-1.1.3}/fusemap/training/ddp.py +0 -0
  36. {fusemap-1.1.2 → fusemap-1.1.3}/fusemap/training/integrate.py +0 -0
  37. {fusemap-1.1.2 → fusemap-1.1.3}/fusemap/training/map.py +0 -0
  38. {fusemap-1.1.2 → fusemap-1.1.3}/fusemap/training/sharded.py +0 -0
  39. {fusemap-1.1.2 → fusemap-1.1.3}/fusemap/utils.py +0 -0
  40. {fusemap-1.1.2 → fusemap-1.1.3}/fusemap.egg-info/dependency_links.txt +0 -0
  41. {fusemap-1.1.2 → fusemap-1.1.3}/fusemap.egg-info/top_level.txt +0 -0
  42. {fusemap-1.1.2 → fusemap-1.1.3}/setup.cfg +0 -0
@@ -0,0 +1,46 @@
1
+ # Changelog
2
+
3
+ ## 1.1.3 — local release preparation, 2026-09-11
4
+
5
+ Reference mapping could raise `NameError: dist_hooks is not defined` during
6
+ validation following the DDP refactor. `map_model` now defaults `dist_hooks` to
7
+ `None`, so ordinary mapping reaches scheduling and checkpoint selection.
8
+ The regression test executes that path with CPU optimizers and a small model,
9
+ including optional synchronization hooks.
10
+
11
+ - Complete Tutorials 10–12 and their navigation/data entries. Tutorial 10
12
+ explicitly uses Leiden as a teaching adaptation of the paper's WGCNA panel
13
+ workflow. Tutorial 11 distinguishes model-derived marker evidence from
14
+ independent anatomical validation. Tutorial 12 documents data available upon
15
+ request, replaces its placeholder download, and interprets the saved mixed
16
+ domains and anatomically unexpected predictions.
17
+ - Keep classic LangChain 0.3 dependencies in the scientific environment. Agent
18
+ v2 has a separate requirements file and setup instructions for its LangChain
19
+ 1.x controller and registered scientific kernel. Kernel startup now reports
20
+ bootstrap errors; SQLite checkpoint directories are created on first use.
21
+ - Replace the obsolete requirements freeze (including a self-pin to FuseMap
22
+ 0.0.1) with installation of the checkout. Bound AnnData below 0.12 for Scanpy
23
+ 1.9.3 compatibility; provide `tutorials` and `agent` extras. Mark the Python 3.7
24
+ environment YAML as historical.
25
+ - Update the manuscript title, retain the earlier preprint citation as such,
26
+ document method/version differences, and use the installed Python API in
27
+ quick starts. Add public API documentation and modern build metadata.
28
+ - Version the corrected artifacts as 1.1.3; keep 1.1.2 artifacts for comparison.
29
+ Build products and Agent runtime state are excluded from version control.
30
+
31
+ ### Scope
32
+
33
+ The current manuscript is *An agentic AI spatial molecular foundation model of
34
+ the brain*. Its frozen code and analysis archive is identified at
35
+ https://doi.org/10.5281/zenodo.22103552. Current software enhancements and teaching
36
+ adaptations are described in `docs/release_notes.rst`; they do not replace the
37
+ paper's analysis-specific configurations.
38
+
39
+ Notebook analysis outputs are retained from earlier runs. Modified setup cells
40
+ are cleared; release preparation does not claim fresh execution of all tutorials,
41
+ full-atlas retraining, live LLM-provider validation, or verification of remote
42
+ data downloads. This checkout and its local build are not a PyPI upload.
43
+
44
+ ### Validation
45
+
46
+ Validation results are recorded in `RELEASE_VALIDATION.md` after the checks run.
@@ -0,0 +1,3 @@
1
+ include README.md LICENSE CHANGELOG.md RELEASE_VALIDATION.md pyproject.toml
2
+ include requirements.txt requirements-agent-v2.txt
3
+ recursive-include tests *.py
@@ -1,10 +1,11 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fusemap
3
- Version: 1.1.2
3
+ Version: 1.1.3
4
4
  Requires-Python: >=3.9,<3.12
5
5
  Description-Content-Type: text/markdown
6
6
  License-File: LICENSE
7
7
  Requires-Dist: scanpy==1.9.3
8
+ Requires-Dist: anndata<0.12,>=0.9
8
9
  Requires-Dist: torch==2.0.1
9
10
  Requires-Dist: dgl==1.1.1
10
11
  Requires-Dist: sparse==0.14.0
@@ -26,25 +27,36 @@ Requires-Dist: langsmith==0.3.43
26
27
  Requires-Dist: easydict==1.13
27
28
  Requires-Dist: numpy<2,>=1.26
28
29
  Requires-Dist: gdown
30
+ Provides-Extra: tutorials
31
+ Requires-Dist: ipykernel; extra == "tutorials"
32
+ Requires-Dist: scikit-misc<0.6,>=0.3; extra == "tutorials"
33
+ Provides-Extra: agent
34
+ Requires-Dist: tavily-python<1,>=0.7; extra == "agent"
35
+ Requires-Dist: duckduckgo-search<9,>=6; extra == "agent"
29
36
  Dynamic: description
30
37
  Dynamic: description-content-type
31
38
  Dynamic: license-file
39
+ Dynamic: provides-extra
32
40
  Dynamic: requires-dist
33
41
  Dynamic: requires-python
34
42
 
35
43
  # FuseMap
36
- Integrate spatial transcripomics with universal gene, cell, and tissue embeddings.
44
+ Integrate spatial transcriptomics with universal gene, cell, and tissue embeddings.
37
45
 
38
46
  <p align="center">
39
- <img src="/img/framework.png" width="600" >
47
+ <img src="https://raw.githubusercontent.com/wanglab-broad/FuseMap/main/docs/_static/framework.png" width="600" >
40
48
  </p>
41
49
 
42
- For more details, please check out our publication.
50
+ Current manuscript: **An agentic AI spatial molecular foundation model of the brain**.
51
+ See [release notes](CHANGELOG.md) for the distinction between the manuscript workflows
52
+ and the current software, including anchor alignment and Agent v2.
43
53
 
44
54
 
45
55
  ## Manuscript code and data
46
56
  ### Reproducibity
47
- For code and data in the manuscript 'Towards a universal spatial molecular atlas of the mouse brain', please go to [paper_code](paper_code/).
57
+ For manuscript analysis code, see [paper_code](paper_code/). The current manuscript
58
+ describes a frozen code and analysis archive at [Zenodo](https://doi.org/10.5281/zenodo.22103552).
59
+ Use that archive and its run configurations for paper reproduction.
48
60
 
49
61
  ### Exploratory analysis
50
62
  We provide an interactive online database of the [molCCF](http://fusemap.spatial-atlas.net/).
@@ -74,12 +86,33 @@ seaborn
74
86
 
75
87
 
76
88
  ## Installation and Tutorial
89
+
90
+ Use Python 3.9–3.11 (3.10 recommended). Install this checkout with:
91
+
92
+ ```bash
93
+ python -m pip install .
94
+ ```
95
+
96
+ For notebook dependencies, use `python -m pip install ".[tutorials]"`.
97
+ The PyPI package is installed with `python -m pip install fusemap`; see the
98
+ [release notes](CHANGELOG.md) for this checkout's version.
99
+
100
+ ```python
101
+ import fusemap
102
+ fusemap.integrate("./data", "./output")
103
+ ```
104
+
105
+ The classic Agent uses `python -m pip install ".[agent]"` from this repository.
106
+ Agent v2 uses a separate environment and a registered scientific kernel; follow
107
+ [the Agent setup instructions](agent_setup/README.md#agent-v2).
108
+
77
109
  - Read the FuseMap tutorial [here](https://fusemap.readthedocs.io/en/latest/).
78
110
  - FuseMap-Agent set up tutorial [here](https://github.com/wanglab-broad/FuseMap/tree/main/agent_setup).
79
111
 
80
112
 
81
113
  ## Citation
82
114
 
83
- If you find FuseMap useful for your work, please cite our paper:
115
+ The current manuscript is titled **An agentic AI spatial molecular foundation model of the brain**.
116
+ The earlier public preprint can be cited as:
84
117
 
85
118
  > Yichun He, Hao Sheng, Hailing Shi, Wendy Xueyi Wang, Zefang Tang, Jia Liu, Xiao Wang. Towards a universal spatial molecular atlas of the mouse brain. Preprint at bioRxiv https://www.biorxiv.org/content/10.1101/2024.05.27.594872v1 (2024).
@@ -0,0 +1,76 @@
1
+ # FuseMap
2
+ Integrate spatial transcriptomics with universal gene, cell, and tissue embeddings.
3
+
4
+ <p align="center">
5
+ <img src="https://raw.githubusercontent.com/wanglab-broad/FuseMap/main/docs/_static/framework.png" width="600" >
6
+ </p>
7
+
8
+ Current manuscript: **An agentic AI spatial molecular foundation model of the brain**.
9
+ See [release notes](CHANGELOG.md) for the distinction between the manuscript workflows
10
+ and the current software, including anchor alignment and Agent v2.
11
+
12
+
13
+ ## Manuscript code and data
14
+ ### Reproducibity
15
+ For manuscript analysis code, see [paper_code](paper_code/). The current manuscript
16
+ describes a frozen code and analysis archive at [Zenodo](https://doi.org/10.5281/zenodo.22103552).
17
+ Use that archive and its run configurations for paper reproduction.
18
+
19
+ ### Exploratory analysis
20
+ We provide an interactive online database of the [molCCF](http://fusemap.spatial-atlas.net/).
21
+
22
+ ## System Requirements
23
+ ### Hardware requirements
24
+ `FuseMap` package requires a standard computer with optional GPU to support the in-memory operations.
25
+
26
+ ### Software requirements
27
+ #### OS Requirements
28
+ This package is supported for *Linux*. The package has been tested on the following system:
29
+ + Linux: Ubuntu 20.04
30
+
31
+ #### Python Dependencies
32
+ `FuseMap` mainly depends on the Python scientific stack.
33
+
34
+ ```
35
+ dgl
36
+ numpy
37
+ scipy
38
+ scikit-learn
39
+ pandas
40
+ pytorch
41
+ scanpy
42
+ seaborn
43
+ ```
44
+
45
+
46
+ ## Installation and Tutorial
47
+
48
+ Use Python 3.9–3.11 (3.10 recommended). Install this checkout with:
49
+
50
+ ```bash
51
+ python -m pip install .
52
+ ```
53
+
54
+ For notebook dependencies, use `python -m pip install ".[tutorials]"`.
55
+ The PyPI package is installed with `python -m pip install fusemap`; see the
56
+ [release notes](CHANGELOG.md) for this checkout's version.
57
+
58
+ ```python
59
+ import fusemap
60
+ fusemap.integrate("./data", "./output")
61
+ ```
62
+
63
+ The classic Agent uses `python -m pip install ".[agent]"` from this repository.
64
+ Agent v2 uses a separate environment and a registered scientific kernel; follow
65
+ [the Agent setup instructions](agent_setup/README.md#agent-v2).
66
+
67
+ - Read the FuseMap tutorial [here](https://fusemap.readthedocs.io/en/latest/).
68
+ - FuseMap-Agent set up tutorial [here](https://github.com/wanglab-broad/FuseMap/tree/main/agent_setup).
69
+
70
+
71
+ ## Citation
72
+
73
+ The current manuscript is titled **An agentic AI spatial molecular foundation model of the brain**.
74
+ The earlier public preprint can be cited as:
75
+
76
+ > Yichun He, Hao Sheng, Hailing Shi, Wendy Xueyi Wang, Zefang Tang, Jia Liu, Xiao Wang. Towards a universal spatial molecular atlas of the mouse brain. Preprint at bioRxiv https://www.biorxiv.org/content/10.1101/2024.05.27.594872v1 (2024).
@@ -0,0 +1,58 @@
1
+ # FuseMap 1.1.3 release validation
2
+
3
+ Date: 2026-09-11. These checks apply to the local 1.1.3 working tree and builds.
4
+ They do not certify a GitHub, PyPI, Read the Docs, or Zenodo deployment.
5
+
6
+ | Check | Result |
7
+ |---|---|
8
+ | Mapping validation/checkpoint regression from source | 2 passed (ordinary mapping and optional synchronization hooks) |
9
+ | Same regression against an installed wheel, outside the source tree | 2 passed with Torch 2.0.1+cu117, Scanpy 1.9.3, AnnData 0.11.4, Python 3.10 |
10
+ | Installed import location/version | Confirmed installation under a temporary virtual environment, FuseMap 1.1.3 |
11
+ | Agent v2 dependency resolution | `pip install --dry-run -r requirements-agent-v2.txt` passed against the controller environment |
12
+ | Wheel plus tutorial/Agent extra dependencies | Online pip dry-run resolved successfully against the pinned tutorial environment |
13
+ | Agent v2 scientific kernel smoke check | Registered a temporary kernel; imported FuseMap 1.1.3, retained a variable across calls, saved a plot, and returned a Python error |
14
+ | Notebook validation | All 12 notebooks: valid schema and 115 code cells compile after IPython syntax transformation |
15
+ | Sphinx HTML documentation | Strict offline build (`-W --keep-going`) passed without warnings |
16
+ | Release archives | Source distribution and wheel built; `twine check` passed |
17
+ | Wheel/source consistency | All 24 package Python files match the working tree byte for byte |
18
+ | Patch whitespace | `git diff --check` passed |
19
+
20
+ ## Reproduce the main checks
21
+
22
+ From the repository root with the appropriate dependencies installed:
23
+
24
+ ```bash
25
+ python -m pytest tests/test_map_validation.py -q
26
+ FUSEMAP_DOCS_OFFLINE=1 python -m sphinx -b html -W --keep-going docs docs/_build/html
27
+ python -m build
28
+ python -m twine check dist/fusemap-1.1.3*
29
+ ```
30
+
31
+ Install the wheel in a separate environment and run a copy of the tests from
32
+ outside the repository to verify the packaged code rather than importing the
33
+ checkout. `dist/SHA256SUMS-1.1.3` records the final archive checksums.
34
+
35
+ ## Environment and scope
36
+
37
+ The source regression and kernel smoke check used the existing scientific runtime
38
+ (Torch 2.6.0+cu124); the installed-wheel regression separately checked the declared
39
+ Torch 2.0.1 stack. Temporary test environments and kernel registration were created
40
+ under `/tmp`; existing Conda environments were not changed. The tutorial environment
41
+ had an incomplete optional Dask installation, repaired only in the temporary test
42
+ environment before the installed-wheel checks. Existing library deprecation warnings
43
+ remain; neither mapping regression run reported a test failure after setup.
44
+
45
+ The first online Sphinx build could not retrieve external intersphinx inventories
46
+ in the restricted network. Local notebook links were fixed, and the complete strict
47
+ build passed with only external inventories disabled via `FUSEMAP_DOCS_OFFLINE=1`.
48
+
49
+ The mapping tests execute CPU optimizers, validation, learning-rate scheduling and
50
+ checkpoint promotion with a small model, replacing graph preparation and loss
51
+ construction. They are regression checks, not a scientific integration benchmark.
52
+ The kernel smoke check makes no LLM-provider calls and does not load the full atlas.
53
+
54
+ Existing notebook analysis outputs were retained. Edited setup cells were cleared;
55
+ no fresh full-atlas training, end-to-end tutorial rerun, live LLM analysis, or external
56
+ reference/data download verification is claimed. Tutorial 12 follows the manuscript's
57
+ marmoset data availability-on-request statement. The manuscript and frozen local
58
+ validation snapshots were not modified.
@@ -1,3 +1,5 @@
1
+ __version__ = "1.1.3"
2
+
1
3
  from fusemap.training.integrate import *
2
4
  from fusemap.training.map import *
3
5
  from fusemap.logger import *
@@ -1356,6 +1356,7 @@ def map_model(
1356
1356
  dataloader_pretrain_spatial,
1357
1357
  TRAINED_X_NUM,
1358
1358
  flagconfig,
1359
+ dist_hooks=None,
1359
1360
  ):
1360
1361
  loss_atlas_val_best = float("inf")
1361
1362
  patience_counter = 0
@@ -1,10 +1,11 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fusemap
3
- Version: 1.1.2
3
+ Version: 1.1.3
4
4
  Requires-Python: >=3.9,<3.12
5
5
  Description-Content-Type: text/markdown
6
6
  License-File: LICENSE
7
7
  Requires-Dist: scanpy==1.9.3
8
+ Requires-Dist: anndata<0.12,>=0.9
8
9
  Requires-Dist: torch==2.0.1
9
10
  Requires-Dist: dgl==1.1.1
10
11
  Requires-Dist: sparse==0.14.0
@@ -26,25 +27,36 @@ Requires-Dist: langsmith==0.3.43
26
27
  Requires-Dist: easydict==1.13
27
28
  Requires-Dist: numpy<2,>=1.26
28
29
  Requires-Dist: gdown
30
+ Provides-Extra: tutorials
31
+ Requires-Dist: ipykernel; extra == "tutorials"
32
+ Requires-Dist: scikit-misc<0.6,>=0.3; extra == "tutorials"
33
+ Provides-Extra: agent
34
+ Requires-Dist: tavily-python<1,>=0.7; extra == "agent"
35
+ Requires-Dist: duckduckgo-search<9,>=6; extra == "agent"
29
36
  Dynamic: description
30
37
  Dynamic: description-content-type
31
38
  Dynamic: license-file
39
+ Dynamic: provides-extra
32
40
  Dynamic: requires-dist
33
41
  Dynamic: requires-python
34
42
 
35
43
  # FuseMap
36
- Integrate spatial transcripomics with universal gene, cell, and tissue embeddings.
44
+ Integrate spatial transcriptomics with universal gene, cell, and tissue embeddings.
37
45
 
38
46
  <p align="center">
39
- <img src="/img/framework.png" width="600" >
47
+ <img src="https://raw.githubusercontent.com/wanglab-broad/FuseMap/main/docs/_static/framework.png" width="600" >
40
48
  </p>
41
49
 
42
- For more details, please check out our publication.
50
+ Current manuscript: **An agentic AI spatial molecular foundation model of the brain**.
51
+ See [release notes](CHANGELOG.md) for the distinction between the manuscript workflows
52
+ and the current software, including anchor alignment and Agent v2.
43
53
 
44
54
 
45
55
  ## Manuscript code and data
46
56
  ### Reproducibity
47
- For code and data in the manuscript 'Towards a universal spatial molecular atlas of the mouse brain', please go to [paper_code](paper_code/).
57
+ For manuscript analysis code, see [paper_code](paper_code/). The current manuscript
58
+ describes a frozen code and analysis archive at [Zenodo](https://doi.org/10.5281/zenodo.22103552).
59
+ Use that archive and its run configurations for paper reproduction.
48
60
 
49
61
  ### Exploratory analysis
50
62
  We provide an interactive online database of the [molCCF](http://fusemap.spatial-atlas.net/).
@@ -74,12 +86,33 @@ seaborn
74
86
 
75
87
 
76
88
  ## Installation and Tutorial
89
+
90
+ Use Python 3.9–3.11 (3.10 recommended). Install this checkout with:
91
+
92
+ ```bash
93
+ python -m pip install .
94
+ ```
95
+
96
+ For notebook dependencies, use `python -m pip install ".[tutorials]"`.
97
+ The PyPI package is installed with `python -m pip install fusemap`; see the
98
+ [release notes](CHANGELOG.md) for this checkout's version.
99
+
100
+ ```python
101
+ import fusemap
102
+ fusemap.integrate("./data", "./output")
103
+ ```
104
+
105
+ The classic Agent uses `python -m pip install ".[agent]"` from this repository.
106
+ Agent v2 uses a separate environment and a registered scientific kernel; follow
107
+ [the Agent setup instructions](agent_setup/README.md#agent-v2).
108
+
77
109
  - Read the FuseMap tutorial [here](https://fusemap.readthedocs.io/en/latest/).
78
110
  - FuseMap-Agent set up tutorial [here](https://github.com/wanglab-broad/FuseMap/tree/main/agent_setup).
79
111
 
80
112
 
81
113
  ## Citation
82
114
 
83
- If you find FuseMap useful for your work, please cite our paper:
115
+ The current manuscript is titled **An agentic AI spatial molecular foundation model of the brain**.
116
+ The earlier public preprint can be cited as:
84
117
 
85
118
  > Yichun He, Hao Sheng, Hailing Shi, Wendy Xueyi Wang, Zefang Tang, Jia Liu, Xiao Wang. Towards a universal spatial molecular atlas of the mouse brain. Preprint at bioRxiv https://www.biorxiv.org/content/10.1101/2024.05.27.594872v1 (2024).
@@ -1,5 +1,11 @@
1
+ CHANGELOG.md
1
2
  LICENSE
3
+ MANIFEST.in
2
4
  README.md
5
+ RELEASE_VALIDATION.md
6
+ pyproject.toml
7
+ requirements-agent-v2.txt
8
+ requirements.txt
3
9
  setup.py
4
10
  fusemap/__init__.py
5
11
  fusemap/api.py
@@ -29,4 +35,5 @@ fusemap/training/ddp.py
29
35
  fusemap/training/integrate.py
30
36
  fusemap/training/map.py
31
37
  fusemap/training/sharded.py
32
- fusemap/training/train_model.py
38
+ fusemap/training/train_model.py
39
+ tests/test_map_validation.py
@@ -1,4 +1,5 @@
1
1
  scanpy==1.9.3
2
+ anndata<0.12,>=0.9
2
3
  torch==2.0.1
3
4
  dgl==1.1.1
4
5
  sparse==0.14.0
@@ -20,3 +21,11 @@ langsmith==0.3.43
20
21
  easydict==1.13
21
22
  numpy<2,>=1.26
22
23
  gdown
24
+
25
+ [agent]
26
+ tavily-python<1,>=0.7
27
+ duckduckgo-search<9,>=6
28
+
29
+ [tutorials]
30
+ ipykernel
31
+ scikit-misc<0.6,>=0.3
@@ -0,0 +1,3 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68", "wheel"]
3
+ build-backend = "setuptools.build_meta"
@@ -0,0 +1,11 @@
1
+ # Install in a separate Python 3.11 environment, without fusemap/requirements.txt.
2
+ # The scientific stack runs through the registered fusemap-kernel (see docs/agent).
3
+ langchain>=1.4,<2
4
+ langgraph>=1.2,<2
5
+ langchain-openai>=1.6,<2
6
+ langchain-anthropic>=1.7,<2
7
+ langchain-google-genai>=4.4,<5
8
+ langgraph-checkpoint-sqlite>=3.1,<4
9
+ jupyter-client>=8.6,<9
10
+ streamlit>=1.45,<2
11
+ tavily-python>=0.7,<1
@@ -0,0 +1,3 @@
1
+ # Install the current checkout; dependency versions are maintained in setup.py.
2
+ # Agent v2 uses requirements-agent-v2.txt in a separate environment.
3
+ -e .
@@ -5,10 +5,11 @@ with open('README.md','r') as f:
5
5
 
6
6
  setup(
7
7
  name='fusemap',
8
- version='1.1.2',
8
+ version='1.1.3',
9
9
  packages=find_packages(include=['fusemap', 'fusemap.*']),
10
10
  install_requires=[
11
11
  'scanpy==1.9.3',
12
+ 'anndata>=0.9,<0.12',
12
13
  'torch==2.0.1',
13
14
  'dgl==1.1.1',
14
15
  'sparse==0.14.0',
@@ -32,8 +33,12 @@ setup(
32
33
  "numpy>=1.26,<2",
33
34
  "gdown"
34
35
  ],
36
+ extras_require={
37
+ 'tutorials': ['ipykernel', 'scikit-misc>=0.3,<0.6'],
38
+ 'agent': ['tavily-python>=0.7,<1', 'duckduckgo-search>=6,<9'],
39
+ },
35
40
  python_requires=">=3.9,<3.12",
36
41
  long_description=description,
37
42
  long_description_content_type='text/markdown',
38
43
 
39
- )
44
+ )
@@ -0,0 +1,59 @@
1
+ """Exercise the mapping validation/checkpoint path without a large atlas or GPU."""
2
+ import importlib
3
+ from types import SimpleNamespace
4
+
5
+ import pytest
6
+ import torch
7
+
8
+
9
+ @pytest.mark.parametrize("with_hooks", [False, True])
10
+ def test_mapping_reaches_validation_and_writes_final_checkpoint(tmp_path, monkeypatch, with_hooks):
11
+ training = importlib.import_module("fusemap.training.train_model")
12
+ value = lambda x: SimpleNamespace(value=x)
13
+ config = SimpleNamespace(
14
+ optim_kw=value("RMSprop"), learning_rate=value(0.001),
15
+ lr_factor_pretrain=value(0.5), lr_patience_pretrain=value(2),
16
+ epochs_run_pretrain=0, epochs_run_final=0, n_epochs=value(2), n_atlas=1,
17
+ use_llm_gene_embedding="false", verbose=value(False),
18
+ TRAIN_WITHOUT_EVAL=value(0), patience_limit_final=value(5),
19
+ lr_limit_final=value(1e-5), save_dir=str(tmp_path),
20
+ snapshot_path=str(tmp_path / "snapshot.pt"),
21
+ )
22
+ monkeypatch.setattr(training, "ModelType", config)
23
+ (tmp_path / "trained_model").mkdir()
24
+ model = torch.nn.Module()
25
+ for name in ("discriminator_single", "discriminator_spatial", "encoder", "decoder", "scrna_seq_adj"):
26
+ model.add_module(name, torch.nn.Linear(2, 2))
27
+
28
+ # Replace only graph preparation and loss construction; execute the actual
29
+ # mapping loop, optimizers, validation, scheduling, and checkpoint promotion.
30
+ monkeypatch.setattr(training, "get_data", lambda *a: (None,) * 9)
31
+ monkeypatch.setattr(training, "compute_dis_loss_map",
32
+ lambda m, *a: {"dis": m.discriminator_single.weight.square().sum()})
33
+ validations = []
34
+
35
+ def ae_loss(m, *args):
36
+ loss = m.encoder.weight.square().sum()
37
+ if not torch.is_grad_enabled():
38
+ validations.append(float(loss))
39
+ return {"loss_all": loss, "loss_AE_all": [loss], "dis_ae": loss}
40
+
41
+ monkeypatch.setattr(training, "compute_ae_loss_map", ae_loss)
42
+ synced = []
43
+
44
+ def sync_value(v):
45
+ synced.append(v)
46
+ return v
47
+
48
+ kwargs = {"dist_hooks": SimpleNamespace(sync_value=sync_value)} if with_hooks else {}
49
+ training.map_model(
50
+ model, [None], None, None, torch.device("cpu"), None, None, str(tmp_path),
51
+ [[torch.ones(2, 2)]], [[torch.ones(2, 2)]], 1,
52
+ SimpleNamespace(align_anneal=1e10, lambda_disc_single=1), **kwargs,
53
+ )
54
+ assert len(validations) == 1
55
+ assert len(synced) == int(with_hooks)
56
+ checkpoint = tmp_path / "trained_model" / "FuseMap_map_model_final.pt"
57
+ state = torch.load(checkpoint, map_location="cpu", weights_only=True)
58
+ assert torch.equal(state["encoder.weight"], model.encoder.weight)
59
+ assert not (tmp_path / "trained_model" / "FuseMap_map_model.pt").exists()
fusemap-1.1.2/README.md DELETED
@@ -1,51 +0,0 @@
1
- # FuseMap
2
- Integrate spatial transcripomics with universal gene, cell, and tissue embeddings.
3
-
4
- <p align="center">
5
- <img src="/img/framework.png" width="600" >
6
- </p>
7
-
8
- For more details, please check out our publication.
9
-
10
-
11
- ## Manuscript code and data
12
- ### Reproducibity
13
- For code and data in the manuscript 'Towards a universal spatial molecular atlas of the mouse brain', please go to [paper_code](paper_code/).
14
-
15
- ### Exploratory analysis
16
- We provide an interactive online database of the [molCCF](http://fusemap.spatial-atlas.net/).
17
-
18
- ## System Requirements
19
- ### Hardware requirements
20
- `FuseMap` package requires a standard computer with optional GPU to support the in-memory operations.
21
-
22
- ### Software requirements
23
- #### OS Requirements
24
- This package is supported for *Linux*. The package has been tested on the following system:
25
- + Linux: Ubuntu 20.04
26
-
27
- #### Python Dependencies
28
- `FuseMap` mainly depends on the Python scientific stack.
29
-
30
- ```
31
- dgl
32
- numpy
33
- scipy
34
- scikit-learn
35
- pandas
36
- pytorch
37
- scanpy
38
- seaborn
39
- ```
40
-
41
-
42
- ## Installation and Tutorial
43
- - Read the FuseMap tutorial [here](https://fusemap.readthedocs.io/en/latest/).
44
- - FuseMap-Agent set up tutorial [here](https://github.com/wanglab-broad/FuseMap/tree/main/agent_setup).
45
-
46
-
47
- ## Citation
48
-
49
- If you find FuseMap useful for your work, please cite our paper:
50
-
51
- > Yichun He, Hao Sheng, Hailing Shi, Wendy Xueyi Wang, Zefang Tang, Jia Liu, Xiao Wang. Towards a universal spatial molecular atlas of the mouse brain. Preprint at bioRxiv https://www.biorxiv.org/content/10.1101/2024.05.27.594872v1 (2024).
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes