
Rank and visualize differentially active CellChat pathways across conditions
RankCellChatPathways.RdExtracts 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:
A flow heatmap: top
top_npathways × conditions, row-normalized so color reflects which condition has higher activity.Sender and receiver tile plots: faceted by top pathway, showing how much each cell type sends/receives per condition.
A top changed links heatmap: the
top_linkssender→receiver pairs with the highest variance across conditions, showing exactly which cell-type interactions drive the pathway-level changes.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.NULLreturns objects only.- top_n
Integer. Number of top pathways (ranked by flow range across conditions) to include in visualizations. Default
20.- top_links
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).
NULLuses 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_tabledata.frame: pathway × condition flow + ranking cols.
sender_tablelong data.frame: cell_type, condition, pathway, flow.
receiver_tablelong data.frame: same for receivers.
links_tablelong data.frame: sender, receiver, pathway, condition, flow.
flow_heatmappheatmap object.
sender_plotggplot2 object.
receiver_plotggplot2 object.
links_plotggplot2 object.