% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/enrichmentSets.R
\name{enrichmentSets}
\alias{enrichmentSets}
\title{Run the Full Differential‐Expression Motif Enrichment Pipeline}
\usage{
enrichmentSets(
  txdb,
  orgdb,
  id_type,
  foreground_ids,
  background_ids = NULL,
  transcript = FALSE,
  threshold = 0.9,
  stripVersions = TRUE,
  inflateThresh = 1,
  geneType = NULL,
  overlapMinGap = 0,
  onePromoterPerGene = FALSE,
  n_ratio = 1,
  promoterWindow = c(upstream = 300, downstream = 50),
  standardChroms = TRUE,
  reduceOverlaps = TRUE
)
}
\arguments{
\item{txdb}{A TxDb object.
(e.g. \code{TxDb.Hsapiens.UCSC.hg38.knownGene}).}

\item{orgdb}{An OrgDb object. (e.g. \code{org.Hs.eg.db}).}

\item{id_type}{Type of identifier supplied in foreground and background IDs.
See the \code{keytypes(orgdb)} for available id type options for each genome.}

\item{foreground_ids}{Character vector of gene or
transcript IDs (e.g. Ensembl, RefSeq, gene symbols) to analyze.}

\item{background_ids}{Character vector of gene or transcript
IDs to use as background set.}

\item{transcript}{Logical; \code{TRUE} to treat inputs as transcript‐level,
\code{FALSE} for gene‐level.}

\item{threshold}{Numeric in range 0 to 1. Min fraction of IDs that must map
to pick a keytype (default 0.9).}

\item{stripVersions}{Logical; strip version suffixes (e.g. ".1") from
Ensembl/RefSeq IDs.}

\item{inflateThresh}{Numeric in range 0 to 1; max allowed transcript:gene
inflation before auto‐collapsing (default 1).}

\item{geneType}{Optional character; biotype filter
(e.g. \code{"protein-coding"}).}

\item{overlapMinGap}{Numeric; minimum gap when reducing
overlapping promoters.}

\item{onePromoterPerGene}{Logical; if
\code{TRUE}, pick only one promoter per gene.}

\item{n_ratio}{Numeric; ratio of ranges to retain in the background set.
The number of background ranges will be equal to \code{n_ratio} multiplied
by the number of foreground ranges.}

\item{promoterWindow}{Numeric named vector \code{c(upstream, downstream)};
promoter flank widths in bp (default \code{c(300,50)}).}

\item{standardChroms}{Logical; restrict to standard chromosomes.}

\item{reduceOverlaps}{Logical; merge overlapping promoter windows.}
}
\value{
A \code{list} containing:
\describe{
\item{backgroundElements}{\code{GRanges} of sampled background promoters}
\item{foregroundElements}{\code{GRanges} of foreground promoters}
\item{backgroundUniverse}{\code{GRanges} of the pruned promoter pool}
}
}
\description{
\code{enrichmentSets()} is a one‐stop wrapper that takes a vector of
user‐provided IDs from a differential expression analysis and returns
promoter regions plus matched background sets for downstream motif
enrichment.  It performs:
\enumerate{
\item ID mapping
\item Optional biotype filtering
\item Promoter coordinate extraction
\item Background sampling within that same call
}
}
\examples{
library(TxDb.Hsapiens.UCSC.hg38.knownGene)
library(org.Hs.eg.db)

txdb <- TxDb.Hsapiens.UCSC.hg38.knownGene
orgdb <- org.Hs.eg.db

# Note that this is a minimal set for demonstration only
genes <- c("ENSG00000139618", "ENSG00000157764")
background <- c("ENSG00000111640", "ENSG00000075624")

# Minimal run with defaults:
results <- enrichmentSets(genes,
    background,
    txdb = txdb,
    orgdb = orgdb,
    id_type = "ENSEMBL"
)

}
