Troubleshooting Guide

SkillDev tools

Diagnose and resolve common issues in spatial transcriptomics analysis. Use when analysis fails, produces unexpected results, or user encounters errors. Triggers: "error", "failed", "not working", "issue", "problem", "help", "unexpected result", "debug", "fix", "wrong output".

Available today. Use it from your connected AI after setup.

Connect ahel once, and every AI you use reads what you have installed.

Then ask your AI: use the Troubleshooting Guide skill

What this skill tells your AI

The instructions your AI receives, as published by cafferychen777/chatspatial in .agents/skills/troubleshoot/SKILL.md and read by ahel’s review.

Overview

This skill helps diagnose and resolve common issues in ChatSpatial analysis.

Quick Diagnosis Tree

Q: What type of problem?
│
├─ Analysis fails with error
│   └─ See: Error Messages section
│
├─ Analysis runs but results look wrong
│   └─ See: Result Validation section
│
├─ Performance issues (slow/memory)
│   └─ See: Performance section
│
└─ Dependency/installation problems
    └─ See: Environment section

Error Messages

Data Loading Errors

ErrorCauseSolution
FileNotFoundErrorPath incorrectVerify file path exists
KeyError: 'spatial'No spatial coordinatesCheck data format, use correct loader
ValueError: sparse matrixFormat mismatchConvert to compatible format
MemoryErrorFile too largeUse chunked loading or subsample

Diagnostic steps:

1. Verify file exists: ls -la <path>
2. Check file size: du -h <path>
3. Try reading header only to test format

Preprocessing Errors

ErrorCauseSolution
No highly variable genesFiltering too strictLower min_mean/max_mean thresholds
Negative values after logData not normalizedUse raw counts first
Empty AnnData after QCQC too strictRelax min_genes/min_cells

Method-Specific Errors

Deconvolution
ErrorCauseSolution
No shared genesReference mismatchCheck gene naming (symbols vs IDs)
RCTD failedR/rpy2 issueVerify R installation, check rpy2
Cell2location GPU errorCUDA issueUse CPU mode, check GPU availability
Reference cell types missingBad annotation columnVerify cell_type_key exists
Cell Communication
ErrorCauseSolution
CellChat R errorR dependencyInstall CellChat in R first
No interactions foundStringent filteringLower p-value threshold
Species database not foundWrong species configUse "human" or "mouse"
Trajectory/Velocity
ErrorCauseSolution
No spliced/unsplicedMissing layersProcess with velocyto first
Root cell not foundBad root specificationUse valid cell barcode or cluster
Disconnected graphPoor connectivityIncrease n_neighbors

Result Validation

Unexpected Clustering Results

Symptoms:

  • Too few/many clusters
  • Clusters don't match histology
  • Known cell types not separated

Solutions:

  1. Adjust resolution parameter (higher = more clusters)
  2. Try different clustering methods
  3. Verify preprocessing quality
  4. Check for batch effects

Poor Deconvolution Results

Symptoms:

  • All spots have same composition
  • Proportions don't sum to 1
  • Expected cell types missing

Diagnostic checklist:

  • Reference and spatial data normalized consistently?
  • Sufficient gene overlap (>2000 genes)?
  • Reference cell types well-defined?
  • Spatial data quality passed QC?

Meaningless Communication Results

Symptoms:

  • Random interactions without biological sense
  • Same interactions everywhere
  • Missing expected pathways

Solutions:

  1. Verify cell type annotations are correct
  2. Check species setting matches data
  3. Try different communication database
  4. Increase minimum expression threshold

Performance Issues

Memory Problems

Symptoms:

  • MemoryError
  • System becomes unresponsive
  • Kernel crashes

Solutions by data size:

Data SizeStrategy
<50k cellsShould work, check other processes
50k-100kClose other applications, increase swap
100k-500kUse chunked processing, subsample
>500kRequires HPC or cloud resources

Specific techniques:

1. Subsample for exploration:
   sc.pp.subsample(adata, n_obs=50000)

2. Use sparse matrices:
   adata.X = scipy.sparse.csr_matrix(adata.X)

3. Process in chunks:
   Use batch processing for large datasets

Slow Execution

Common causes and solutions:

BottleneckSolution
Neighbor computationReduce n_neighbors, use approximate methods
ClusteringUse faster method (leiden > louvain)
DeconvolutionUse FlashDeconv instead of Cell2location
VisualizationReduce point size, subsample for plotting

Environment Issues

Python Dependencies

Check installation:

python -c "import scanpy; print(scanpy.__version__)"
python -c "import squidpy; print(squidpy.__version__)"

Common fixes:

pip install --upgrade scanpy squidpy
pip install scvi-tools  # For deep learning methods

R Dependencies (rpy2)

Check R availability:

import rpy2.robjects as ro
print(ro.r('R.version.string'))

Install R packages:

# In R console
install.packages("Seurat")
BiocManager::install("RCTD")
devtools::install_github("sqjin/CellChat")

Common rpy2 issues:

1. R_HOME not set:
   export R_HOME=/path/to/R

2. Library path issues:
   Check .libPaths() in R

3. Version mismatch:
   Ensure rpy2 matches R version

GPU/CUDA Issues

Check GPU availability:

import torch
print(torch.cuda.is_available())
print(torch.cuda.device_count())

Common fixes:

  • Update CUDA drivers
  • Install correct torch version for CUDA
  • Use CPU fallback: use_gpu=False

Data Format Issues

AnnData Structure Problems

Verify structure:

print(adata)
print(adata.obs.columns.tolist())
print(adata.var.columns.tolist())
print(list(adata.obsm.keys()))
print(list(adata.layers.keys()))

Common fixes:

IssueSolution
Missing raw countsadata.raw = adata.copy() before normalization
Wrong X matrixCheck if log-transformed when needed
Missing obsm keysRe-run PCA/UMAP computation

Coordinate System Issues

Spatial coordinates check:

if 'spatial' in adata.obsm:
    print(adata.obsm['spatial'].shape)
    print(adata.obsm['spatial'][:5])

Common problems:

  • Coordinates in wrong units
  • Flipped/rotated coordinates
  • Missing spatial key

Getting Help

Information to Provide

When reporting issues, include:

  1. Error message: Full traceback
  2. Data description: n_cells, n_genes, platform
  3. Command used: Exact parameters
  4. Environment: Python version, package versions

Quick Diagnostic Commands

# Dataset summary
print(f"Cells: {adata.n_obs}, Genes: {adata.n_vars}")
print(f"Spatial: {'spatial' in adata.obsm}")
print(f"Layers: {list(adata.layers.keys())}")
print(f"Obs columns: {adata.obs.columns.tolist()[:10]}")

Signals

GitHub stars
44
Forks
13
Last commit
Aug 2026
Advanced
Catalog kind
skill
Gateway key
troubleshoot
Source
github.com/cafferychen777/chatspatial