Biostar Beta. Not for public use.
Tutorial: Showing up and down regulated GO and pathway using enrichR and ggplot2
18
Entering edit mode

Hi guys,

I have made this code for showing best 20 up and down GO or Kegg pathway in R using enrichR package, hope you enjoy the result:

library(ggplot2)
theme_set(theme_bw())  
library(enrichR)
dbs <- listEnrichrDbs()
# Set up & down variable
list_up <- c("g1","g2")
list_down <- c("x1","x2")
dbs <- c( "GO_Cellular_Component_2018" ,
         "GO_Biological_Process_2018" ,
       "GO_Molecular_Function_2018",
       "KEGG_2016")

eup <- enrichr(list_up, dbs)
edown <- enrichr(list_down, dbs)

up <- eup$KEGG_2016
down <- edown$KEGG_2016

up$type <- "up"
down$type <- "down"
up <- up [c(1:20),]
up <- up[order(up$Combined.Score), ]  # sort
down <- down [c(1:20),]
down <- down[order(down$Combined.Score), ]  # sort
down$Combined.Score <- (-1) * down$Combined.Score
gos <- rbind(down,up)
gos$Term <- factor(gos$Term, levels=gos$Term)
# Diverging Barcharts
ggplot(gos, aes(x=Term, y=Combined.Score , label=Combined.Score)) + 
  geom_bar(stat='identity', aes(fill=type), width=.5,position="dodge")  +
  scale_fill_manual(name="Expression", 
                    labels = c("Down regulated", "Up regulated"), 
                    values = c("down"="#00ba38", "up"="#f8766d")) + 
  labs(subtitle="Combined scores from Kegg pathways", 
       title= "Biological process") + 
  coord_flip()

enter image description here

Entering edit mode
0

Check your image URL...

ADD REPLYlink 15 months ago
Kevin Blighe
43k
Entering edit mode
Entering edit mode
0

have a look at variable dbs:

dbs<- listEnrichrDbs()

# Set up & down variable
list_up <- c("g1","g2")
list_down <- c("x1","x2")

dbs <- c( "GO_Cellular_Component_2018" ,
         "GO_Biological_Process_2018" ,
       "GO_Molecular_Function_2018",
       "KEGG_2016")

and you may want to change name="Mileage" to name="Expression" or name="Regulation" . Labels in the code and labels in the image do not match. Please either update the code or the image.

ADD REPLYlink 15 months ago
cpad0112
11k
Entering edit mode
0

Yes, the plot title is also misleading because you are not just enriching for KEGG pathways. You are also enriching for GO BP, MF, and CC, which mostly do not represent pathways. You should change your plot title.

ADD REPLYlink 15 months ago
Kevin Blighe
43k
Entering edit mode
0

sorry for mistakes, I fixed them.

ADD REPLYlink 15 months ago
ahmad mousavi
• 430
Entering edit mode
0

The plot title is still incorrect... You indicate that the plot contains KEGG pathways, however, you just list GO terms. For example, at the top, GO:0030198 is from GO Biological Process (GO BP) database, not KEGG.

ADD REPLYlink 15 months ago
Kevin Blighe
43k
Entering edit mode
0

This tutorial is very useful ahmad mousavi, however code and image need revisiting.

ADD REPLYlink 15 months ago
cpad0112
11k

Login before adding your answer.

Similar Posts
Loading Similar Posts
Powered by the version 2.0