Overview
TheAdvancedCommunicationPipeline class performs sophisticated cell-cell communication analysis using ligand-receptor (L-R) interaction databases. It integrates with LIANA-compatible resources to identify signaling pathways between cell types.
Inheritance: BasePipeline
Source: heartmap.pipelines.AdvancedCommunicationPipeline (src/heartmap/pipelines/init.py:113)
Constructor
Configuration object containing analysis parameters.
Attributes
Inherited fromBasePipeline:
config(Config): Configuration objectdata_processor(DataProcessor): Data processing handlervisualizer(Visualizer): Visualization handlerexporter(ResultsExporter): Results export handlerresults(Dict[str, Any]): Dictionary storing pipeline results
lr_available(bool): Whether ligand-receptor database is availableget_lr_pairs(callable): Function to retrieve L-R pairs from database
Methods
run()
Run the advanced communication analysis pipeline on annotated single-cell data.Path to annotated H5AD file. Must contain cell type annotations in one of these columns: ‘leiden’, ‘louvain’, ‘Cluster’, ‘cluster’, ‘cell_type’, ‘celltype’.
Directory to save communication results and visualizations. If None, results are returned but not saved.
Dictionary containing pipeline results:
Annotated data object (unchanged from input)
Communication analysis results
DataFrame with columns:
source(str): Source cell type expressing ligandtarget(str): Target cell type expressing receptorligand(str): Ligand gene namereceptor(str): Receptor gene namecommunication_score(float): Communication strength (geometric mean of expression)
Hub scores for each cell (index matches adata.obs.index)
Pathway enrichment scores (currently placeholder)
ImportError: If required dependencies are not availableValueError: If input data lacks cell type annotation columns
- Data Loading - Reads annotated H5AD file
- Annotation Detection - Identifies cell type column (leiden/Cluster/cell_type/etc.)
- L-R Database Integration - Loads ligand-receptor pairs from consensus database (confidence ≥ 0.7)
- Communication Analysis - Calculates L-R co-expression scores between cell types
- Hub Score Calculation - Identifies communication hub cell types
- Visualization - Generates heatmaps and network plots (if output_dir provided)
_calculate_lr_communication()
Internal method. Calculate communication scores based on ligand-receptor co-expression._basic_communication_analysis()
Internal method. Fallback communication analysis when L-R database is unavailable._calculate_hub_scores()
Internal method. Calculate hub scores per cell type.(std * mean) / (variance + 1) for each cell type’s expression profile.
Usage Example
L-R Database Integration
The pipeline automatically attempts to load ligand-receptor pairs from the consensus database with:- Resource:
'consensus'- Aggregated from multiple curated databases - Confidence threshold:
0.7- Only high-confidence interactions - Filtering: Expression threshold of 0.1 for both ligand and receptor
Output Files
Whenoutput_dir is specified, the pipeline generates:
figures/communication_heatmap.png- Cell type communication matrixfigures/hub_scores.png- Hub score visualization per cell typefigures/pathway_scores.png- Pathway enrichment plots- Results exported via
ResultsExporter
Related Documentation
BasicPipeline
Run basic clustering before communication analysis
Visualizer
Visualization utilities for communication networks
Communication Analysis Guide
Detailed guide on cell-cell communication analysis