Reference Documentation

Comprehensive reference materials for ChatSpatial users and developers.

Table of contents

  1. Quick References
    1. πŸ“‹ Quick Reference Guides
    2. πŸ”§ API Documentation
    3. πŸ“Š Data and Configuration
    4. πŸ› οΈ Troubleshooting
  2. Analysis Methods Reference
    1. Core Analysis Tools
    2. Advanced Analysis Tools
    3. Integration and Utilities
  3. Data Format Specifications
    1. Supported Input Formats
      1. H5AD (AnnData) - Recommended
      2. 10X Visium Format
      3. H5 (HDF5) Format
    2. Output Formats
      1. Analysis Results
      2. Metadata Structure
  4. Method Parameters Reference
    1. Spatial Domain Identification
      1. SpaGCN Parameters
      2. STAGATE Parameters
    2. Cell Communication Analysis
      1. LIANA Parameters
      2. CellPhoneDB Parameters
    3. Trajectory Analysis
      1. CellRank Parameters
  5. Error Codes Reference
    1. Common Error Types
    2. Method-Specific Errors
  6. Performance Guidelines
    1. Memory Requirements
    2. Processing Time Estimates
    3. Optimization Tips
  7. Version Compatibility
    1. Python Version Support
    2. Key Dependencies

This section provides detailed reference information for all aspects of ChatSpatial, from API documentation to troubleshooting guides.

Quick References

πŸ“‹ Quick Reference Guides

Essential information at your fingertips:

πŸ”§ API Documentation

Technical documentation for developers:

πŸ“Š Data and Configuration

Format specifications and setup guides:

πŸ› οΈ Troubleshooting

Problem-solving resources:

Analysis Methods Reference

Core Analysis Tools

ToolDescriptionKey Parameters
load_dataLoad spatial transcriptomics datadata_path, data_type
preprocess_dataQuality control and normalizationnormalization_method, n_top_genes
visualize_dataCreate spatial visualizationsplot_type, feature, colormap
annotate_cell_typesCell type annotationmethod, reference_data_id
analyze_spatial_dataSpatial pattern analysisanalysis_type, n_neighbors

Advanced Analysis Tools

ToolDescriptionRequirements
identify_spatial_domainsSpatial domain identificationSpaGCN, STAGATE, Leiden/Louvain
analyze_cell_communicationCell-cell interaction analysisLIANA or CellPhoneDB
analyze_trajectory_dataRNA velocity and pseudotimeCellRank or Palantir
deconvolve_dataSpatial deconvolutionCell2location or RCTD
find_spatial_genesSpatially variable genesSPARK-X or SpatialDE

Integration and Utilities

ToolDescriptionUse Cases
integrate_samplesMulti-sample integrationBatch effect correction
register_spatial_dataSpatial alignmentMulti-section studies
analyze_enrichmentPathway enrichmentFunctional interpretation
find_markersDifferential expressionCluster characterization

Data Format Specifications

Supported Input Formats

# Expected structure
adata.X              # Gene expression matrix (cells x genes)
adata.obs            # Cell metadata
adata.var            # Gene metadata  
adata.obsm['spatial'] # Spatial coordinates (cells x 2)
adata.uns            # Unstructured metadata

10X Visium Format

sample_folder/
β”œβ”€β”€ filtered_feature_bc_matrix.h5
└── spatial/
    β”œβ”€β”€ tissue_positions_list.csv
    β”œβ”€β”€ scalefactors_json.json
    β”œβ”€β”€ tissue_hires_image.png
    └── tissue_lowres_image.png

H5 (HDF5) Format

# Gene expression matrix
/matrix/             # Sparse matrix data
/matrix/barcodes     # Cell barcodes
/matrix/features     # Gene information

Output Formats

Analysis Results

  • Tabular data: CSV files with statistics and annotations
  • Visualizations: PNG/PDF plots and interactive HTML
  • Processed data: H5AD files with analysis results

Metadata Structure

# Analysis metadata stored in adata.uns
adata.uns['spatial_domains']    # Domain assignments
adata.uns['cell_communication'] # Interaction results  
adata.uns['trajectory']         # Pseudotime results
adata.uns['deconvolution']      # Cell type proportions

