chatspatial 1.0.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.
- chatspatial-1.0.0/LICENSE +21 -0
- chatspatial-1.0.0/PKG-INFO +76 -0
- chatspatial-1.0.0/README.md +379 -0
- chatspatial-1.0.0/chatspatial/__init__.py +11 -0
- chatspatial-1.0.0/chatspatial/__main__.py +141 -0
- chatspatial-1.0.0/chatspatial/cli/__init__.py +9 -0
- chatspatial-1.0.0/chatspatial/config.py +53 -0
- chatspatial-1.0.0/chatspatial/models/__init__.py +72 -0
- chatspatial-1.0.0/chatspatial/models/analysis.py +323 -0
- chatspatial-1.0.0/chatspatial/models/data.py +2191 -0
- chatspatial-1.0.0/chatspatial/server.py +1943 -0
- chatspatial-1.0.0/chatspatial/spatial_mcp_adapter.py +790 -0
- chatspatial-1.0.0/chatspatial/tools/__init__.py +3 -0
- chatspatial-1.0.0/chatspatial/tools/annotation.py +1830 -0
- chatspatial-1.0.0/chatspatial/tools/cell_communication.py +1325 -0
- chatspatial-1.0.0/chatspatial/tools/cnv_analysis.py +605 -0
- chatspatial-1.0.0/chatspatial/tools/deconvolution/__init__.py +355 -0
- chatspatial-1.0.0/chatspatial/tools/deconvolution/base.py +299 -0
- chatspatial-1.0.0/chatspatial/tools/deconvolution/card.py +245 -0
- chatspatial-1.0.0/chatspatial/tools/deconvolution/cell2location.py +382 -0
- chatspatial-1.0.0/chatspatial/tools/deconvolution/destvi.py +148 -0
- chatspatial-1.0.0/chatspatial/tools/deconvolution/flashdeconv.py +108 -0
- chatspatial-1.0.0/chatspatial/tools/deconvolution/rctd.py +320 -0
- chatspatial-1.0.0/chatspatial/tools/deconvolution/spotlight.py +213 -0
- chatspatial-1.0.0/chatspatial/tools/deconvolution/stereoscope.py +112 -0
- chatspatial-1.0.0/chatspatial/tools/deconvolution/tangram.py +142 -0
- chatspatial-1.0.0/chatspatial/tools/differential.py +370 -0
- chatspatial-1.0.0/chatspatial/tools/embeddings.py +298 -0
- chatspatial-1.0.0/chatspatial/tools/enrichment.py +1737 -0
- chatspatial-1.0.0/chatspatial/tools/integration.py +912 -0
- chatspatial-1.0.0/chatspatial/tools/preprocessing.py +723 -0
- chatspatial-1.0.0/chatspatial/tools/spatial_domains.py +766 -0
- chatspatial-1.0.0/chatspatial/tools/spatial_genes.py +887 -0
- chatspatial-1.0.0/chatspatial/tools/spatial_registration.py +469 -0
- chatspatial-1.0.0/chatspatial/tools/spatial_statistics.py +1370 -0
- chatspatial-1.0.0/chatspatial/tools/trajectory.py +1006 -0
- chatspatial-1.0.0/chatspatial/tools/visualization/__init__.py +145 -0
- chatspatial-1.0.0/chatspatial/tools/visualization/basic.py +415 -0
- chatspatial-1.0.0/chatspatial/tools/visualization/cell_comm.py +684 -0
- chatspatial-1.0.0/chatspatial/tools/visualization/cnv.py +318 -0
- chatspatial-1.0.0/chatspatial/tools/visualization/core.py +484 -0
- chatspatial-1.0.0/chatspatial/tools/visualization/deconvolution.py +811 -0
- chatspatial-1.0.0/chatspatial/tools/visualization/enrichment.py +615 -0
- chatspatial-1.0.0/chatspatial/tools/visualization/integration.py +205 -0
- chatspatial-1.0.0/chatspatial/tools/visualization/main.py +164 -0
- chatspatial-1.0.0/chatspatial/tools/visualization/multi_gene.py +739 -0
- chatspatial-1.0.0/chatspatial/tools/visualization/persistence.py +374 -0
- chatspatial-1.0.0/chatspatial/tools/visualization/spatial_stats.py +484 -0
- chatspatial-1.0.0/chatspatial/tools/visualization/trajectory.py +649 -0
- chatspatial-1.0.0/chatspatial/tools/visualization/velocity.py +404 -0
- chatspatial-1.0.0/chatspatial/utils/__init__.py +109 -0
- chatspatial-1.0.0/chatspatial/utils/adata_utils.py +1325 -0
- chatspatial-1.0.0/chatspatial/utils/compute.py +327 -0
- chatspatial-1.0.0/chatspatial/utils/data_loader.py +522 -0
- chatspatial-1.0.0/chatspatial/utils/dependency_manager.py +879 -0
- chatspatial-1.0.0/chatspatial/utils/exceptions.py +199 -0
- chatspatial-1.0.0/chatspatial/utils/image_utils.py +377 -0
- chatspatial-1.0.0/chatspatial/utils/mcp_utils.py +138 -0
- chatspatial-1.0.0/chatspatial/utils/path_utils.py +243 -0
- chatspatial-1.0.0/chatspatial/utils/persistence.py +78 -0
- chatspatial-1.0.0/chatspatial.egg-info/PKG-INFO +76 -0
- chatspatial-1.0.0/chatspatial.egg-info/SOURCES.txt +66 -0
- chatspatial-1.0.0/chatspatial.egg-info/dependency_links.txt +1 -0
- chatspatial-1.0.0/chatspatial.egg-info/entry_points.txt +2 -0
- chatspatial-1.0.0/chatspatial.egg-info/requires.txt +73 -0
- chatspatial-1.0.0/chatspatial.egg-info/top_level.txt +1 -0
- chatspatial-1.0.0/pyproject.toml +193 -0
- chatspatial-1.0.0/setup.cfg +4 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 ChatSpatial Contributors
|
|
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,76 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: chatspatial
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: ChatSpatial: Natural language-driven spatial transcriptomics analysis via Model Context Protocol (MCP) integration
|
|
5
|
+
Requires-Python: <3.14,>=3.10
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
Requires-Dist: mcp>=1.17.0
|
|
8
|
+
Requires-Dist: numpy>=1.21.0
|
|
9
|
+
Requires-Dist: pandas>=1.3.0
|
|
10
|
+
Requires-Dist: scipy>=1.7.0
|
|
11
|
+
Requires-Dist: scikit-learn>=1.0.0
|
|
12
|
+
Requires-Dist: matplotlib>=3.5.0
|
|
13
|
+
Requires-Dist: seaborn>=0.11.0
|
|
14
|
+
Requires-Dist: Pillow>=8.0.0
|
|
15
|
+
Requires-Dist: scanpy<2.0,>=1.9.0
|
|
16
|
+
Requires-Dist: anndata>=0.11.0
|
|
17
|
+
Requires-Dist: squidpy>=1.2.0
|
|
18
|
+
Requires-Dist: umap-learn>=0.5.0
|
|
19
|
+
Requires-Dist: igraph>=0.9.0
|
|
20
|
+
Requires-Dist: leidenalg>=0.8.0
|
|
21
|
+
Requires-Dist: pydantic<3.0,>=2.0.0
|
|
22
|
+
Requires-Dist: click>=8.0.0
|
|
23
|
+
Requires-Dist: aiohttp>=3.8.0
|
|
24
|
+
Requires-Dist: jinja2>=3.0.0
|
|
25
|
+
Requires-Dist: scvi-tools<2.0,>=1.0.0
|
|
26
|
+
Requires-Dist: mudata>=0.2.0
|
|
27
|
+
Requires-Dist: scvelo>=0.2.5
|
|
28
|
+
Requires-Dist: liana
|
|
29
|
+
Requires-Dist: cellphonedb<6.0,>=5.0.0
|
|
30
|
+
Requires-Dist: ktplotspy>=0.3.0
|
|
31
|
+
Requires-Dist: harmonypy>=0.0.9
|
|
32
|
+
Requires-Dist: bbknn>=1.5.0
|
|
33
|
+
Requires-Dist: esda>=2.4.0
|
|
34
|
+
Requires-Dist: libpysal>=4.6.0
|
|
35
|
+
Requires-Dist: gseapy>=1.0.0
|
|
36
|
+
Provides-Extra: full
|
|
37
|
+
Requires-Dist: torch<3.0,>=2.0.0; extra == "full"
|
|
38
|
+
Requires-Dist: SpaGCN<2.0,>=1.2.5; extra == "full"
|
|
39
|
+
Requires-Dist: GraphST>=1.1.0; extra == "full"
|
|
40
|
+
Requires-Dist: cell2location>=0.1.4; extra == "full"
|
|
41
|
+
Requires-Dist: cellrank<3.0,>=2.0.0; extra == "full"
|
|
42
|
+
Requires-Dist: palantir>=1.0.0; extra == "full"
|
|
43
|
+
Requires-Dist: petsc4py<4.0,>=3.18.0; sys_platform != "win32" and extra == "full"
|
|
44
|
+
Requires-Dist: slepc4py<4.0,>=3.18.0; sys_platform != "win32" and extra == "full"
|
|
45
|
+
Requires-Dist: scanorama>=1.7.0; extra == "full"
|
|
46
|
+
Requires-Dist: spatialde>=1.1.3; extra == "full"
|
|
47
|
+
Requires-Dist: scikit-misc>=0.5.0; extra == "full"
|
|
48
|
+
Requires-Dist: tangram-sc>=1.0.0; extra == "full"
|
|
49
|
+
Requires-Dist: singler>=0.4.0; sys_platform != "win32" and extra == "full"
|
|
50
|
+
Requires-Dist: singlecellexperiment>=0.4.0; sys_platform != "win32" and extra == "full"
|
|
51
|
+
Requires-Dist: celldex>=0.3.0; sys_platform != "win32" and extra == "full"
|
|
52
|
+
Requires-Dist: mllmcelltype>=0.1.0; extra == "full"
|
|
53
|
+
Requires-Dist: rpy2<3.7,>=3.5.0; extra == "full"
|
|
54
|
+
Requires-Dist: anndata2ri>=1.3.0; extra == "full"
|
|
55
|
+
Requires-Dist: pysal>=2.6.0; extra == "full"
|
|
56
|
+
Requires-Dist: statsmodels>=0.13.0; extra == "full"
|
|
57
|
+
Requires-Dist: networkx>=2.6.0; extra == "full"
|
|
58
|
+
Requires-Dist: POT>=0.9.0; extra == "full"
|
|
59
|
+
Requires-Dist: paste-bio>=1.0.0; extra == "full"
|
|
60
|
+
Requires-Dist: infercnvpy>=0.4.0; extra == "full"
|
|
61
|
+
Requires-Dist: enrichmap; extra == "full"
|
|
62
|
+
Requires-Dist: statannotations>=0.2.0; extra == "full"
|
|
63
|
+
Requires-Dist: pygam>=0.8.0; extra == "full"
|
|
64
|
+
Requires-Dist: scikit-gstat>=1.0.0; extra == "full"
|
|
65
|
+
Requires-Dist: adjustText>=0.8.0; extra == "full"
|
|
66
|
+
Requires-Dist: splot>=1.1.0; extra == "full"
|
|
67
|
+
Requires-Dist: spatialdata>=0.2.0; extra == "full"
|
|
68
|
+
Provides-Extra: dev
|
|
69
|
+
Requires-Dist: pytest>=8.0.0; extra == "dev"
|
|
70
|
+
Requires-Dist: pytest-asyncio<2.0,>=0.23.0; extra == "dev"
|
|
71
|
+
Requires-Dist: black<26.0,>=22.0.0; extra == "dev"
|
|
72
|
+
Requires-Dist: mypy<2.0,>=1.0.0; extra == "dev"
|
|
73
|
+
Requires-Dist: ruff>=0.1.0; extra == "dev"
|
|
74
|
+
Requires-Dist: isort>=5.0.0; extra == "dev"
|
|
75
|
+
Requires-Dist: pre-commit<5.0,>=3.0.0; extra == "dev"
|
|
76
|
+
Dynamic: license-file
|
|
@@ -0,0 +1,379 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
<img src="assets/images/chatspatial-logo.png" alt="ChatSpatial Logo" width="300"/>
|
|
4
|
+
|
|
5
|
+
# ChatSpatial
|
|
6
|
+
|
|
7
|
+
[](https://www.python.org/downloads/) [](https://modelcontextprotocol.io) [](https://opensource.org/licenses/MIT) [](https://cafferychen777.github.io/ChatSpatial/)
|
|
8
|
+
|
|
9
|
+
### Agentic Workflow Orchestration for Spatial Transcriptomics Analysis
|
|
10
|
+
|
|
11
|
+
</div>
|
|
12
|
+
|
|
13
|
+
**Eliminate the implementation tax. Focus on biological insight.**
|
|
14
|
+
|
|
15
|
+
ChatSpatial is an agentic workflow orchestration platform that integrates 60 state-of-the-art methods from fragmented Python and R ecosystems into a unified conversational interface. Built on the Model Context Protocol (MCP), it enables human-steered discovery through natural language in Claude Desktop or Claude Code, eliminating the need for manual data conversion and complex programming.
|
|
16
|
+
|
|
17
|
+
**🎯 Example: Analyze spatial transcriptomics data through conversation with Claude**
|
|
18
|
+
|
|
19
|
+
```text
|
|
20
|
+
👤 "Load my 10x Visium dataset and identify spatial domains"
|
|
21
|
+
🤖 ✅ Loaded 3,456 spots, 18,078 genes
|
|
22
|
+
✅ Identified 7 spatial domains using SpaGCN
|
|
23
|
+
✅ Generated spatial domain visualization
|
|
24
|
+
|
|
25
|
+
👤 "Find marker genes for domain 3 and create a heatmap"
|
|
26
|
+
🤖 ✅ Found 23 significant markers (adj. p < 0.05)
|
|
27
|
+
✅ Top markers: GFAP, S100B, AQP4 (astrocyte signature)
|
|
28
|
+
✅ Generated expression heatmap
|
|
29
|
+
```
|
|
30
|
+
*👤 = You chatting with Claude | 🤖 = ChatSpatial MCP executing analysis*
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## 🚀 Why Researchers Choose ChatSpatial
|
|
36
|
+
|
|
37
|
+
<table>
|
|
38
|
+
<tr>
|
|
39
|
+
<td width="50%" valign="top">
|
|
40
|
+
|
|
41
|
+
### Before: Traditional Analysis
|
|
42
|
+
```python
|
|
43
|
+
# 50+ lines of code for basic analysis
|
|
44
|
+
import scanpy as sc
|
|
45
|
+
import squidpy as sq
|
|
46
|
+
import pandas as pd
|
|
47
|
+
import matplotlib.pyplot as plt
|
|
48
|
+
|
|
49
|
+
adata = sc.read_h5ad("data.h5ad")
|
|
50
|
+
sc.pp.filter_cells(adata, min_genes=200)
|
|
51
|
+
sc.pp.filter_genes(adata, min_cells=3)
|
|
52
|
+
# ... 40+ more lines ...
|
|
53
|
+
```
|
|
54
|
+
❌ Hours of coding
|
|
55
|
+
❌ Complex syntax
|
|
56
|
+
❌ Error-prone
|
|
57
|
+
❌ Steep learning curve
|
|
58
|
+
|
|
59
|
+
</td>
|
|
60
|
+
<td width="50%" valign="top">
|
|
61
|
+
|
|
62
|
+
### After: ChatSpatial
|
|
63
|
+
**Chat with Claude using natural language:**
|
|
64
|
+
```text
|
|
65
|
+
"Analyze my Visium data and find
|
|
66
|
+
spatially variable genes"
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
✅ **5 seconds to results**
|
|
70
|
+
✅ **Plain English in Claude chat**
|
|
71
|
+
✅ **Zero programming required**
|
|
72
|
+
✅ **Publication-ready output**
|
|
73
|
+
✅ **60 methods via MCP**
|
|
74
|
+
|
|
75
|
+
</td>
|
|
76
|
+
</tr>
|
|
77
|
+
</table>
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## ⚡ Quick Start (2 Minutes)
|
|
82
|
+
|
|
83
|
+
### 1. Create Virtual Environment & Install
|
|
84
|
+
```bash
|
|
85
|
+
# Clone and enter directory
|
|
86
|
+
git clone https://github.com/cafferychen777/ChatSpatial.git
|
|
87
|
+
cd chatspatial
|
|
88
|
+
|
|
89
|
+
# Create virtual environment (strongly recommended)
|
|
90
|
+
# For macOS with Homebrew Python:
|
|
91
|
+
/opt/homebrew/bin/python3.10 -m venv chatspatial_env # macOS Homebrew
|
|
92
|
+
# For other systems:
|
|
93
|
+
# python3 -m venv chatspatial_env # Linux/other systems
|
|
94
|
+
source chatspatial_env/bin/activate # macOS/Linux
|
|
95
|
+
# chatspatial_env\Scripts\activate # Windows
|
|
96
|
+
|
|
97
|
+
# Verify Python version and install
|
|
98
|
+
python --version # Should be 3.10+
|
|
99
|
+
pip install --upgrade pip
|
|
100
|
+
pip install -e ".[full]" # Recommended: All features included
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
> 💡 **Windows Users:** SingleR and PETSc acceleration are not available on Windows due to C++ compilation limitations. Use alternative cell type annotation methods (Tangram, scANVI, CellAssign). All R-based methods (RCTD, SPOTlight, Numbat) work on Windows. See [INSTALLATION.md](INSTALLATION.md#windows) for details.
|
|
104
|
+
|
|
105
|
+
### 2. Configure Your Client
|
|
106
|
+
|
|
107
|
+
<details>
|
|
108
|
+
<summary><strong>Option A: Claude Desktop</strong> (GUI Application)</summary>
|
|
109
|
+
|
|
110
|
+
> 💡 **New to Claude Desktop?** [Download Claude Desktop](https://claude.com/download) from Anthropic's official site (available for Mac & Windows)
|
|
111
|
+
|
|
112
|
+
Add to `~/Library/Application Support/Claude/claude_desktop_config.json`:
|
|
113
|
+
```json
|
|
114
|
+
{
|
|
115
|
+
"mcpServers": {
|
|
116
|
+
"chatspatial": {
|
|
117
|
+
"command": "/path/to/chatspatial_env/bin/python",
|
|
118
|
+
"args": ["-m", "chatspatial", "server"]
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
</details>
|
|
124
|
+
|
|
125
|
+
<details>
|
|
126
|
+
<summary><strong>Option B: Claude Code</strong> (Terminal/IDE)</summary>
|
|
127
|
+
|
|
128
|
+
**Step 1: Install Claude Code CLI**
|
|
129
|
+
```bash
|
|
130
|
+
npm install -g @anthropic-ai/claude-code
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
**Step 2: Find Your Virtual Environment Path**
|
|
134
|
+
```bash
|
|
135
|
+
# First, activate your virtual environment
|
|
136
|
+
source chatspatial_env/bin/activate
|
|
137
|
+
|
|
138
|
+
# Then get the exact Python path (copy this output!)
|
|
139
|
+
which python
|
|
140
|
+
```
|
|
141
|
+
**Example output:** `/Users/yourname/Research/chatspatial_env/bin/python`
|
|
142
|
+
|
|
143
|
+
**Step 3: Add ChatSpatial MCP Server**
|
|
144
|
+
```bash
|
|
145
|
+
# Replace <PYTHON_PATH_FROM_STEP_2> with the actual path from step 2
|
|
146
|
+
claude mcp add chatspatial <PYTHON_PATH_FROM_STEP_2> -- -m chatspatial server
|
|
147
|
+
|
|
148
|
+
# Example with real path:
|
|
149
|
+
# claude mcp add chatspatial /Users/yourname/Research/chatspatial_env/bin/python -- -m chatspatial server
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
**Step 4: Verify Installation**
|
|
153
|
+
```bash
|
|
154
|
+
claude mcp list
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
**Step 5: Restart Claude Code** ⚠️
|
|
158
|
+
```bash
|
|
159
|
+
# IMPORTANT: Exit and restart Claude Code for changes to take effect
|
|
160
|
+
/quit
|
|
161
|
+
|
|
162
|
+
# Then re-enter Claude Code
|
|
163
|
+
claude
|
|
164
|
+
```
|
|
165
|
+
> 💡 **Note**: After adding the MCP server, you MUST restart Claude Code using `/quit` and then re-enter with `claude` for ChatSpatial to appear in the available tools.
|
|
166
|
+
|
|
167
|
+
</details>
|
|
168
|
+
|
|
169
|
+
### 3. Download Sample Data & Start Analyzing
|
|
170
|
+
|
|
171
|
+
**🎯 Quick Test (1 minute):**
|
|
172
|
+
|
|
173
|
+
1. **Download sample datasets**: Go to [**ChatSpatial Releases**](https://github.com/cafferychen777/ChatSpatial/releases/tag/v0.3.0-data)
|
|
174
|
+
2. **Download these files**:
|
|
175
|
+
- `card_reference_filtered.h5ad` (36MB - pancreatic reference with 9 cell types)
|
|
176
|
+
- `card_spatial.h5ad` (7.7MB - spatial data with clear tissue domains)
|
|
177
|
+
|
|
178
|
+
**3. Open Claude Desktop or Claude Code and chat with ChatSpatial:**
|
|
179
|
+
|
|
180
|
+
> 💡 **Important**: Tell Claude to use ChatSpatial MCP for your spatial analysis (e.g., "Use ChatSpatial MCP for all my spatial transcriptomics analysis"). This ensures Claude calls the MCP tools instead of writing scripts.
|
|
181
|
+
|
|
182
|
+
Simply type this natural language request in your Claude chat:
|
|
183
|
+
|
|
184
|
+
```text
|
|
185
|
+
Load /Users/yourname/Downloads/card_reference_filtered.h5ad and /Users/yourname/Downloads/card_spatial.h5ad, then show me the tissue structure
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
> 💡 **How it works**: ChatSpatial MCP server interprets your natural language and automatically calls the appropriate analysis tools. No coding required!
|
|
189
|
+
|
|
190
|
+
> ⚠️ **IMPORTANT**: Use **absolute paths** when loading data (e.g., `/Users/yourname/Downloads/card_reference_filtered.h5ad`)
|
|
191
|
+
|
|
192
|
+
**🎯 That's it!** ChatSpatial will load your data and create a beautiful spatial visualization - all through natural language conversation.
|
|
193
|
+
|
|
194
|
+
> **📚 Detailed Setup Guides**: [Claude Desktop](INSTALLATION.md#claude-desktop) | [Claude Code](INSTALLATION.md#claude-code)
|
|
195
|
+
|
|
196
|
+
---
|
|
197
|
+
|
|
198
|
+
## 🧬 What You Can Do
|
|
199
|
+
|
|
200
|
+
> 💬 **All examples below are natural language commands you type in Claude chat with ChatSpatial MCP**
|
|
201
|
+
|
|
202
|
+
### 📊 **Try These Examples** (After Loading Sample Data)
|
|
203
|
+
|
|
204
|
+
Chat with Claude using these natural language requests:
|
|
205
|
+
|
|
206
|
+
```text
|
|
207
|
+
Identify spatial domains using SpaGCN
|
|
208
|
+
|
|
209
|
+
Deconvolve the spatial data using the reference with Cell2location
|
|
210
|
+
|
|
211
|
+
Analyze cell communication between spatial regions
|
|
212
|
+
|
|
213
|
+
Find spatially variable genes and create heatmaps
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
**What happens**: ChatSpatial MCP automatically selects the right tools, runs the analysis, and returns publication-ready visualizations.
|
|
217
|
+
|
|
218
|
+
### 🔍 **Spatial Analysis - Just Ask in Plain English**
|
|
219
|
+
|
|
220
|
+
| Your Question | What ChatSpatial Does |
|
|
221
|
+
|---------------|----------------------|
|
|
222
|
+
| "Find spatial domains" | Runs SpaGCN/STAGATE/Leiden clustering |
|
|
223
|
+
| "Detect hotspots" | Applies Getis-Ord Gi* spatial statistics |
|
|
224
|
+
| "Map cell territories" | Performs spatial neighborhood analysis |
|
|
225
|
+
|
|
226
|
+
### 🧮 **Advanced Methods - No Coding Knowledge Required**
|
|
227
|
+
|
|
228
|
+
| Your Request | Methods Used |
|
|
229
|
+
|-------------|--------------|
|
|
230
|
+
| "Deconvolve this spatial data" | Cell2location + scvi-tools |
|
|
231
|
+
| "Analyze cell communication" | LIANA+ + CellPhoneDB |
|
|
232
|
+
| "Find developmental trajectories" | CellRank + Palantir |
|
|
233
|
+
| "Run pathway enrichment" | GSEA + spatial smoothing |
|
|
234
|
+
|
|
235
|
+
### 🎨 **Instant Visualizations**
|
|
236
|
+
- **Spatial plots** with tissue overlays
|
|
237
|
+
- **Interactive heatmaps** for gene expression
|
|
238
|
+
- **Communication networks** between cell types
|
|
239
|
+
- **Trajectory flow maps** for development
|
|
240
|
+
- **Domain boundary visualizations**
|
|
241
|
+
|
|
242
|
+
---
|
|
243
|
+
|
|
244
|
+
## 🎯 Choose Your Path
|
|
245
|
+
|
|
246
|
+
<table>
|
|
247
|
+
<tr>
|
|
248
|
+
<td width="33%" align="center">
|
|
249
|
+
|
|
250
|
+
### 🚀 **Researchers**
|
|
251
|
+
**Quick start?**
|
|
252
|
+
|
|
253
|
+
```bash
|
|
254
|
+
pip install -e .
|
|
255
|
+
```
|
|
256
|
+
✅ 80% of features
|
|
257
|
+
✅ Most common methods
|
|
258
|
+
✅ 6-minute install
|
|
259
|
+
|
|
260
|
+
**→ [Research Quick Start](docs/getting-started/quick-start.md)**
|
|
261
|
+
|
|
262
|
+
</td>
|
|
263
|
+
<td width="33%" align="center">
|
|
264
|
+
|
|
265
|
+
### 🧠 **Power Users**
|
|
266
|
+
**Want everything?**
|
|
267
|
+
|
|
268
|
+
```bash
|
|
269
|
+
pip install -e ".[full]"
|
|
270
|
+
```
|
|
271
|
+
✅ 100% of features
|
|
272
|
+
✅ All 16+ methods
|
|
273
|
+
✅ Deep learning included
|
|
274
|
+
|
|
275
|
+
**→ [Advanced Setup Guide](docs/tutorials/learning-paths/advanced.md)**
|
|
276
|
+
|
|
277
|
+
</td>
|
|
278
|
+
<td width="33%" align="center">
|
|
279
|
+
|
|
280
|
+
### 👩💻 **Developers**
|
|
281
|
+
**Want to contribute?**
|
|
282
|
+
|
|
283
|
+
```bash
|
|
284
|
+
pip install -e ".[dev]"
|
|
285
|
+
```
|
|
286
|
+
✅ Development tools
|
|
287
|
+
✅ Testing framework
|
|
288
|
+
✅ Documentation
|
|
289
|
+
|
|
290
|
+
**→ [Contributor Guide](CONTRIBUTING.md)**
|
|
291
|
+
|
|
292
|
+
</td>
|
|
293
|
+
</tr>
|
|
294
|
+
</table>
|
|
295
|
+
|
|
296
|
+
---
|
|
297
|
+
|
|
298
|
+
## 🛠️ Technical Capabilities
|
|
299
|
+
|
|
300
|
+
<details>
|
|
301
|
+
<summary><strong>📊 Data Formats Supported</strong></summary>
|
|
302
|
+
|
|
303
|
+
- **10x Genomics**: Visium, Xenium
|
|
304
|
+
- **Spatial Technologies**: Slide-seq v2
|
|
305
|
+
- **Multiplexed Imaging**: MERFISH, seqFISH
|
|
306
|
+
- **Standard Formats**: H5AD, H5, MTX, CSV
|
|
307
|
+
|
|
308
|
+
</details>
|
|
309
|
+
|
|
310
|
+
<details>
|
|
311
|
+
<summary><strong>🔬 Analysis Methods (12 Categories, 75+ Methods)</strong></summary>
|
|
312
|
+
|
|
313
|
+
| Category | Methods |
|
|
314
|
+
|----------|---------|
|
|
315
|
+
| **Cell Type Annotation** | Tangram, scANVI, CellAssign, mLLMCellType, sc-type, SingleR |
|
|
316
|
+
| **Spatial Domains** | SpaGCN, STAGATE, Leiden clustering |
|
|
317
|
+
| **Cell Communication** | LIANA+, CellPhoneDB, CellChat (via LIANA) |
|
|
318
|
+
| **Deconvolution** | Cell2location, DestVI, RCTD, Tangram, Stereoscope, SPOTlight |
|
|
319
|
+
| **CNV Analysis** | infercnvpy, Numbat (haplotype-aware CNV analysis) |
|
|
320
|
+
| **Spatial Variable Genes** | SpatialDE, SPARK-X |
|
|
321
|
+
| **Trajectory & Velocity** | CellRank, Palantir, DPT, scVelo, VeloVI |
|
|
322
|
+
| **Sample Integration** | Harmony, BBKNN, Scanorama, scVI |
|
|
323
|
+
| **Differential Expression** | Wilcoxon, t-test, Logistic Regression (scanpy methods) |
|
|
324
|
+
| **Gene Set Enrichment** | GSEA, ORA, ssGSEA, Enrichr, Spatial EnrichMap |
|
|
325
|
+
| **Spatial Statistics** | Moran's I, Local Moran's I (LISA), Geary's C, Getis-Ord Gi*, Neighborhood Enrichment, Co-occurrence, Ripley's K/L, Bivariate Moran's I, Join Count, Network Properties, Spatial Centrality |
|
|
326
|
+
| **Spatial Registration** | PASTE, STalign |
|
|
327
|
+
|
|
328
|
+
</details>
|
|
329
|
+
|
|
330
|
+
<details>
|
|
331
|
+
<summary><strong>⚙️ System Requirements</strong></summary>
|
|
332
|
+
|
|
333
|
+
- **Python**: 3.10+ (required for MCP)
|
|
334
|
+
- **Memory**: 8GB+ RAM (16GB+ for large datasets)
|
|
335
|
+
- **Storage**: 5GB+ for dependencies
|
|
336
|
+
- **OS**: Linux, macOS, Windows (WSL recommended)
|
|
337
|
+
- **GPU**: Optional (speeds up deep learning methods)
|
|
338
|
+
|
|
339
|
+
</details>
|
|
340
|
+
|
|
341
|
+
---
|
|
342
|
+
|
|
343
|
+
## 🤝 Community & Support
|
|
344
|
+
|
|
345
|
+
- **📧 Issues**: [GitHub Issues](https://github.com/cafferychen777/ChatSpatial/issues) for bug reports
|
|
346
|
+
- **📖 Docs**: [Complete documentation](docs/) with tutorials
|
|
347
|
+
- **⭐ Star this repo** to follow development
|
|
348
|
+
|
|
349
|
+
---
|
|
350
|
+
|
|
351
|
+
## 📄 License & Citation
|
|
352
|
+
|
|
353
|
+
**MIT License** - Free for academic and commercial use.
|
|
354
|
+
|
|
355
|
+
If ChatSpatial helps your research, please cite:
|
|
356
|
+
```bibtex
|
|
357
|
+
@software{chatspatial2025,
|
|
358
|
+
title={ChatSpatial: An Agentic Framework for Reproducible Cross-Platform Spatial Transcriptomics Analysis},
|
|
359
|
+
author={Chen Yang and Xianyang Zhang and Jun Chen},
|
|
360
|
+
year={2025},
|
|
361
|
+
url={https://github.com/cafferychen777/ChatSpatial},
|
|
362
|
+
note={Manuscript in preparation}
|
|
363
|
+
}
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
## 🙏 Built With
|
|
367
|
+
|
|
368
|
+
ChatSpatial stands on the shoulders of giants:
|
|
369
|
+
[**Scanpy**](https://scanpy.readthedocs.io/) • [**Squidpy**](https://squidpy.readthedocs.io/) • [**scvi-tools**](https://scvi-tools.org/) • [**LIANA**](https://liana-py.readthedocs.io/) • [**Anthropic MCP**](https://modelcontextprotocol.io/)
|
|
370
|
+
|
|
371
|
+
---
|
|
372
|
+
|
|
373
|
+
<div align="center">
|
|
374
|
+
|
|
375
|
+
**Made with ❤️ for the spatial transcriptomics community**
|
|
376
|
+
|
|
377
|
+
[⭐ **Star us on GitHub**](https://github.com/cafferychen777/ChatSpatial) if this project helps you!
|
|
378
|
+
|
|
379
|
+
</div>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"""
|
|
2
|
+
ChatSpatial
|
|
3
|
+
|
|
4
|
+
Agentic workflow orchestration platform for spatial transcriptomics analysis.
|
|
5
|
+
Integrates 60 methods from Python and R ecosystems via Model Context Protocol.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
__version__ = "1.0.0"
|
|
9
|
+
|
|
10
|
+
# Import configuration to set up environment
|
|
11
|
+
from . import config as config # noqa: F401
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Entry point for ChatSpatial.
|
|
3
|
+
|
|
4
|
+
This module provides the command-line interface for starting the
|
|
5
|
+
ChatSpatial server using either stdio or SSE transport.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import os
|
|
9
|
+
import sys
|
|
10
|
+
import traceback
|
|
11
|
+
import warnings
|
|
12
|
+
from pathlib import Path
|
|
13
|
+
|
|
14
|
+
import click
|
|
15
|
+
|
|
16
|
+
# Suppress warnings to speed up startup
|
|
17
|
+
warnings.filterwarnings("ignore", category=FutureWarning)
|
|
18
|
+
warnings.filterwarnings("ignore", category=UserWarning)
|
|
19
|
+
|
|
20
|
+
# CRITICAL: Disable all progress bars to prevent stdout pollution in MCP protocol
|
|
21
|
+
# MCP uses JSON-RPC over stdio, any non-JSON output breaks communication
|
|
22
|
+
os.environ["TQDM_DISABLE"] = "1" # Disable tqdm globally
|
|
23
|
+
|
|
24
|
+
# Configure scientific libraries to suppress output
|
|
25
|
+
try:
|
|
26
|
+
import scanpy as sc
|
|
27
|
+
|
|
28
|
+
sc.settings.verbosity = 0 # Suppress scanpy output
|
|
29
|
+
except ImportError:
|
|
30
|
+
pass # scanpy may not be installed yet
|
|
31
|
+
|
|
32
|
+
# IMPORTANT: Intelligent working directory handling
|
|
33
|
+
# Only change cwd when it's clearly problematic, otherwise respect user configuration
|
|
34
|
+
PROJECT_ROOT = Path(__file__).parent.resolve()
|
|
35
|
+
user_cwd = Path.cwd()
|
|
36
|
+
|
|
37
|
+
# Identify problematic working directories that should be changed
|
|
38
|
+
problematic_cwds = [
|
|
39
|
+
Path("/"), # Root directory
|
|
40
|
+
Path("/tmp"), # Temp directory
|
|
41
|
+
Path("/var"), # System directory
|
|
42
|
+
Path("/usr"), # System directory
|
|
43
|
+
Path("/etc"), # System directory
|
|
44
|
+
]
|
|
45
|
+
|
|
46
|
+
# Check if current cwd is problematic
|
|
47
|
+
is_problematic = (
|
|
48
|
+
# Check exact match
|
|
49
|
+
user_cwd in problematic_cwds
|
|
50
|
+
or
|
|
51
|
+
# Check if cwd is a parent of problematic directories
|
|
52
|
+
any(user_cwd == p.parent for p in problematic_cwds)
|
|
53
|
+
or
|
|
54
|
+
# Check if directory doesn't exist
|
|
55
|
+
not user_cwd.exists()
|
|
56
|
+
or
|
|
57
|
+
# Check if it's a temporary npx directory (common MCP issue)
|
|
58
|
+
"_npx" in str(user_cwd)
|
|
59
|
+
or ".npm" in str(user_cwd)
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
if is_problematic:
|
|
63
|
+
print(
|
|
64
|
+
f"WARNING:Working directory appears problematic: {user_cwd}\n"
|
|
65
|
+
f" Changing to project root: {PROJECT_ROOT}\n"
|
|
66
|
+
f" (This ensures file operations work correctly)",
|
|
67
|
+
file=sys.stderr,
|
|
68
|
+
)
|
|
69
|
+
os.chdir(PROJECT_ROOT)
|
|
70
|
+
else:
|
|
71
|
+
print(
|
|
72
|
+
f"Using configured working directory: {user_cwd}\n"
|
|
73
|
+
f" (Project root: {PROJECT_ROOT})",
|
|
74
|
+
file=sys.stderr,
|
|
75
|
+
)
|
|
76
|
+
# Keep user's configured cwd - don't change it!
|
|
77
|
+
|
|
78
|
+
from .server import mcp # noqa: E402
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
@click.group()
|
|
82
|
+
def cli():
|
|
83
|
+
"""ChatSpatial - AI-powered spatial transcriptomics analysis"""
|
|
84
|
+
pass
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
@cli.command()
|
|
88
|
+
@click.option("--port", default=8000, help="Port to listen on for SSE transport")
|
|
89
|
+
@click.option(
|
|
90
|
+
"--transport",
|
|
91
|
+
type=click.Choice(["stdio", "sse"]),
|
|
92
|
+
default="stdio",
|
|
93
|
+
help="Transport type (stdio or sse)",
|
|
94
|
+
)
|
|
95
|
+
@click.option(
|
|
96
|
+
"--host",
|
|
97
|
+
default="127.0.0.1", # nosec B104 - Default to localhost for security
|
|
98
|
+
help="Host to bind to for SSE transport",
|
|
99
|
+
)
|
|
100
|
+
@click.option(
|
|
101
|
+
"--log-level",
|
|
102
|
+
type=click.Choice(["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"]),
|
|
103
|
+
default="INFO",
|
|
104
|
+
help="Logging level",
|
|
105
|
+
)
|
|
106
|
+
def server(port: int, transport: str, host: str, log_level: str):
|
|
107
|
+
"""Start the ChatSpatial server.
|
|
108
|
+
|
|
109
|
+
This command starts the ChatSpatial server using either stdio or SSE transport.
|
|
110
|
+
For stdio transport, the server communicates through standard input/output.
|
|
111
|
+
For SSE transport, the server starts an HTTP server on the specified host and port.
|
|
112
|
+
"""
|
|
113
|
+
try:
|
|
114
|
+
# Configure server settings
|
|
115
|
+
print(
|
|
116
|
+
f"Starting ChatSpatial server with {transport} transport...",
|
|
117
|
+
file=sys.stderr,
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
# Set server settings
|
|
121
|
+
mcp.settings.host = host
|
|
122
|
+
mcp.settings.port = port
|
|
123
|
+
mcp.settings.log_level = log_level
|
|
124
|
+
|
|
125
|
+
# Run the server with the specified transport
|
|
126
|
+
# This is the recommended way to run a FastMCP server
|
|
127
|
+
mcp.run(transport=transport)
|
|
128
|
+
|
|
129
|
+
except Exception as e:
|
|
130
|
+
print(f"Error starting MCP server: {str(e)}", file=sys.stderr)
|
|
131
|
+
traceback.print_exc(file=sys.stderr)
|
|
132
|
+
sys.exit(1)
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
def main():
|
|
136
|
+
"""Main entry point for ChatSpatial CLI"""
|
|
137
|
+
cli()
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
if __name__ == "__main__":
|
|
141
|
+
main()
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Configuration module for ChatSpatial
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import os
|
|
6
|
+
import warnings
|
|
7
|
+
|
|
8
|
+
# Configure Dask to use new DataFrame implementation
|
|
9
|
+
os.environ.setdefault("DASK_DATAFRAME__QUERY_PLANNING", "True")
|
|
10
|
+
|
|
11
|
+
# Try to import and configure dask
|
|
12
|
+
try:
|
|
13
|
+
import dask
|
|
14
|
+
|
|
15
|
+
dask.config.set({"dataframe.query-planning": True})
|
|
16
|
+
except ImportError:
|
|
17
|
+
pass # Dask not installed
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
# Suppress specific warnings
|
|
21
|
+
def configure_warnings():
|
|
22
|
+
"""Configure warning filters for known issues"""
|
|
23
|
+
# Suppress dask legacy dataframe warning
|
|
24
|
+
warnings.filterwarnings(
|
|
25
|
+
"ignore",
|
|
26
|
+
message="The legacy Dask DataFrame implementation is deprecated",
|
|
27
|
+
category=FutureWarning,
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
# Suppress spatialdata functools.partial warnings
|
|
31
|
+
warnings.filterwarnings(
|
|
32
|
+
"ignore",
|
|
33
|
+
message="functools.partial will be a method descriptor",
|
|
34
|
+
category=FutureWarning,
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
# Suppress numba nopython warning
|
|
38
|
+
warnings.filterwarnings(
|
|
39
|
+
"ignore",
|
|
40
|
+
message="nopython is set for njit and is ignored",
|
|
41
|
+
category=RuntimeWarning,
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
# Suppress anndata read_text warning
|
|
45
|
+
warnings.filterwarnings(
|
|
46
|
+
"ignore",
|
|
47
|
+
message="Importing read_text from `anndata` is deprecated",
|
|
48
|
+
category=FutureWarning,
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
# Configure on import
|
|
53
|
+
configure_warnings()
|