Agent skill
single-cell-cellphonedb-communication-mapping
Run omicverse's CellPhoneDB v5 wrapper on annotated single-cell data to infer ligand-receptor networks and produce CellChat-style visualisations.
Install this agent skill to your Project
npx add-skill https://github.com/FreedomIntelligence/OpenClaw-Medical-Skills/tree/main/skills/single-cellphone-db
SKILL.md
Single-cell CellPhoneDB communication mapping
Overview
Apply this skill when a user wants to quantify ligand–receptor communication between annotated single-cell populations and display the networks with CellChatViz. It distils the workflow from t_cellphonedb.ipynb, which analyses EVT trophoblast data.
Instructions
- Prepare the environment
- Use an environment with
omicverse>=0.2,scanpy,anndata,pandas,matplotlib, andcellphonedbresources. The tutorial assumes the pre-built CellPhoneDB v5 SQLite bundle downloaded ascellphonedb.zipin the working directory. - Activate omicverse plotting defaults via
ov.plot_set()so that downstream figures follow the project palette.
- Use an environment with
- Load and subset the annotated AnnData object
- Read the normalised counts with
adata = ov.read('data/cpdb/normalised_log_counts.h5ad'). - Filter to the cell populations of interest using
adata.obs['cell_labels'](e.g., EVT, dNK, VCT). Ensureadata.obs['cell_labels']is categorical and free of missing values so CellPhoneDB groups cells correctly. - Confirm values are log-normalised (
adata.X.max()should be <10 and non-integer); raw counts inflate CellPhoneDB permutations.
- Read the normalised counts with
- Run CellPhoneDB via omicverse
- Execute
ov.single.run_cellphonedb_v5with the curated AnnData and metadata column:pythoncpdb_results, adata_cpdb = ov.single.run_cellphonedb_v5( adata, cpdb_file_path='./cellphonedb.zip', celltype_key='cell_labels', min_cell_fraction=0.005, min_genes=200, min_cells=3, iterations=1000, threshold=0.1, pvalue=0.05, threads=10, output_dir='./cpdb_results', cleanup_temp=True, ) - Persist the outputs for reuse (
ov.utils.save(cpdb_results, ...),adata_cpdb.write(...)). Saving avoids recomputing permutations.
- Execute
- Initialise CellChat-style visualisation
- Create a colour dictionary that maps ordered
cell_labelscategories toadata.uns['cell_labels_colors']from previous plots. - Instantiate the viewer:
viz = ov.pl.CellChatViz(adata_cpdb, palette=color_dict). Inspectadata_cpdbto ensure communication slots (uns/obsm) were populated.
- Create a colour dictionary that maps ordered
- Summarise global communication
- Derive aggregated counts/weights with
viz.compute_aggregated_network(pvalue_threshold=0.05, use_means=True). - Plot overall interaction strength and counts using
viz.netVisual_circle(...)with matching figure sizes and colormaps. - Generate outgoing/incoming per-celltype circles using
viz.netVisual_individual_circleandviz.netVisual_individual_circle_incomingto highlight senders versus receivers.
- Derive aggregated counts/weights with
- Interrogate specific pathways
- Compute pathway summaries:
pathway_comm = viz.compute_pathway_communication(method='mean', min_lr_pairs=2, min_expression=0.1). - Identify significant signalling routes with
viz.get_significant_pathways_v2(...), then plot selected pathways usingviz.netVisual_aggregate(..., layout='circle'),viz.netVisual_chord_cell(...), orviz.netVisual_heatmap_marsilea(...). - For ligand–receptor focus, call
viz.netVisual_chord_LR(...)orviz.netAnalysis_contribution(pathway)to surface dominant pairs.
- Compute pathway summaries:
- System-level visualisations
- Compose bubble summaries for multiple pathways with
viz.netVisual_bubble_marsilea(...), optionally restrictingsources_use/targets_use. - Display gene-level chords via
viz.netVisual_chord_gene(...)to inspect signalling directionality. - Evaluate signalling roles using
viz.netAnalysis_computeCentrality(),viz.netAnalysis_signalingRole_network_marsilea(...),viz.netAnalysis_signalingRole_scatter(...), andviz.netAnalysis_signalingRole_heatmap(...)for incoming/outgoing programmes.
- Compose bubble summaries for multiple pathways with
- Troubleshooting tips
- Metadata alignment: CellPhoneDB requires a categorical
celltype_key. If the column contains spaces, mixed casing, orNaN, clean it (adata.obs['cell_labels'] = adata.obs['cell_labels'].astype('category').cat.remove_unused_categories()). - Database bundle:
cpdb_file_pathmust point to a full CellPhoneDB v5 SQLite zip. If omicverse raisesFileNotFoundErroror missing receptor tables, re-download the bundle from the official release and ensure the zip is not corrupted. - Permutation failures: Low cell counts per group (<
min_cells) cause early termination. Increasemin_cell_fractionthresholds or merge sparse clusters before rerunning. - Palette mismatches: When colours render incorrectly, rebuild
color_dictfromadata.uns['cell_labels_colors']after sorting categories to keep nodes and legends consistent.
- Metadata alignment: CellPhoneDB requires a categorical
Examples
- "Run CellPhoneDB on our trophoblast dataset and export both the cpdb results pickle and processed AnnData."
- "Highlight significant 'Signaling by Fibroblast growth factor' interactions with chord and bubble plots."
- "Generate outgoing versus incoming communication circles to compare dNK subsets."
References
- Tutorial notebook:
t_cellphonedb.ipynb - Example data:
omicverse_guide/docs/Tutorials-single/data/cpdb/ - Quick copy/paste commands:
reference.md
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
vcf-annotator
Annotate VCF variants with VEP, ClinVar, gnomAD frequencies, and ancestry-aware context. Generates prioritised variant reports.
chemist-analyst
Analyzes events through chemistry lens using molecular structure, reaction mechanisms, thermodynamics, kinetics, and analytical techniques (spectroscopy, chromatography, mass spectrometry). Provides insights on chemical processes, material properties, reaction pathways, synthesis, and analytical methods. Use when: Chemical reactions, material analysis, synthesis planning, process optimization, environmental chemistry. Evaluates: Molecular structure, reaction mechanisms, yield, selectivity, safety, environmental impact.
bio-alignment-io
Read, write, and convert multiple sequence alignment files using Biopython Bio.AlignIO. Supports Clustal, PHYLIP, Stockholm, FASTA, Nexus, and other alignment formats for phylogenetics and conservation analysis. Use when reading, writing, or converting alignment file formats.
sleep-analyzer
分析睡眠数据、识别睡眠模式、评估睡眠质量,并提供个性化睡眠改善建议。支持与其他健康数据的关联分析。
metabolomics-workbench-database
Access NIH Metabolomics Workbench via REST API (4,200+ studies). Query metabolites, RefMet nomenclature, MS/NMR data, m/z searches, study metadata, for metabolomics and biomarker discovery.
bio-hi-c-analysis-matrix-operations
Balance, normalize, and transform Hi-C contact matrices using cooler and cooltools. Apply iterative correction (ICE), compute expected values, and generate observed/expected matrices. Use when normalizing or transforming Hi-C matrices.
Didn't find tool you were looking for?