OpenClaw-Medical-Skills 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
source · Clone the upstream repo
git clone https://github.com/FreedomIntelligence/OpenClaw-Medical-Skills
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/FreedomIntelligence/OpenClaw-Medical-Skills "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/single-cellphone-db" ~/.claude/skills/freedomintelligence-openclaw-medical-skills-single-cell-cellphonedb-communicatio && rm -rf "$T"
OpenClaw · Install into ~/.openclaw/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/FreedomIntelligence/OpenClaw-Medical-Skills "$T" && mkdir -p ~/.openclaw/skills && cp -r "$T/skills/single-cellphone-db" ~/.openclaw/skills/freedomintelligence-openclaw-medical-skills-single-cell-cellphonedb-communicatio && rm -rf "$T"
manifest:
skills/single-cellphone-db/SKILL.mdsource content
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
, andmatplotlib
resources. The tutorial assumes the pre-built CellPhoneDB v5 SQLite bundle downloaded ascellphonedb
in the working directory.cellphonedb.zip - Activate omicverse plotting defaults via
so that downstream figures follow the project palette.ov.plot_set()
- 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
(e.g., EVT, dNK, VCT). Ensureadata.obs['cell_labels']
is categorical and free of missing values so CellPhoneDB groups cells correctly.adata.obs['cell_labels'] - Confirm values are log-normalised (
should be <10 and non-integer); raw counts inflate CellPhoneDB permutations.adata.X.max()
- Read the normalised counts with
- Run CellPhoneDB via omicverse
- Execute
with the curated AnnData and metadata column:ov.single.run_cellphonedb_v5cpdb_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, ...)
). Saving avoids recomputing permutations.adata_cpdb.write(...)
- Execute
- Initialise CellChat-style visualisation
- Create a colour dictionary that maps ordered
categories tocell_labels
from previous plots.adata.uns['cell_labels_colors'] - Instantiate the viewer:
. Inspectviz = ov.pl.CellChatViz(adata_cpdb, palette=color_dict)
to ensure communication slots (adata_cpdb
/uns
) were populated.obsm
- 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
with matching figure sizes and colormaps.viz.netVisual_circle(...) - Generate outgoing/incoming per-celltype circles using
andviz.netVisual_individual_circle
to highlight senders versus receivers.viz.netVisual_individual_circle_incoming
- 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
, then plot selected pathways usingviz.get_significant_pathways_v2(...)
,viz.netVisual_aggregate(..., layout='circle')
, orviz.netVisual_chord_cell(...)
.viz.netVisual_heatmap_marsilea(...) - For ligand–receptor focus, call
orviz.netVisual_chord_LR(...)
to surface dominant pairs.viz.netAnalysis_contribution(pathway)
- Compute pathway summaries:
- System-level visualisations
- Compose bubble summaries for multiple pathways with
, optionally restrictingviz.netVisual_bubble_marsilea(...)
/sources_use
.targets_use - Display gene-level chords via
to inspect signalling directionality.viz.netVisual_chord_gene(...) - Evaluate signalling roles using
,viz.netAnalysis_computeCentrality()
,viz.netAnalysis_signalingRole_network_marsilea(...)
, andviz.netAnalysis_signalingRole_scatter(...)
for incoming/outgoing programmes.viz.netAnalysis_signalingRole_heatmap(...)
- Compose bubble summaries for multiple pathways with
- Troubleshooting tips
- Metadata alignment: CellPhoneDB requires a categorical
. If the column contains spaces, mixed casing, orcelltype_key
, clean it (NaN
).adata.obs['cell_labels'] = adata.obs['cell_labels'].astype('category').cat.remove_unused_categories() - Database bundle:
must point to a full CellPhoneDB v5 SQLite zip. If omicverse raisescpdb_file_path
or missing receptor tables, re-download the bundle from the official release and ensure the zip is not corrupted.FileNotFoundError - Permutation failures: Low cell counts per group (<
) cause early termination. Increasemin_cells
thresholds or merge sparse clusters before rerunning.min_cell_fraction - Palette mismatches: When colours render incorrectly, rebuild
fromcolor_dict
after sorting categories to keep nodes and legends consistent.adata.uns['cell_labels_colors']
- 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