as_genes: Extract significant genes from DESeq2 results for ORA

View source: R/deseq2.R

as_genesR Documentation

Extract significant genes from DESeq2 results for ORA

Description

Select the genes passing an adjusted-p-value cut-off (optionally split by direction of change) from a DESeq2 analysis, as a character vector of gene identifiers for ora.

Usage

as_genes(
  x,
  cutoff = 0.05,
  direction = c("both", "up", "down"),
  minAbsLFC = 0,
  ...
)

## S3 method for class 'DESeqResults'
as_genes(
  x,
  cutoff = 0.05,
  direction = c("both", "up", "down"),
  minAbsLFC = 0,
  ...
)

## S3 method for class 'DESeqDataSet'
as_genes(
  x,
  cutoff = 0.05,
  direction = c("both", "up", "down"),
  minAbsLFC = 0,
  ...
)

Arguments

x

a DESeqResults or DESeqDataSet object. For a DESeqDataSet, ... is forwarded to DESeq2::results().

cutoff

numeric, adjusted p-value cut-off (default 0.05); genes with padj < cutoff are kept.

direction

character, "both" (default), "up" or "down"; selects genes with positive or negative log2FoldChange among the significant ones.

minAbsLFC

numeric, keep only significant genes with abs(log2FoldChange) > minAbsLFC (default 0, no filtering).

...

additional arguments; for a DESeqDataSet these are passed to DESeq2::results().

Details

Selection uses padj < cutoff on the padj column as produced by DESeq2::results() (which includes independent filtering). minAbsLFC is a post-hoc filter applied to the reported log2FoldChange; it does not change the underlying test. To test against a minimum effect size, set lfcThreshold in results() / DESeq2::results() instead.

Value

A character vector of gene identifiers (empty if no gene passes, with a warning).

Examples


library(DESeq2)
dds <- makeExampleDESeqDataSet(n = 500)
isB <- colData(dds)$condition == "B"
ct <- counts(dds)
ct[1:60, isB] <- ct[1:60, isB] * 5 + 500
storage.mode(ct) <- "integer"
counts(dds) <- ct
dds <- DESeq(dds, quiet = TRUE)
up_genes <- as_genes(dds, contrast = c("condition", "B", "A"), direction = "up")
gene_sets <- list(
    SET1 = paste0("gene", 1:50),
    SET2 = paste0("gene", 201:260)
)
res <- ora(gene = up_genes, gene_sets = gene_sets, universe = rownames(dds))


enrichit documentation built on Oct. 28, 2026, 9:07 a.m.