Combines two enrichment analyses in a single divergent (back-to-back) bar plot: the genesets enriched in the first element of the list are drawn as positive values, the ones enriched in the second element as negative values. It is meant to display together the two sides of a differential expression analyses, for instance the ORA of the up- and down-regulated proteins of the same contrast. The two enrichments can come from different sources (DEprot or clusterProfiler) and can be mixed.

divergent.enrichment(
  enrichment.list,
  value = "FoldEnrichment",
  top.n = 10,
  terms = NULL,
  padj.cutoff = 0.05,
  top.by = "significance",
  pos.color = "steelblue",
  neg.color = "orange",
  alpha.range = c(0.3, 1),
  add.counts = TRUE,
  string.pattern.to.remove = NULL,
  max.term.length = 60,
  perc.bleeding.x = 8,
  axes.text.size = 10,
  bar.width = 0.8,
  title = NULL
)

Arguments

enrichment.list

Named list of two enrichments. Each element can be an object of class DEprot.enrichResult (DEprot), enrichResult or gseaResult (clusterProfiler), or a data.frame with the same structure of the tables returned by clusterProfiler. The first element is plotted on the positive side, the second one on the negative side. No default.

value

String indicating the metric used for the length of the bars. One among: "FoldEnrichment", "GeneRatio", "Count", "NES", "padj" (-log10 of the adjusted p-value). Default: "FoldEnrichment".

top.n

Numeric value indicating the maximum number of genesets to display for each side. Default: 10.

terms

Character vector indicating specific geneset IDs to display. When provided, top.n is ignored. Default: NULL.

padj.cutoff

Numeric value indicating the adjusted p-value threshold used to consider a geneset as significantly enriched. Default: 0.05.

top.by

String indicating the metric used to select the top genesets of each side. One among: "significance", "value". Default: "significance".

pos.color

String indicating the color of the bars of the first enrichment (positive side). Default: "steelblue".

neg.color

String indicating the color of the bars of the second enrichment (negative side). Default: "orange".

alpha.range

Numeric vector of length 2 indicating minimum and maximum value for the transparency, which is proportional to the significance. Individual values must be a number between 0 and 1. Default: c(0.3, 1).

add.counts

Logic value indicating whether labels with the counts of proteins ('count/geneset size') should be added at the end of each bar. Default: TRUE.

string.pattern.to.remove

String with a regular expression of a pattern to be removed from the geneset names. Default: NULL (no changes).

max.term.length

Numeric value indicating the maximal number of characters of the geneset names displayed on the y-axis (longer names are truncated). Default: 60.

perc.bleeding.x

Numeric value indicating the percentage of the full x-axis range to add on the left and on the right. Useful when labels are falling outside the x-max. Default: 8 (%).

axes.text.size

Numeric value indicating the font size of the axis text. Default: 10.

bar.width

Numeric value indicating the width of the bars. Default: 0.8.

title

String indicating the title of the plot, markdown formatting is supported. Default: NULL (built from the names of the list).

Value

A list with two elements: results (data.frame combining the results of the two enrichments) and divergent.plot (ggplot object).

Author

Sebastian Gregoricchio

Examples

# Plot together the ORA of the two sides of the same contrast
if (FALSE) { # \dontrun{
divergent <- divergent.enrichment(enrichment.list = list(`up-regulated` = ora.up,
                                                         `down-regulated` = ora.down),
                                  value = "FoldEnrichment",
                                  top.n = 10)
divergent$divergent.plot
} # }