Tutorial:Showing up and down regulated GO and pathway using enrichR and ggplot2
0
20
Entering edit mode
5.5 years ago
ahmad mousavi ▴ 800

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()
ggplot2 RNA-Seq R • 6.3k views
ADD COMMENT
0
Entering edit mode

Check your image URL...

ADD REPLY
0
Entering edit mode
ADD REPLY
0
Entering edit mode

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 REPLY
0
Entering edit mode

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 REPLY
0
Entering edit mode

sorry for mistakes, I fixed them.

ADD REPLY
0
Entering edit mode

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 REPLY
0
Entering edit mode

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

ADD REPLY

Login before adding your answer.

Traffic: 2698 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6