ChatSpatial Troubleshooting Guide
Welcome to the ChatSpatial troubleshooting guide! This comprehensive resource will help you resolve common issues and get back to analyzing spatial transcriptomics data quickly.
Quick Problem Finder
Having issues right now? Jump to the relevant section:
- 🚀 Installation Problems
- 💾 Memory and Performance
- 🔬 Analysis Not Working
- 🔗 Cell Communication Errors
- 📁 Data Loading Issues
- ⚠️ Error Messages
- 💬 Agent Conversation Issues
Installation and Dependency Issues
Python Environment Problems
Problem: ImportError or ModuleNotFoundError
Common error messages:
ImportError: No module named 'chatspatial'
ModuleNotFoundError: No module named 'scanpy'
ImportError: cannot import name 'X' from 'Y'
Step-by-step solution:
- Check your environment:
which python python --version # Should be 3.10+ (required for MCP) - Verify ChatSpatial installation:
pip list | grep chatspatial # OR python -c "import chatspatial; print('SUCCESS')" - Check dependency status:
pip list | grep -E "(numpy|pandas|scanpy|squidpy)" # Or check if advanced features are available python -c "import scvi; print('Advanced features OK')" 2>/dev/null || echo "Advanced features not installed" - Reinstall if needed:
pip uninstall chatspatial pip cache purge pip install -e ".[advanced]" # For full features
💡 Prevention Tips:
- Always use conda environments:
conda create -n chatspatial python=3.10- Install with dependency groups:
pip install -e ".[advanced]"for most users- Regularly update:
pip install --upgrade -e ".[advanced]"
Problem: Conda vs Pip Conflicts
Common symptoms:
- Package versions don’t match requirements
- Mix of conda and pip installations causing conflicts
pip checkshows dependency conflicts
Solution:
- Create clean environment:
conda create -n chatspatial-clean python=3.10 conda activate chatspatial-clean - Install core scientific packages with conda:
conda install numpy pandas scipy scikit-learn matplotlib seaborn conda install -c conda-forge scanpy anndata - Install ChatSpatial with pip:
pip install -e ".[advanced]"
💡 Prevention Tip: Stick to one package manager per environment when possible.
R Dependencies (for Advanced Features)
Problem: rpy2 Installation Fails
Error messages:
ERROR: Failed building wheel for rpy2
fatal error: 'R.h' file not found
Solution:
- Install R first:
# macOS brew install r # Ubuntu/Debian sudo apt install r-base r-base-dev # Windows (use WSL or R installer) - Set R environment variables:
export R_HOME=$(R RHOME) export R_USER=$(whoami) - Install rpy2:
pip install rpy2>=3.4.0
💡 Prevention Tip: Only install R dependencies if you need RCTD deconvolution.
macOS Library Loading Issues
Problem: llvmlite/numba libc++.1.dylib Not Found (Apple Silicon)
Error messages:
OSError: dlopen(libllvmlite.dylib): Library not loaded: @rpath/libc++.1.dylib
Referenced from: .../llvmlite/binding/libllvmlite.dylib
Reason: tried: '/opt/homebrew/lib/libc++.1.dylib' (no such file)
Common symptoms:
- Squidpy neighborhood analysis fails with multiprocessing error
- Numba works in main process but fails in subprocesses
- Any parallel computation using numba crashes
Solution 1: Fix Library Links (Recommended for quick fix)
# Find the exact llvmlite location
find ~/your_env -name "libllvmlite.dylib"
# Fix the library references (requires sudo)
sudo install_name_tool -change "@rpath/libc++.1.dylib" "/usr/lib/libc++.1.dylib" /path/to/llvmlite/binding/libllvmlite.dylib
sudo install_name_tool -change "@rpath/libz.1.dylib" "/usr/lib/libz.1.dylib" /path/to/llvmlite/binding/libllvmlite.dylib
# Verify the fix
otool -L /path/to/llvmlite/binding/libllvmlite.dylib | head -5
# Should show /usr/lib/ paths instead of @rpath
Solution 2: Use Conda/Miniforge (Recommended for long-term)
# Install Miniforge for Apple Silicon
wget https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-MacOSX-arm64.sh
bash Miniforge3-MacOSX-arm64.sh
# Create new environment
conda create -n spatial python=3.10
conda activate spatial
# Install from conda-forge
conda install -c conda-forge numba llvmlite squidpy
Solution 3: Temporary Workaround
# Set library path before running
export DYLD_LIBRARY_PATH=/usr/lib:$DYLD_LIBRARY_PATH
# Or use single-threaded mode in squidpy
# Pass n_jobs=1 to neighborhood analysis functions
💡 Prevention Tips:
- On Apple Silicon Macs, prefer conda/miniforge over pip for scientific packages
- Use ARM64-native conda distributions
- Avoid mixing x86_64 and ARM64 packages
⚠️ Impact: This issue affects all squidpy spatial analysis functions that use parallel processing (neighborhood enrichment, co-occurrence analysis, etc.)
MCP Connection Issues
Problem: MCP Server Won’t Start
Error messages:
Failed to start MCP server
Connection refused
Server process exited with code 1
Step-by-step diagnosis:
- Test server manually:
python -m chatspatial --help # Should show help message without errors - Check Python path in MCP config:
which python # Copy this EXACT path to your MCP configuration - Verify MCP configuration format:
{ "mcpServers": { "chatspatial": { "command": "/full/path/to/python", "args": ["-m", "chatspatial"], "env": {} } } } - Test with MCP Inspector:
npx @modelcontextprotocol/inspector python -m chatspatial
⚠️ When to Seek Help: If MCP Inspector also fails, report the exact error message.
Memory and Performance Problems
Large Dataset Handling
Problem: Out of Memory Errors
Error messages:
MemoryError: Unable to allocate X GB
RuntimeError: CUDA out of memory
Process killed (signal 9)
Immediate solutions:
- Check available memory:
import psutil print(f"Available RAM: {psutil.virtual_memory().available / (1024**3):.1f} GB") - Subsample your data:
# Keep every 10th cell for initial exploration adata_subset = adata[::10].copy() # Or randomly sample import numpy as np n_sample = 5000 indices = np.random.choice(adata.n_obs, n_sample, replace=False) adata_subset = adata[indices].copy() - Use sparse matrices:
import scipy.sparse as sp if not sp.issparse(adata.X): adata.X = sp.csr_matrix(adata.X) - Process in chunks:
"Process my dataset in batches of 1000 cells" "Run analysis on spatial domains separately"
🔧 Long-term Strategies:
- Increase swap space (Linux/macOS): Add virtual memory
- Use high-memory nodes on computing clusters
- Consider cloud computing with more RAM (32GB+ for large datasets)
Problem: Slow Performance
Symptoms:
- Analysis takes hours instead of minutes
- LLM agent times out
- Progress bars move very slowly
Optimization strategies:
- Use Cherry Studio instead of Claude Desktop:
- Configure timeout to 3600 seconds
- Better for computationally intensive tasks
- More stable for long-running processes
- Enable multi-threading:
import scanpy as sc sc.settings.n_jobs = 4 # Adjust based on your CPU cores - Optimize specific methods:
"Use Leiden clustering for fastest spatial domain identification" "Use SPARK-X for faster spatial gene detection on large datasets" "Use basic visualization instead of interactive plots"
💡 Prevention Tips:
- Start with small subsets for method testing
- Use progress monitoring: “Show progress updates every 100 cells”
- Monitor system resources during analysis
GPU-Related Issues
Problem: CUDA/GPU Not Available
Error messages:
RuntimeError: No CUDA GPUs are available
torch.cuda.is_available() returns False
Solutions:
- Check GPU setup:
nvidia-smi # Should show GPU information python -c "import torch; print(torch.cuda.is_available())" - Install CUDA-compatible PyTorch:
pip install torch>=2.0.0 --index-url https://download.pytorch.org/whl/cu118 - Fall back to CPU:
"Use CPU-only mode for analysis" "Disable GPU acceleration for this analysis"
ℹ️ When GPU Isn’t Needed: Most ChatSpatial analyses work fine on CPU. Only deep learning methods (Cell2location, scVI) benefit significantly from GPU.
Analysis-Specific Issues
Clustering and Spatial Domains
Problem: No Clusters Found or Too Many Clusters
Symptoms:
- All cells assigned to one cluster
- Hundreds of tiny clusters
- Spatial domains don’t make biological sense
Diagnostic approach:
"Show me the clustering parameters used"
"Visualize quality control metrics"
"Check if data needs better preprocessing"
Solutions:
- Adjust resolution parameters:
"Try Leiden clustering with resolution 0.5" "Use SpaGCN with higher alpha parameter" "Increase k for STAGATE spatial domains" - Improve preprocessing:
"Filter genes present in at least 10 cells" "Remove cells with very low gene counts" "Apply log normalization before clustering" - Try different methods:
"Compare SpaGCN vs STAGATE results" "Try Leiden instead of Louvain clustering"
Problem: Cell Type Annotation Fails
Error messages:
No significant markers found
Reference dataset incompatible
Annotation method failed
Step-by-step troubleshooting:
- Check marker genes:
"Show available marker genes for my tissue type" "List genes present in my dataset" "Use mouse markers instead of human" - Try different annotation methods:
"Try scType instead of marker-based annotation" "Use Tangram with reference data" "Try CellAssign with custom markers" - Verify data compatibility:
"Check if gene symbols match reference data" "Convert gene names to match annotation database"
Visualization Problems
Problem: Plots Not Showing or Corrupted
Error messages:
Image could not be displayed
Visualization failed
Empty plot generated
Solutions:
- Check data availability:
"Show me data summary before plotting" "Check if spatial coordinates exist" "Verify embedding was computed" - Simplify visualization:
"Create basic scatter plot instead of complex visualization" "Use default parameters for plotting" "Show first 1000 cells only" - Try alternative plot types:
"Create violin plot instead of spatial plot" "Use heatmap instead of UMAP" "Generate summary statistics table"
💡 Prevention Tip: Always start with simple plots before creating complex visualizations.
Cell Communication Analysis
Problem: CellPhoneDB KeyError with Complex Names
Error messages:
KeyError: 'ICAM3_integrin_aDb2_complex'
KeyError: 'GP1BA_integrin_aMb2_complex'
KeyError: 'BMP8A_ACVR_1A2B_receptor'
Known Issue: CellPhoneDB v5.0.1 has database inconsistencies with certain protein complexes.
Solutions:
- Use LIANA instead (recommended):
"Use LIANA method for cell communication analysis" "Try LIANA with consensus database" "Use cell_type_handling='create_from_column' if needed" - Enable gene filtering (partial fix):
"Enable gene filtering with moderate strategy" "Use cellphonedb_use_microenvironments=true with filtering" - Workarounds:
- Remove problematic genes manually (ICAM3, ITGAD, GP1BA, BMP8A)
- Use older CellPhoneDB version (v4.x)
- Switch to alternative databases
⚠️ Note: This is a known bug in CellPhoneDB v5.0.1, not a ChatSpatial issue. The development team is aware of these database inconsistencies.
Problem: CellPhoneDB ‘significant_means’ KeyError
Error message:
KeyError: 'significant_means'
Causes:
- Insufficient ligand-receptor gene coverage
- Species mismatch (mouse genes vs human database)
- Dataset too sparse (< 5000 genes)
Solutions:
- Check gene coverage:
"Check how many L-R genes are in my dataset" "Use data_source='raw' for more genes" - Species issues:
"Ensure species parameter matches your data" "Convert mouse gene names to human format if needed" - Use alternatives:
"Try LIANA which handles sparse data better" "Use CellChat via LIANA for mouse data"
RNA Velocity and Trajectory Analysis
Problem: Velocity Analysis Fails
Error messages:
Missing spliced/unspliced layers
Velocity vectors could not be computed
Insufficient velocity genes
Solutions:
- Check velocity data:
"Show me what layers are available in my data" "Check if RNA velocity preprocessing was done" "Verify spliced and unspliced counts exist" - Use alternative approaches:
"Try pseudotime analysis with Palantir instead" "Use DPT for trajectory inference" "Focus on spatial patterns without velocity"
Data Format and Loading Problems
Path Issues (Most Common!)
Problem: File Not Found - Wrong Path Type
⚠️ CRITICAL REQUIREMENT: ChatSpatial’s MCP server requires absolute paths. Relative paths will always fail!
Error messages:
File not found
FileNotFoundError: [Errno 2] No such file or directory: 'data.h5ad'
Cannot locate file: ./folder/data.h5ad
Most common mistake:
❌ Wrong: "Load data.h5ad"
❌ Wrong: "Load ./Downloads/data.h5ad"
❌ Wrong: "Load ~/Downloads/data.h5ad"
✅ Correct: "Load /Users/yourname/Downloads/data.h5ad"
Quick fix:
- Find the absolute path:
cd /your/download/folder pwd # Shows: /Users/yourname/Downloads ls *.h5ad # Shows: card_spatial.h5ad - Use in ChatSpatial:
"Load /Users/yourname/Downloads/card_spatial.h5ad"
File Format Issues
Problem: Data Won’t Load
Error messages:
Unsupported file format
Corrupted data file
KeyError: spatial coordinates not found
File format checklist:
- Verify file exists and is accessible:
ls -la /Users/yourname/Downloads/data.h5ad file /Users/yourname/Downloads/data.h5ad # Check file type Check file format support:
Supported formats:
.h5ad(recommended).h5(10X format).mtx + .tsv(Matrix Market).csv/.tsv(text files).xlsx(Excel, limited)
- Test with ChatSpatial (remember: absolute paths only!):
"Load data from /Users/yourname/Downloads/card_spatial.h5ad" "Check what file formats are supported" "Try loading with different format options"
Problem: Missing Spatial Information
Error messages:
No spatial coordinates found
KeyError: 'spatial'
Spatial analysis requires coordinates
Solutions:
- Check for spatial data:
"Show me what's available in adata.obsm" "List all coordinate systems in the data" "Check if X_spatial or spatial key exists" - Load coordinates separately:
"Load coordinates from tissue_positions_list.csv" "Add spatial coordinates from separate file" "Use pixel coordinates as spatial data" - Use non-spatial analysis:
"Perform standard single-cell analysis instead" "Focus on cell type identification without spatial context"
10X Visium Specific Issues
Problem: Spatial Folder Structure Missing
Expected structure:
project/
├── filtered_feature_bc_matrix.h5
└── spatial/
├── tissue_positions_list.csv
├── scalefactors_json.json
├── tissue_hires_image.png
└── tissue_lowres_image.png
Solutions:
- Check folder structure:
find /path/to/data -name "*.csv" -o -name "*.json" -o -name "*.png" - Load components separately:
"Load count matrix from filtered_feature_bc_matrix.h5" "Add spatial coordinates from tissue_positions_list.csv" "Include image data from spatial folder"
Common Error Messages with Solutions
“Dataset not found in data store”
Meaning: ChatSpatial can’t find your loaded dataset.
Solutions:
"Show me what datasets are currently loaded""Load my data again from /full/path""List available datasets in memory"
“Missing required dependencies”
Meaning: Optional package needed for specific analysis is not installed.
Solutions:
- Check what’s needed:
pip list | grep -E "(chatspatial|numpy|pandas|scanpy|squidpy)" - Install missing package:
pip install package_name - Use alternative method:
"Try different method that doesn't require X"
“Memory allocation failed”
Meaning: Not enough RAM for the analysis.
Quick fixes:
"Subsample data to 5000 cells""Use sparse matrices""Process data in smaller chunks"
“CUDA out of memory”
Meaning: GPU doesn’t have enough memory.
Solutions:
"Use CPU instead of GPU""Reduce batch size for deep learning""Free GPU memory before analysis"
“No significant results found”
Meaning: Statistical analysis didn’t find meaningful patterns.
Troubleshooting:
"Check data quality metrics""Try less stringent parameters""Use different statistical method"
“Visualization failed to render”
Meaning: Plot generation encountered an error.
Solutions:
"Create simple scatter plot first""Check if data has required information""Use basic plotting parameters"
Conversation Troubleshooting
Agent Doesn’t Understand Your Request
Problem: Generic or Unhelpful Responses
Symptoms:
- Agent suggests irrelevant analyses
- Asks for clarification on clear requests
- Provides generic instead of specific help
Better communication strategies:
- Be specific about your data:
❌ "Analyze my data" ✅ "Load 10X Visium data from /path/data.h5ad and identify spatial domains using SpaGCN" - Specify the biological context:
❌ "Find cell types" ✅ "Annotate cell types in mouse brain tissue using known cortical markers" - Include parameters when needed:
❌ "Do clustering" ✅ "Perform Leiden clustering with resolution 0.8 and visualize on UMAP"
Problem: Agent Suggests Wrong Analysis Method
Common mix-ups:
- Suggests single-cell methods for spatial data
- Recommends incompatible analysis combinations
- Proposes computationally expensive methods unnecessarily
Clarification approaches:
"I have spatial transcriptomics data, not single-cell RNA-seq"
"My dataset is large (50K cells), suggest fast methods"
"Focus on spatial-specific analyses only"
"I need methods compatible with Visium data"
Parameter and Method Issues
Problem: Agent Chooses Inappropriate Parameters
Symptoms:
- Analysis fails due to incompatible settings
- Results don’t make biological sense
- Methods take too long to complete
Parameter guidance strategies:
"Use standard parameters for mouse brain Visium analysis"
"Choose parameters suitable for large datasets"
"Optimize for speed over precision"
"Use conservative statistical thresholds"
Problem: Method Compatibility Issues
Common conflicts:
- Trying to use methods requiring specific data types
- Combining incompatible analysis steps
- Using experimental methods with production data
Compatibility checking:
"Check if my data is compatible with Cell2location"
"What methods work best with my data type?"
"Suggest analysis pipeline for 10X Visium data"
"List methods that work without GPU"
Progress and Status Monitoring
Problem: Long Analysis with No Updates
Solutions:
- Request progress updates:
"Show progress updates every minute" "Report when each analysis step completes" "Provide estimated time remaining" - Use Cherry Studio for better monitoring:
- Set timeout to 3600 seconds
- Better progress reporting
- Can handle interruptions gracefully
- Break into smaller steps:
"First load and preprocess data, then tell me when ready" "Do quality control first, then we'll proceed with analysis"
When to Seek Help
Gather Information First
Before seeking help, collect this information:
- System details:
python --version pip list | grep chatspatial uname -a # Linux/macOS - Error details:
- Full error message
- What you were trying to do
- Steps that led to the error
- Data information:
- File format and size
- Data source (10X, Slide-seq, etc.)
- Any preprocessing done
Where to Get Help
- GitHub Issues: For bugs and feature requests
- Include system info and error messages
- Provide minimal reproducible example
- Check existing issues first
- Community Forums: For usage questions
- Describe your biological question
- Include what you’ve already tried
- Share relevant code snippets
- Documentation: For method-specific help
- Check tutorial sections
- Review API documentation
- Look at example workflows
Emergency Workarounds
When you need results quickly:
- Use minimal installation:
pip install -e .for basic features - Process small subsets: Test with 1000 cells first
- Use simple methods: Basic clustering and visualization
- Try different LLM client: Cherry Studio vs Claude Desktop
- Run analysis step-by-step: Break complex workflows into pieces
📝 Remember: ChatSpatial is designed to be robust and provide helpful error messages. Most issues can be resolved by following the specific guidance above or trying alternative approaches suggested by the LLM agent.
Quick Reference Card
Installation Commands
# Basic installation
pip install -e .
# Advanced features
pip install -e ".[advanced]"
# Check dependencies
pip list | grep -E "(chatspatial|numpy|pandas|scanpy|squidpy)"
# Test MCP server
python -m chatspatial --help
npx @modelcontextprotocol/inspector python -m chatspatial
Common Agent Requests
# Data loading
"Load 10X Visium data from /full/path/to/data.h5ad"
# Quick analysis
"Preprocess data with standard QC, then identify spatial domains"
# Troubleshooting
"Show me data summary and available analysis options"
"Check system resources and suggest optimization"
# Method alternatives
"Suggest fast methods for large dataset analysis"
"What methods work without GPU?"
This troubleshooting guide covers the most common issues you’ll encounter with ChatSpatial. Keep it bookmarked for quick reference during your spatial transcriptomics analyses!