% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/enrichment_util.R
\name{runEnrichmentAnalyses}
\alias{runEnrichmentAnalyses}
\title{Wrapper for executing various enrichment analyses}
\usage{
runEnrichmentAnalyses(
  diffr.wrapper.output,
  analysis.name = "enrichment",
  use.background.from.diffr.output = TRUE,
  use.pval.in.DE.filtering.if.no.sign.fdrs = FALSE,
  out.dir,
  species = "human",
  p.thr = 0.05,
  fdr.thr = 0.05,
  logfc.thr = 1,
  do.plot = FALSE,
  plot.fdr.thr = fdr.thr,
  plot.logfc.thr = logfc.thr,
  plot.num.terms = 5,
  enrichment.methods = c("clusterProfilerGO", "clusterProfilerKEGG", "gProfileR",
    "topGO"),
  clusterProfilerGO.params = list(analysis.approach = "ORA", do.similarity.filtering =
    FALSE, min.gene.set.size = 10, max.gene.set.size = 1000, ontology = "BP", min.overlap
    = 2, p.adjust.method = "BH"),
  clusterProfilerKEGG.params = list(analysis.approach = "ORA", min.gene.set.size = 10,
    max.gene.set.size = 1000, ontology = "BP", min.overlap = 2, p.adjust.method = "BH"),
  gProfileR.params = list(data.sources = "GO:BP", show.only.significant = TRUE,
    measure_underrepresentation = FALSE, evidence_codes = TRUE, domain_scope =
    "annotated", highlight = TRUE),
  topGO.params = list(ontologies.used = c("BP"), org = "hsapiens")
)
}
\arguments{
\item{diffr.wrapper.output}{\code{list}.  Nested list system produced by diffrExpr-wrapper.
Has to contain element "contrasts" that contains contrast-specific expression tables}

\item{analysis.name}{\code{character}. Descriptive character-tag used in output file names}

\item{use.background.from.diffr.output}{\code{logical}. Whether the (ORA) analyses are run
with experiment-specific background obtained from pre-filtered expression matrix or with the default background of the functions (genome)}

\item{use.pval.in.DE.filtering.if.no.sign.fdrs}{\code{logical} Sometimes no DE genes with significant adjusted p-value is found.
In such cases, should uncorrected p-values be used in order to get at least some results}

\item{out.dir}{\code{character}. Root directory for the resulting subdirectories. Must contain subfolders for contrasts.
Required; no default is used so that nothing is written to the working directory unintentionally.}

\item{species}{\code{character}. Currently valid options are "human" or "mouse".}

\item{p.thr}{\code{numeric}. Threshold for un-adjusted p-values (applied in both filtering of DE-genes and in enrichment results,
when relevant (i.e. no significant fdr-entries are found)). Default 0.05}

\item{fdr.thr}{\code{numeric}. Threshold for adjusted p-values (applied in both filtering of DE-genes and in enrichment results). Default 0.05}

\item{logfc.thr}{\code{numeric}. Threshold for the log2-fold-change. Defaults to 1.}

\item{do.plot}{\code{logical}. Whether or not to draw a network plot for the enrichment results. Defaults to \code{FALSE}.}

\item{plot.fdr.thr}{\code{numeric}. FDR threshold used in the enrichment plot. This may be useful to tweak to produce a more informative plot.
Defaults to 0.05.}

\item{plot.logfc.thr}{\code{numeric}. FC threshold on the log2-scale used in the enrichment plot. Defaults to 1.}

\item{plot.num.terms}{\code{integer}. Number of terms shown in the plot. Defaults to 5.}

\item{enrichment.methods}{\code{character}. Enrichment methods to be run. One or more of the following: c("clusterProfilerGO", "clusterProfilerKEGG", "gProfileR", "topGO")}

\item{clusterProfilerGO.params}{\code{list}. Method-specific parameters for clusterProfilerGO. One or more of the following (default values shown
and used for all such elements not given in the call):
analysis.approach="ORA", do.similarity.filtering=F,min.gene.set.size=10,max.gene.set.size=1000, ontology="BP", min.overlap=2,p.adjust.method="BH".
Analysis approach can be "ORA" or "KEGG". If do.similarity.filtering is set to TRUE, clusterProfiler::simplify() is run.}

\item{clusterProfilerKEGG.params}{\code{list}.}

\item{gProfileR.params}{\code{list}.}

\item{topGO.params}{\code{list}.}
}
\value{
A list of all relevant objects generated in the course of the enrichment analyses
}
\description{
\command{runEnrichmentAnalyses} enables the auto-run of some over-representation analysis (ORA) and
gene set enrichment analysis (GSEA) functions for the output of diffExpr main wrapper.
Functions in various R-packages (clusterProfiler, topGO, gProfileR)
are integrated. Currently supports human or mouse!
}
\examples{
\donttest{
# needs annotation packages; run on real data with mappable gene IDs
if (requireNamespace("clusterProfiler", quietly = TRUE) &&
    requireNamespace("org.Hs.eg.db", quietly = TRUE) &&
    requireNamespace("AnnotationDbi", quietly = TRUE)) {
  out.dir <- file.path(tempdir(), "diffwrap_demo")
  dir.create(out.dir, showWarnings = FALSE)
  res <- diffExpr(diffwrap_counts, diffwrap_samp_info, samples = "SampleName",
                  groups = "Group", control = "control", analysis.name = "demo",
                  out.dir = out.dir, enr.do = FALSE)
  # wrapped in tryCatch(): enrichment depends on annotation databases and, for some
  # methods, on remote services, neither of which may be available on a check machine
  enr <- tryCatch(
    runEnrichmentAnalyses(res, analysis.name = "demo", out.dir = out.dir,
                          species = "human", enrichment.methods = "clusterProfilerGO"),
    error = function(e) {
      message("Enrichment could not be run: ", conditionMessage(e))
      NULL
    })
}
}
}
