Skip to contents

Iterates over every cluster in a named list of GO enrichment results, builds a Jaccard-overlap network of enriched GO terms, applies Leiden community detection, and saves network plots and summary tables. Clusters that lack enrichment results or have fewer than two significant pathways are skipped with a message.

Usage

run_comparison_networks(
  go_list,
  de_list,
  comp_label,
  base_outdir,
  overlap_threshold = 0.1,
  leiden_resolution = 0.03
)

Arguments

go_list

A named list of enrichResult objects (from clusterProfiler::enrichGO), one per cell-type cluster. Names must match the names in de_list.

de_list

A named list of differential-expression data frames, one per cluster. Each data frame must contain at least the columns gene (gene symbol) and avg_log2FC.

comp_label

Character string identifying the comparison (e.g., "CD206_Car_vs_Bleo"). Used to build output sub-directory paths and as a prefix in plot titles.

base_outdir

Character path to the root output directory. A sub-directory <comp_label>/networks/ is created automatically.

overlap_threshold

Numeric [0, 1]. Minimum Jaccard overlap between two GO term gene sets required to draw an edge. Default 0.1.

leiden_resolution

Numeric. Resolution parameter passed to igraph::cluster_leiden. Lower values produce fewer, larger communities. Default 0.03.

Value

A named list of network result lists (one per cluster that produced a valid network). Each element is the list returned by generate_overlap_network.