enrichment_barplot: Enrichment bar plot with two directions

View source: R/enrichment_barplot.R

enrichment_barplotR Documentation

Enrichment bar plot with two directions

Description

This function creates a bar plot to visualize enrichment results, displaying both up-regulated and down-regulated terms or genes. The bar plot highlights the significance of each term or gene using -log10(p-value).

Usage

enrichment_barplot(
  up_terms,
  down_terms,
  terms = "Description",
  pvalue = "pvalue",
  group = "group",
  palette = "jama",
  title = "Gene Ontology Enrichment",
  width_wrap = 30,
  font_terms = 15
)

Arguments

up_terms

A data frame containing the information for up-regulated terms

down_terms

A data frame containing the information for down-regulated terms or genes.

terms

The column name in the data frames that specifies the term or gene description. By default, it is set to "Description".

pvalue

The column name in the data frames that specifies the p-value. By default, it is set to "pvalue".

group

The column name in the data frames that specifies the group or condition. By default, it is set to "group". If this column is not present in the data frames, the function will automatically assign a group based on the up_terms and down_terms. If the group is "Upregulated", it is assigned a value of 1, otherwise it is assigned a value of -1.

palette

The color palette to use for the barplot. By default, it is set to "jama".

title

The title for the barplot. By default, it is set to "Gene Ontology Enrichment".

width_wrap

The maximum width for wrapping the pathway names on the x-axis labels. By default, it is set to 30 characters.

font_terms

The font size for the x-axis and y-axis labels. By default, it is set to 15.

Value

A ggplot object representing the enrichment bar plot.

Author(s)

Dongqiang Zeng

Examples

# Example data frames
up_terms <- data.frame(
  Description = c("Pathway1", "Pathway2", "Pathway3"),
  pvalue      = c(0.001, 0.01, 0.05))

down_terms <- data.frame(
  Description = c("Pathway4", "Pathway5", "Pathway6"),
  pvalue      = c(0.005, 0.02, 0.03))

# Create enrichment bar plot using the function
p <- enrichment_barplot(
  up_terms   = up_terms,
  down_terms = down_terms,
  title      = "Custom Enrichment Plot")

print(p)

IOBR/IOBR documentation built on July 16, 2025, 8:12 p.m.