GOBar Plot

Authors

[Editor] Hu Zheng;

[Contributors]

The gobar plot is used to display Z-score coloured barplot of terms ordered alternatively by z-score or the negative logarithm of the adjusted p-value.

Setup

  • System Requirements: Cross-platform (Linux/MacOS/Windows)

  • Programming language: R

  • Dependent packages: GOplot

# Install packages
if (!requireNamespace("GOplot", quietly = TRUE)) {
  install.packages("GOplot")
}

# Load packages
library(GOplot)

Data Preparation

The loaded data are the results of GO enrichment with seven columns: category, GO id, GO term, gene count, gene name, logFC, adjust pvalue and zscore.

# Load data
data <- read.delim("files/Hiplot/077-gobar-data.txt", header = T)

# Convert data structure
colnames(data) <- c("category","ID","term","count","genes","logFC","adj_pval","zscore")
data <- data[data$category %in% c("BP","CC","MF"),]
data <- data[!is.na(data$adj_pval),]
data$adj_pval <- as.numeric(data$adj_pval)
data$zscore <- as.numeric(data$zscore)

# View data
head(data)
  category         ID              term count  genes        logFC adj_pval
1       BP GO:0007507 heart development    54   DLC1 -0.970787511 2.17e-06
2       BP GO:0007507 heart development    54   NRP2 -1.515317303 2.17e-06
3       BP GO:0007507 heart development    54   NRP1 -1.141231543 2.17e-06
4       BP GO:0007507 heart development    54   EDN1  1.381300593 2.17e-06
5       BP GO:0007507 heart development    54 PDLIM3 -0.887693887 2.17e-06
6       BP GO:0007507 heart development    54   GJA1  -0.81794802 2.17e-06
      zscore
1 -0.8164966
2 -0.8164966
3 -0.8164966
4 -0.8164966
5 -0.8164966
6 -0.8164966

Visualization

# GOBar Plot
p <- GOBar(data, display = "multiple", order.by.zscore = T,
           title = "GO Enrichment Barplot ", 
           zsc.col = c("#EF8A62","#F7F7F7","#67A9CF")) + 
    theme(plot.title = element_text(hjust = 0.5),
          axis.text.x = element_text(size = 8))

p
FigureΒ 1: GOBar Plot

As shown in the example figure, the x-axis represent each GO term, the y-axis represent the -log(adj_pvalue), each bar is colored by the z-score. If display is used to facet the plot the width of the panels will be proportional to the length of the x scale.