Method Parameters Reference

Spatial Domain Identification

SpaGCN Parameters

params = {
    "method": "spagcn",
    "n_domains": 7,           # Number of domains
    "spagcn_p": 0.5,         # Smoothing parameter
    "spagcn_s": 1,           # Scaling factor
    "spagcn_b": 49,          # Bandwidth
    "resolution": 0.5        # Clustering resolution
}

STAGATE Parameters

params = {
    "method": "stagate", 
    "stagate_epochs": 1000,      # Training epochs
    "stagate_learning_rate": 0.001, # Learning rate
    "stagate_dim_output": 512,   # Output dimensions
    "n_domains": 7               # Target domains
}

Cell Communication Analysis

LIANA Parameters

params = {
    "method": "liana",
    "liana_resource": "consensus",    # Database
    "liana_local_metric": "cosine",   # Local metric
    "liana_global_metric": "morans",  # Global metric
    "perform_spatial_analysis": True
}

CellPhoneDB Parameters

params = {
    "method": "cellphonedb",
    "cellphonedb_iterations": 1000,     # Permutations
    "cellphonedb_pvalue": 0.05,         # P-value threshold
    "cellphonedb_use_microenvironments": True
}

Trajectory Analysis

CellRank Parameters

params = {
    "method": "cellrank",
    "cellrank_n_states": 5,              # Terminal states
    "cellrank_kernel_weights": [0.8, 0.2], # Velocity/connectivity weights
    "spatial_weight": 0.5                 # Spatial constraint
}

Error Codes Reference

Common Error Types

Error CodeDescriptionSolution
DATA_LOAD_ERRORFailed to load dataCheck file path and format
MISSING_SPATIALNo spatial coordinatesEnsure spatial coordinates in obsm[β€˜spatial’]
DEPENDENCY_ERRORMissing required packageInstall missing dependencies
MEMORY_ERRORInsufficient memoryReduce dataset size or increase memory
PARAMETER_ERRORInvalid parametersCheck parameter types and ranges

Method-Specific Errors

MethodErrorCauseSolution
SpaGCNHISTOLOGY_ERRORMissing histology imageProvide tissue image or disable histology
Cell2locationGPU_ERRORCUDA issuesUse CPU or fix GPU setup
RCTDR_ERRORR/rpy2 problemsCheck R installation
LIANADATABASE_ERRORMissing interaction databaseInstall LIANA databases

Performance Guidelines

Memory Requirements

Dataset SizeMinimalAdvancedExperimental
< 5K cells2GB RAM4GB RAM8GB RAM
5K-20K cells4GB RAM8GB RAM16GB RAM
20K-100K cells8GB RAM16GB RAM32GB RAM
> 100K cells16GB RAM32GB RAM64GB RAM

Processing Time Estimates

Analysis TypeSmall DatasetLarge Dataset
Basic preprocessing< 1 min5-15 min
Spatial domains (SpaGCN)2-5 min15-30 min
Cell communication5-10 min30-60 min
Trajectory analysis10-20 min1-2 hours
Deep learning methods15-30 min2-4 hours

Optimization Tips

  1. Use appropriate data types - Sparse matrices for large datasets
  2. Chunk processing - Process data in batches for memory efficiency
  3. GPU acceleration - Use CUDA for compatible methods
  4. Parallel processing - Set n_jobs parameter for multi-core usage

Version Compatibility

Python Version Support

Python VersionMinimalAdvancedExperimental
3.10βœ…βœ…βœ…
3.11βœ…βœ…βœ…
3.12βœ…βœ…βš οΈ

Key Dependencies

PackageMinimal VersionRecommendedNotes
scanpy1.9.0+1.10.0+Core single-cell analysis
squidpy1.2.0+1.4.0+Spatial analysis tools
torch2.0.0+2.1.0+Deep learning (advanced)
scvi-tools1.0.0+1.1.0+Variational inference

Need help finding something? Try the search function or browse the troubleshooting guides.


Table of contents