Entering edit mode
6.2 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()
Check your image URL...
How to add images to a Biostars post
have a look at variable dbs:
and you may want to change
name="Mileage"
toname="Expression"
orname="Regulation"
. Labels in the code and labels in the image do not match. Please either update the code or the image.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.
sorry for mistakes, I fixed them.
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.
This tutorial is very useful ahmad mousavi, however code and image need revisiting.