Skip to contents

Extracts per-pathway information flow and sender/receiver cell-type marginals from a named list of CellChat objects, ranks pathways by differential activity, and produces four outputs:

  1. A flow heatmap: top top_n pathways × conditions, row-normalized so color reflects which condition has higher activity.

  2. Sender and receiver tile plots: faceted by top pathway, showing how much each cell type sends/receives per condition.

  3. A top changed links heatmap: the top_links sender→receiver pairs with the highest variance across conditions, showing exactly which cell-type interactions drive the pathway-level changes.

  4. A CSV of all underlying metrics (flow, sender, receiver, link tables).

Usage

RankCellChatPathways(
  cellchat_list,
  output_dir = NULL,
  top_n = 20L,
  top_links = 15L,
  rank_by = "range",
  colors = NULL,
  cell_colors = NULL
)

Arguments

cellchat_list

Named list of CellChat objects (one per condition). Names are used as condition labels throughout.

output_dir

Character or NULL. Directory for PDFs and CSVs. NULL returns objects only.

top_n

Integer. Number of top pathways (ranked by flow range across conditions) to include in visualizations. Default 20.

Integer. Number of top sender→receiver links (ranked by variance of flow across conditions) to show in the links heatmap. Default 15.

rank_by

Character. Metric used to rank pathways: "range" (max − min flow; default) or "cv" (coefficient of variation).

colors

Named character vector. Condition colors (names = condition names). NULL uses ggplot2 defaults.

cell_colors

Named character vector. Cell-type colors (names = cell type labels). Used for annotation strips in tile plots.

Value

Invisibly, a named list:

flow_table

data.frame: pathway × condition flow + ranking cols.

sender_table

long data.frame: cell_type, condition, pathway, flow.

receiver_table

long data.frame: same for receivers.

links_table

long data.frame: sender, receiver, pathway, condition, flow.

flow_heatmap

pheatmap object.

sender_plot

ggplot2 object.

receiver_plot

ggplot2 object.

links_plot

ggplot2 object.