Skip to contents

Internal engine that performs Gene Set Enrichment Analysis via fgsea. Detects chemicals whose known target genes cluster toward the extremes of a ranked gene list.

This function returns the raw GSEA result with two GSEA-specific decorations (foldEnrichment, Enriched_GENE) and harmonized column names (ChemicalID, pvalue). The adjusted-p, chemical-name join, column ordering and sort are applied downstream by .format_enrichment_result so that the schema stays consistent across ORA / GSEA / CAMERA.

Usage

gsea(ChemicalName_GeneEntrezIds, gene_table, ...)

Arguments

ChemicalName_GeneEntrezIds

A named list where each element is a character vector of Entrez gene IDs associated with a CTD chemical. Names are CTD chemical IDs.

gene_table

A data frame with at least two columns:

EntrezID

Entrez gene IDs (character).

(second column)

Numeric values (e.g. p-values), used as -log10(value) fallback ranking when no stat column is present.

stat (optional)

Signed numeric ranking statistic used directly by fgsea (higher = ranked first). Recommended: the moderated t-statistic from limma::eBayes() or -log10(p) * sign(logFC). When present, suppresses the directionality warning.

...

Additional arguments forwarded to fgseaMultilevel (e.g. nproc to set the number of parallel workers, eps for p-value precision).

Value

A data frame with fgsea::fgseaMultilevel's native columns (pathway, pval, ES, NES, size, leadingEdge) plus two ctdR-added columns (foldEnrichment, Enriched_GENE). Not yet sorted and not yet joined with chemical metadata; pass to .format_enrichment_result for the canonical shape.