This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Ggplot for Gene ontology data

Hello all I need one help in plot ggplot Suppose I have file containing 1 column the terms like biological processes,molecular function, cellular components 2 column has count of gene having particular function 3 column David ID GOxxxxxx 4 column function of set of gene for eg RNase activity etc I want to plot ggplot having X axis David I'd Y axis count But my geom_bar colour should be different for molecular function, cellular components, biological processes How should I proceed Please help

ggplot geneontology rna-seq
ggplot(d, aes(id, count, fill=ontology)) + geom_col()

I want to plot bar using ggplot with different color for biological processes molecular function and cellular process

I guess you know nothing about ggplot2.

a bar plot (geom_col(), which is a short cut of geom_bar(stat='identity')) that map id to x and count to y and use ontology to color the bars.

go to read some docs before posting a question with no idea of what you (and someone else) are talking about.

Ok thanks for your suggestions and answer

2 answers

require(clusterProfiler)
require(ggplot2)

data(geneList)
de = names(geneList)[1:100]
x=enrichGO(de, OrgDb='org.Hs.eg.db', ont='ALL')

ggplot(x, aes(ID, Count, fill=ONTOLOGY), split='ONTOLOGY') + geom_col()  + 
    theme(axis.text.x=element_text(angle=-40, hjust=0)) + facet_grid(.~ONTOLOGY, scale="free_x")

Hi guangchuang yu Thanks for this !! I was searching for this few month ago same kind of plot but ended up with overlaping value in x-axis It would be appreciable if you help me so that i can apply the same for my future work Thanks

Please use ADD COMMENT/ADD REPLY when responding to existing posts to keep threads logically organized.

Log in to answer this question.