| name | cellchat-pkg-local-complete |
| description | CellChat 包源码随附的本地教程 + Rd 转换的函数文档 + R 源码 HTML - 完整覆盖173个文件 |
CellChat-Pkg-Local-Complete Skill
Comprehensive assistance with CellChat package for cell-cell communication analysis, generated from official documentation and source code.
When to Use This Skill
This skill should be triggered when:
Data Preparation & Object Creation:
- Converting single-cell data from Seurat, SingleCellExperiment, or AnnData objects to CellChat
- Preparing normalized expression matrices and cell metadata for CellChat analysis
- Setting up CellChat objects from different data formats (count matrices, spatial data)
- Handling data input issues from Python/Scanpy or other single-cell tools
Cell-Cell Communication Analysis:
- Inferring ligand-receptor interactions and signaling pathways
- Computing communication probabilities and network analysis
- Analyzing spatially resolved cell-cell communication
- Performing comparative analysis across conditions or time points
Network Analysis & Visualization:
- Visualizing communication networks using hierarchy, circle, or chord diagrams
- Computing network centrality measures to identify key signaling players
- Creating spatial plots of communication on tissue sections
- Extracting and filtering specific communications of interest
Advanced Applications:
- Integrating custom ligand-receptor databases
- Analyzing contact-dependent signaling
- Projecting expression data onto protein-protein interaction networks
- Batch correction and multi-sample analysis
Troubleshooting & Optimization:
- Debugging issues with object creation or data conversion
- Optimizing parameters for communication inference
- Handling spatial transcriptomics data from different platforms
- Understanding and customizing analysis workflows
Quick Reference
Core Examples
Example 1: Create CellChat object from Seurat
library(CellChat)
cellchat <- createCellChat(object = seurat.obj, group.by = "ident", assay = "RNA")
Example 2: Create from expression matrix
cellchat <- createCellChat(object = data.input, meta = meta, group.by = "labels")
Example 3: Set up database and preprocess
cellchat@DB <- CellChatDB.human
cellchat <- subsetData(cellchat)
cellchat <- identifyOverExpressedGenes(cellchat)
cellchat <- identifyOverExpressedInteractions(cellchat)
Example 4: Infer communication network
cellchat <- computeCommunProb(cellchat)
cellchat <- computeCommunProbPathway(cellchat)
cellchat <- aggregateNet(cellchat)
Example 5: Extract communications
# All communications
df.net <- subsetCommunication(cellchat)
# Specific pathways
df.net <- subsetCommunication(cellchat, signaling = c("WNT", "TGFb"))
# Specific cell groups
df.net <- subsetCommunication(cellchat, sources.use = c(1,2), targets.use = c(4,5))
Example 6: Visualize signaling network
netVisual(cellchat, signaling = "TGFb", layout = "hierarchy")
Example 7: Network centrality analysis
cellchat <- netAnalysis_computeCentrality(cellchat, slot.name = "netP")
netAnalysis_signalingRole_network(cellchat, signaling = "TGFb")
Example 8: Spatial data setup
cellchat <- createCellChat(object = data.input, meta = meta, group.by = "labels",
coordinates = coordinates, spatial.factors = spatial.factors)
Example 9: Data conversion from AnnData
library(anndata)
ad <- read_h5ad("scanpy_object.h5ad")
counts <- t(as.matrix(ad$X))
library.size <- Matrix::colSums(counts)
data.input <- as(log1p(Matrix::t(Matrix::t(counts)/library.size) * 10000), "dgCMatrix")
meta <- ad$obs
Example 10: Rank signaling pathways
rankNet(cellchat, mode = "single", measure = "weight")
Key Concepts
Core CellChat Objects:
cellchat@data: Normalized expression datacellchat@meta: Cell metadata and group informationcellchat@net: Ligand-receptor level communication networkcellchat@netP: Pathway level communication networkcellchat@idents: Cell group identities
Data Requirements:
- Expression Matrix: Genes in rows, cells in columns, normalized data required
- Cell Metadata: Dataframe with cell labels and sample information
- Spatial Data: Coordinates and distance factors for spatial analysis
Communication Inference:
- Probability Calculation: Based on mass action law integrating expression and prior knowledge
- Permutation Testing: Statistical significance assessment
- Pathway Aggregation: Summarizing multiple L-R pairs per signaling pathway
Network Analysis Types:
- Functional Networks: Based on inferred communication probabilities
- Structural Networks: Based on ligand-receptor interaction structure
- Centrality Measures: Identifying key senders, receivers, mediators, influencers
Reference Files
This skill includes comprehensive documentation in references/:
api_functions.md (134 pages)
Complete API documentation for all CellChat functions:
subsetCommunication: Extract specific cell-cell communicationscomputeAveExpr: Calculate average expression per cell groupnetVisual_embedding: 2D visualization of signaling manifoldsrankNet: Rank signaling networks by information flownetAnalysis_computeCentrality: Network centrality analysiscomputeExpr_antagonist: Model antagonist effects
cpp_source.md (2 pages)
C++ source code for performance-critical operations:
ComputeSNN: Shared nearest neighbor computation- Rcpp bindings for high-performance calculations
r_source.md (10 pages)
R source code for core functionality:
visualization: Network visualization functions and themes- Color palettes and plotting utilities
- Core analysis algorithms
tutorials.md (27 pages)
Comprehensive tutorials covering:
- Spatial transcriptomics analysis: Complete workflow for spatial data
- Data preparation: From various single-cell formats
- Network inference: Step-by-step communication analysis
- Visualization: Multiple plotting options and customization
- Advanced applications: Custom databases and comparative analysis
Working with This Skill
For Beginners
- Start with Data Preparation: Use the tutorials to understand data input requirements
- Basic Workflow: Follow the spatial transcriptomics tutorial for a complete example
- Simple Visualizations: Begin with circle plots and hierarchy diagrams
- Reference Functions: Use api_functions.md for detailed parameter explanations
For Intermediate Users
- Custom Analyses: Explore different
typeparameters incomputeAveExpr - Advanced Visualizations: Try chord diagrams and spatial plots
- Network Analysis: Use centrality measures to identify key regulators
- Multi-sample Analysis: Learn comparative analysis across conditions
For Advanced Users
- Custom Databases: Update CellChatDB with domain-specific interactions
- Spatial Applications: Adapt parameters for different spatial technologies
- Performance Optimization: Use C++ functions for large datasets
- Integration Workflows: Combine with other single-cell analysis tools
Navigation Tips
- Function Lookup: Search api_functions.md for specific function names
- Parameter Details: Each function entry includes complete parameter descriptions
- Code Examples: All tutorials include reproducible R code
- Troubleshooting: Check the tutorials section for common issues and solutions
Resources
references/
Organized documentation extracted from official sources:
- Detailed explanations of all parameters and return values
- Code examples with proper language annotations
- Links to original documentation for deeper exploration
- Table of contents for quick navigation
scripts/
Add helper scripts here for common automation tasks:
- Data conversion utilities
- Custom visualization functions
- Batch processing workflows
assets/
Store templates and examples:
- Example datasets in proper format
- Custom ligand-receptor databases
- Configuration files for different analysis types
Common Workflows
Basic CellChat Analysis
# 1. Create object
cellchat <- createCellChat(object = data.input, meta = meta, group.by = "labels")
# 2. Set database and preprocess
cellchat@DB <- CellChatDB.human
cellchat <- subsetData(cellchat)
cellchat <- normalizeData(cellchat)
# 3. Identify over-expressed genes/interactions
cellchat <- identifyOverExpressedGenes(cellchat)
cellchat <- identifyOverExpressedInteractions(cellchat)
# 4. Infer communication
cellchat <- computeCommunProb(cellchat)
cellchat <- computeCommunProbPathway(cellchat)
cellchat <- aggregateNet(cellchat)
# 5. Visualize
netVisual(cellchat, signaling = "TGFb")
Spatial Transcriptomics Analysis
# 1. Create with spatial information
cellchat <- createCellChat(object = data.input, meta = meta, group.by = "labels",
coordinates = coordinates, spatial.factors = spatial.factors)
# 2. Spatial communication inference
cellchat <- computeCommunProb(cellchat, contact.dependent = FALSE,
interaction.range = 250, scale.distance = 1)
# 3. Spatial visualization
netVisual_spatial(cellchat, signaling = "WNT")
Comparative Analysis
# 1. Create separate objects for each condition
cellchat1 <- createCellChat(object = data.input1, meta = meta1, group.by = "labels")
cellchat2 <- createCellChat(object = data.input2, meta = meta2, group.by = "labels")
# 2. Process each object
# ... (preprocessing steps for each)
# 3. Merge for comparison
cellchat <- mergeCellChat(cellchat1, cellchat2, add.names = c("LS", "NL"))
# 4. Compare signaling
rankNet(cellchat, mode = "comparison", comparison = c(1, 2))
Notes
- Coverage: This skill covers 173 files including tutorials, API docs, and source code
- Languages: Primarily R with some C++ components
- Data Types: Supports scRNA-seq, spatial transcriptomics, and bulk data
- Integration: Works with Seurat, SingleCellExperiment, AnnData objects
- Documentation: Preserves original structure and examples from official sources
Updating
To refresh this skill with updated documentation:
- Restart the local CellChat documentation server
- Re-run the documentation scraper with the same configuration
- The skill will be rebuilt with the latest information and examples