# 08 Cell Communication Logic

## Quick Answer
Cell Communication estimates ligand-receptor signaling support between selected source/target cells. UI detail tables may be capped, but summary calculations and full exports are preserved with metadata.

## What this does
Generates interaction lists, system summaries, and heatmap representations for selected cell contexts.

## Inputs
- Query set and selected cells
- Ligand-receptor pairs
- Cell specificity/expression support
- Scoring method configuration

## Outputs
- Interaction detail rows
- System-level summary rows
- Heatmap matrix and selected-pair details
- Scoring metadata and cap indicators

## Interaction UX (Phase 11)
- System chord ribbons are click-selectable and filter detailed interaction rows inline.
- System-summary row drilldown renders inline accordion detail below the summary table.
- Heatmap and chord filtering are aligned to the same detail container behavior.
- When no cells are explicitly chosen, the workflow uses the default top-ranked cell set from Cell Specificity to avoid empty communication runs.
- Heatmap legends (score gradient + pair-size scale) are embedded directly in the SVG for consistent fonts and dark/light theming.

## How calculated
Candidate interactions are first scored from ligand and receptor expression under configured method parameters. The default expression score is:

`(log1p(ligand_expr) + log1p(receptor_expr)) / 2`.

The environment variable `LR_SCORE_METHOD` can switch this expression score to `product_log1p` or `geometric_log1p`. The Alzheimer manuscript state reports the default weighted relevance score on a 0-100 point scale:

`45 * expression_score + 15 * direct_query_ligand + 10 * query_receptor + 10 * ev_reported_ligand + 10 * secreted_or_membrane_ligand + 5 * curated_source_count + 5 * active_system_focus`.

When disease context is active, context-only rows can be hidden in the detail view. Ranking then sorts by disease-pair score, communication relevance, expression score, and curated source breadth while preserving hidden-row counts in metadata.

The communication module is usually launched after Cell Specificity. The selected source and target cell contexts determine which ligand-receptor rows are summarized. Dense results can be capped in the UI for speed, but full exports preserve `total_rows`, `returned_rows`, truncation status, source labels, score components, and selected cell pairs.

## What to download
Use full communication exports for downstream plotting and statistics, not just visible rows.

## Known limits
Dense systems can produce large interaction spaces. Interactive view limits are expected and should be reported. Communication scores rank candidate cell-pair hypotheses. They do not prove EV transfer, receptor activation, or signaling in recipient cells.
