agentleFS
cafferychen777cafferychen777/ChatSpatial/.agents/skills/troubleshoot/SKILL.md

troubleshoot

Skill45 starsChanged 3 months agoMITView on GitHub

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".

  • Installs packages

27 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use ecosystem-reference, fractal-delegation and 10 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • naman10parikhSkill

    ecosystem-reference

    Quick-access directory of Claude Code ecosystem repos, skills, plugins, MCPs, and patterns. Use when improving the harness.

    Also in 5 projects that use this

  • naman10parikhSkill

    fractal-delegation

    Also in 5 projects that use this

  • MicrosoftSkill

    act-on-feedback

    Act on user feedback attached to the current session. Use when the user submits feedback on the session's changes via the Submit Feedback button.

    Also in 3 projects that use this

  • MicrosoftSkill

    generate-run-commands

    Generate or modify run commands for the current session. Use when the user wants to set up or update run commands that appear in the session's Run button.

    Also in 3 projects that use this

  • KirchliveSkill

    skill-routing

    Decides which of the installed skills a task needs and loads them before the work starts. This skill should be used at the beginning of any multi-step task — build, fix, refactor, migrate, review, plan, release, research, write, design, video — and again at every phase change, after context compaction, and when work moves into a different part of the codebase. Use it for requests like "let's build X", "fix this bug", "refactor Y", "plan the migration", "review this", and also when the user asks which skill applies, why a skill did not fire, or asks to check what is available.

    Also in 5 projects that use this

  • sublimotionSkill

    agent-runtime

    Launch and manage detached agent runs on EKS via the agent-runner CLI. Use when the user says "launch an agent run", "agent runtime", "agent-runner", "run this spec on the cluster", "check run status", "agent run logs", or "stop a run". Do NOT use for writing the agent-runner code itself (edit the sibling ../agent-runner repo), Terraform of the foundation (use terraform-automation), or GPU serving deployments (use infra-deployer).

    Also in 5 projects that use this

  • +6 more from naman10parikh

The file

We split this skill into the rules it gives an agent

6 rules. 0 are common, 5 are distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 22 edited versions we read keep these.

  • 5

    Distinctive

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Check for batch effects

    line 103
  2. Distinctive:

    All spots have same composition

    line 108
  3. Distinctive:

    Verify cell type annotations are correct

    line 126
  4. Distinctive:

    Check species setting matches data

    line 127
  5. Very specific:

    Use CPU fallback: use_gpu=False

    line 228
  6. Distinctive:

    When reporting issues, include:

    line 269

“Common” is measured: kept by at least 6 in 10 of the 22 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Troubleshooting Guide

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]}")

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.