Tutorial: Showing up and down regulated GO and pathway using enrichR and ggplot2
19
gravatar for ahmad mousavi
14 months ago by
ahmad mousavi450
Royan Institute, Tehran, Iran
ahmad mousavi450 wrote:

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

rna-seq ggplot2 tutorial R • 1.9k views
ADD COMMENTlink modified 12 months ago • written 14 months ago by ahmad mousavi450

Check your image URL...

ADD REPLYlink written 13 months ago by Kevin Blighe52k

How to add images to a Biostars post

ADD REPLYlink written 12 months ago by lakhujanivijay4.7k

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 modified 12 months ago • written 12 months ago by cpad011212k

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 written 12 months ago by Kevin Blighe52k

sorry for mistakes, I fixed them.

ADD REPLYlink written 12 months ago by ahmad mousavi450

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 modified 12 months ago • written 12 months ago by Kevin Blighe52k

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

ADD REPLYlink modified 12 months ago • written 12 months ago by cpad011212k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1216 users visited in the last hour