single-cell-cellphonedb-communication-mapping

2
0
Source

Run omicverse's CellPhoneDB v5 wrapper on annotated single-cell data to infer ligand-receptor networks and produce CellChat-style visualisations.

Install

mkdir -p .claude/skills/single-cell-cellphonedb-communication-mapping && curl -L -o skill.zip "https://mcp.directory/api/skills/download/3549" && unzip -o skill.zip -d .claude/skills/single-cell-cellphonedb-communication-mapping && rm skill.zip

Installs to .claude/skills/single-cell-cellphonedb-communication-mapping

About this skill

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

  1. Prepare the environment
    • Use an environment with omicverse>=0.2, scanpy, anndata, pandas, matplotlib, and cellphonedb resources. The tutorial assumes the pre-built CellPhoneDB v5 SQLite bundle downloaded as cellphonedb.zip in the working directory.
    • Activate omicverse plotting defaults via ov.plot_set() so that downstream figures follow the project palette.
  2. 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). Ensure adata.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.
  3. Run CellPhoneDB via omicverse
    • Execute ov.single.run_cellphonedb_v5 with the curated AnnData and metadata column:
      cpdb_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.
  4. Initialise CellChat-style visualisation
    • Create a colour dictionary that maps ordered cell_labels categories to adata.uns['cell_labels_colors'] from previous plots.
    • Instantiate the viewer: viz = ov.pl.CellChatViz(adata_cpdb, palette=color_dict). Inspect adata_cpdb to ensure communication slots (uns/obsm) were populated.
  5. 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_circle and viz.netVisual_individual_circle_incoming to highlight senders versus receivers.
  6. 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 using viz.netVisual_aggregate(..., layout='circle'), viz.netVisual_chord_cell(...), or viz.netVisual_heatmap_marsilea(...).
    • For ligand–receptor focus, call viz.netVisual_chord_LR(...) or viz.netAnalysis_contribution(pathway) to surface dominant pairs.
  7. System-level visualisations
    • Compose bubble summaries for multiple pathways with viz.netVisual_bubble_marsilea(...), optionally restricting sources_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(...), and viz.netAnalysis_signalingRole_heatmap(...) for incoming/outgoing programmes.
  8. Defensive validation
    # Before CellPhoneDB: validate cell type column
    assert celltype_key in adata.obs.columns, f"Column '{celltype_key}' not found in adata.obs"
    adata.obs[celltype_key] = adata.obs[celltype_key].astype('category').cat.remove_unused_categories()
    assert not adata.obs[celltype_key].isna().any(), f"NaN values in '{celltype_key}' — clean before running CellPhoneDB"
    min_per_group = adata.obs[celltype_key].value_counts().min()
    if min_per_group < 10:
        print(f"WARNING: smallest cell group has {min_per_group} cells — may cause permutation failures")
    
  9. Troubleshooting tips
    • Metadata alignment: CellPhoneDB requires a categorical celltype_key. If the column contains spaces, mixed casing, or NaN, clean it (adata.obs['cell_labels'] = adata.obs['cell_labels'].astype('category').cat.remove_unused_categories()).
    • Database bundle: cpdb_file_path must point to a full CellPhoneDB v5 SQLite zip. If omicverse raises FileNotFoundError or 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. Increase min_cell_fraction thresholds or merge sparse clusters before rerunning.
    • Palette mismatches: When colours render incorrectly, rebuild color_dict from adata.uns['cell_labels_colors'] after sorting categories to keep nodes and legends consistent.

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

You might also like

flutter-development

aj-geddes

Build beautiful cross-platform mobile apps with Flutter and Dart. Covers widgets, state management with Provider/BLoC, navigation, API integration, and material design.

643969

drawio-diagrams-enhanced

jgtolentino

Create professional draw.io (diagrams.net) diagrams in XML format (.drawio files) with integrated PMP/PMBOK methodologies, extensive visual asset libraries, and industry-standard professional templates. Use this skill when users ask to create flowcharts, swimlane diagrams, cross-functional flowcharts, org charts, network diagrams, UML diagrams, BPMN, project management diagrams (WBS, Gantt, PERT, RACI), risk matrices, stakeholder maps, or any other visual diagram in draw.io format. This skill includes access to custom shape libraries for icons, clipart, and professional symbols.

591705

ui-ux-pro-max

nextlevelbuilder

"UI/UX design intelligence. 50 styles, 21 palettes, 50 font pairings, 20 charts, 8 stacks (React, Next.js, Vue, Svelte, SwiftUI, React Native, Flutter, Tailwind). Actions: plan, build, create, design, implement, review, fix, improve, optimize, enhance, refactor, check UI/UX code. Projects: website, landing page, dashboard, admin panel, e-commerce, SaaS, portfolio, blog, mobile app, .html, .tsx, .vue, .svelte. Elements: button, modal, navbar, sidebar, card, table, form, chart. Styles: glassmorphism, claymorphism, minimalism, brutalism, neumorphism, bento grid, dark mode, responsive, skeuomorphism, flat design. Topics: color palette, accessibility, animation, layout, typography, font pairing, spacing, hover, shadow, gradient."

318398

godot

bfollington

This skill should be used when working on Godot Engine projects. It provides specialized knowledge of Godot's file formats (.gd, .tscn, .tres), architecture patterns (component-based, signal-driven, resource-based), common pitfalls, validation tools, code templates, and CLI workflows. The `godot` command is available for running the game, validating scripts, importing resources, and exporting builds. Use this skill for tasks involving Godot game development, debugging scene/resource files, implementing game systems, or creating new Godot components.

339397

nano-banana-pro

garg-aayush

Generate and edit images using Google's Nano Banana Pro (Gemini 3 Pro Image) API. Use when the user asks to generate, create, edit, modify, change, alter, or update images. Also use when user references an existing image file and asks to modify it in any way (e.g., "modify this image", "change the background", "replace X with Y"). Supports both text-to-image generation and image-to-image editing with configurable resolution (1K default, 2K, or 4K for high resolution). DO NOT read the image file first - use this skill directly with the --input-image parameter.

451339

fastapi-templates

wshobson

Create production-ready FastAPI projects with async patterns, dependency injection, and comprehensive error handling. Use when building new FastAPI applications or setting up backend API projects.

304231

Stay ahead of the MCP ecosystem

Get weekly updates on new skills and servers.