Skip to contents

Shared post-processing for the ORA / GSEA / CAMERA runners. Each runner hands in a data frame that already has the harmonized columns ChemicalID and pvalue; this helper computes padj, joins chemical metadata, applies a canonical leading-column order, sorts by padj ascending, and drops row names. Centralizing this step keeps the runners small and the public output schema consistent across methods.

Usage

.format_enrichment_result(
  res,
  chemicals_meta,
  pAdjustMethod,
  method,
  rename = NULL,
  drop = NULL
)

Arguments

res

Data frame as returned by an enrichment engine (ora(), gsea(), limma::camera()), still carrying the engine's native column names.

chemicals_meta

Data frame with ChemicalID and ChemicalName columns.

pAdjustMethod

Method passed to p.adjust.

method

Method label (one of "ORA", "GSEA", "CAMERA") stamped into the new Method column so results can be rbind'd across methods without losing provenance.

rename

Named character vector mapping old_engine_colname = "NewCanonicalName". Applied before the metadata merge. Centralizes the engine->canonical-schema mapping so each engine can keep its native column names.

drop

Character vector of engine column names to remove before the merge / sort.

Value

A data frame whose leading columns are ChemicalID, ChemicalName, Method, PValue, PValueAdjusted (whichever of those are present after the rename), followed by the remaining columns in their original order, sorted by PValueAdjusted ascending.