
Visualize Leading-Edge Genes from GSEA Results
VisualizeLeadingEdge.RdLoads one or more GSEA result CSV files (from RunGSEA or
RunGSEA_pseudobulk), searches for pathways by keyword or exact
name, extracts the union of leading-edge genes, and produces a per-cell
expression heatmap. Optionally, if a DEG data frame is supplied, the
leading-edge genes are intersected with significant DEGs and additional
diagnostic plots are produced (a second heatmap, dotplot, stacked violins,
and boxplots).
Usage
VisualizeLeadingEdge(
seurat_object,
gsea_files,
search_terms = NULL,
pathways = NULL,
group.by,
split.by = NULL,
assay = "RNA",
layer = "data",
min_expr = 0.05,
subset_cells = FALSE,
subset_by = NULL,
subset_values = NULL,
deg_df = NULL,
deg_gene_column = "feature",
deg_group_column = "group",
deg_fc_column = "logFC",
deg_padj_column = "padj",
deg_padj_cutoff = 0.05,
deg_top_n = 20,
add_dotplot = TRUE,
add_violin = TRUE,
add_boxplots = TRUE,
add_pvalues = TRUE,
add_feature_maps = FALSE,
heatmap_type = c("cell", "group"),
heatmap_column_split = NULL,
show_pathway_annotation = TRUE,
group_colors = NULL,
split_colors = NULL,
heatmap_params = list(row_names_side = "left", show_row_dend = FALSE,
row_names_max_width = grid::unit(15, "cm")),
output_dir,
object_name = "Analysis",
subset_name = ""
)Arguments
- seurat_object
A Seurat object.
- gsea_files
Character vector of CSV file paths (output of
RunGSEAorRunGSEA_pseudobulk). Must each containpathwayandleadingEdgecolumns.- search_terms
Keyword(s) to filter pathways. See Pathway search above.
- pathways
Exact pathway names to select (alternative to
search_terms).- group.by
Metadata column for the primary grouping (required). Used for column annotation, dotplot, and violin grouping.
- split.by
Optional second metadata column for column annotation and violin splitting.
- assay
Assay to pull expression from (default
"RNA").- layer
Layer to pull expression from (default
"data").- min_expr
Genes whose row-mean expression is below this threshold are excluded from the heatmap (default
0.05).- subset_cells
Logical; if
TRUE, subsetseurat_objecttosubset_valuesinsubset_bybefore analysis.- subset_by
Metadata column used for subsetting (requires
subset_cells = TRUE).- subset_values
Character vector of values to retain in
subset_by.- deg_df
Optional DEG data frame (e.g. from presto or
FindMarkers). When provided, leading-edge genes are intersected with significant DEGs and additional plots are generated.- deg_gene_column
Column in
deg_dfwith gene names (default"feature").- deg_group_column
Column in
deg_dfwith group labels (default"group").- deg_fc_column
Column in
deg_dfwith log-fold change (default"logFC").- deg_padj_column
Column in
deg_dfwith adjusted p-value (default"padj").- deg_padj_cutoff
Adjusted p-value cut-off (default
0.05).- deg_top_n
Top N DEGs per group (by logFC) for bonus plots (default
20).- add_dotplot
Logical; produce a
Seurat::DotPlotof top DEGs (defaultTRUE; requiresdeg_df).- add_violin
Logical; produce stacked violin plots of top DEGs (default
TRUE; requiresdeg_df).- add_boxplots
Logical; produce boxplots of top DEGs (default
TRUE; requiresdeg_df).- add_pvalues
Logical; overlay Kruskal-Wallis p-value on boxplots via
ggpubr::stat_compare_means(defaultTRUE).- add_feature_maps
Logical; produce per-gene
FeaturePlotPDFs for the top DEG genes (defaultFALSE; can be slow for large gene sets).- heatmap_type
Character. Either
"cell"(default) for a per-cell heatmap with cells ordered bygroup.by(thensplit.by), or"group"for a compact group-mean heatmap with one column pergroup.byxsplit.bycombination.- heatmap_column_split
Character or
NULL. Metadata column used to split heatmap columns into labeled sections (e.g. a diagnosis or timepoint variable). Only applies whenheatmap_type = "cell". DefaultNULL.- show_pathway_annotation
Logical. When
TRUE(default), a colored annotation bar is drawn on the right of each heatmap showing which source pathway each gene belongs to. Suppressed automatically when only one pathway is matched.- group_colors
Named character vector of colors for
group.bylevels. Auto-assigned fromNour_pal("all")ifNULL.- split_colors
Named character vector of colors for
split.bylevels. Auto-assigned fromNour_pal("spectrum")ifNULL.- heatmap_params
Named list of additional arguments forwarded to
ComplexHeatmap::Heatmap(). Any key supplied here overrides the default.- output_dir
Directory where all output files are saved.
- object_name
Label used in output file names and subfolder (default
"Analysis").- subset_name
Optional label appended to output file names (default
"").
Value
Invisibly returns a named list:
genes_allAll leading-edge genes present in the Seurat object (after
min_exprfiltering).genes_topTop DEG genes within the leading edge, or
NULLif nodeg_dfwas provided.top_degsFiltered DEG data frame, or
NULL.
Pathway search
search_termsas a character vectorOR logic - any term matches, case-insensitive.
search_termsas a list of character vectorsEach element is an AND-group (all terms must appear in the same pathway name); results are OR'd across elements.
pathwaysExact pathway names (alternative to
search_terms).