Prepare enrichment data with common computed columns
Source:R/enrichment_visualization.R
prepare_enrichment_data.RdAdds neg_log_fdr, direction, and significant columns to enrichment results. This is a shared helper used by plot functions and analyses.
Examples
# Basic usage with default FDR column
df <- data.frame(NES = c(1.5, -1.2, 0.5, -0.3), FDR = c(0.01, 0.08, 0.05, 0.25))
result <- prepare_enrichment_data(df)
result$direction # "Up", "Down", "Up", "Down"
#> [1] "Up" "Down" "Up" "Down"
result$significant # TRUE, TRUE, TRUE, FALSE
#> [1] TRUE TRUE TRUE FALSE
# With custom FDR column name (e.g., from clusterProfiler)
df2 <- data.frame(NES = c(2.0, -1.5), p.adjust = c(0.02, 0.12))
result2 <- prepare_enrichment_data(df2, fdr_col = "p.adjust")
# With stricter FDR threshold
result3 <- prepare_enrichment_data(df, fdr_threshold = 0.05)
result3$significant # TRUE, FALSE, TRUE, FALSE
#> [1] TRUE FALSE FALSE FALSE