ggplot2绘制GO注释二级分类统计图

>library(ggplot2) #载入ggplot2

>data=read.table(“GO.count.txt”,,header=T,sep=”\t”) #读取数据

>dorder = factor(as.integer(rownames(data)),labels=data$Description) #对数据按Description排序

>ggplot(data,aes(x=Description,y=Counts,fill=Class)) #定义X轴,Y轴的数据和颜色填充
+geom_bar(stat=”identity”,position=position_dodge(0.7),width=0.5,aes(x=dorder)) #定义柱形图的宽度和间距
+coord_flip() #转换横纵坐标
+scale_y_log10(breaks = c(1,10,100,1000)) #Y轴按log10排序,展示1,10,100,1000刻度
+scale_fill_discrete(name=”Ontology”) #修改legend的tittle
+theme(panel.background = element_rect(fill = “transparent”,colour = NA)) #清楚背景颜色
+xlab(“Term”) #修改X轴标签

《ggplot2绘制GO注释二级分类统计图》 GO_classification_L2.jpg

根据链接的指导,结合自己的数据实现上图,代码略作修改。
用R画GO注释二级分类统计图 | 生信菜鸟团 http://www.bio-info-trainee.com/771.html

这是我自己的数据
GOid Description Class Counts TotalGOid TotalGeneAnnotated
GO:0045735 nutrient reservoir activity molecular_function 39 3384 9842
GO:0060089 molecular transducer activity molecular_function 42 3384 9842
GO:0004871 signal transducer activity molecular_function 56 3384 9842
GO:0016209 antioxidant activity molecular_function 64 3384 9842
GO:0098772 molecular function regulator molecular_function 95 3384 9842
GO:0005198 structural molecule activity molecular_function 166 3384 9842
GO:0140110 transcription regulator activity molecular_function 180 3384 9842

GO:0005215 transporter activity molecular_function 478 3384 9842
GO:0003824 catalytic activity molecular_function 3805 3384 9842
GO:0005488 binding molecular_function 5401 3384 9842
GO:0019012 virion cellular_component 1 3384 9842
GO:0099080 supramolecular complex cellular_component 9 3384 9842
GO:0044421 extracellular region part cellular_component 35 3384 9842
GO:0031974 membrane-enclosed lumen cellular_component 54 3384 9842
GO:0005576 extracellular region cellular_component 81 3384 9842
GO:0044422 organelle part cellular_component 284 3384 9842
GO:0032991 macromolecular complex cellular_component 517 3384 9842
GO:0043226 organelle cellular_component 649 3384 9842
GO:0044425 membrane part cellular_component 702 3384 9842
GO:0005623 cell cellular_component 996 3384 9842
GO:0044464 cell part cellular_component 996 3384 9842
GO:0016020 membrane cellular_component 1219 3384 9842
GO:0022610 biological adhesion biological_process 1 3384 9842
GO:0008283 cell proliferation biological_process 1 3384 9842
GO:0098754 detoxification biological_process 1 3384 9842
GO:0019740 nitrogen utilization biological_process 1 3384 9842
GO:0048511 rhythmic process biological_process 1 3384 9842
GO:0002376 immune system process biological_process 5 3384 9842
GO:0015976 carbon utilization biological_process 6 3384 9842
GO:0040007 growth biological_process 13 3384 9842
GO:0051704 multi-organism process biological_process 43 3384 9842
GO:0000003 reproduction biological_process 52 3384 9842
GO:0022414 reproductive process biological_process 52 3384 9842
GO:0032502 developmental process biological_process 59 3384 9842
GO:0032501 multicellular organismal process biological_process 85 3384 9842
GO:0023052 signaling biological_process 183 3384 9842
GO:0071840 cellular component organization or biogenesis biological_process 265 3384 9842
GO:0050896 response to stimulus biological_process 501 3384 9842
GO:0065007 biological regulation biological_process 664 3384 9842
GO:0051179 localization biological_process 756 3384 9842
GO:0009987 cellular process biological_process 3122 3384 9842
GO:0008152 metabolic process biological_process 4225 3384 9842

    原文作者:木子愚溪
    原文地址: https://www.jianshu.com/p/58ec5d3ecf6b
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