GO富集分析可视化:R语言GOplot包
2019-12-09 本文已影响0人
小明的数据分析笔记本
找R语言做弦图的教程的时候发现了这个包:GOplot。其主要功能是可视化GO富集分析的结果。自己应该会用得到。
第一步是学习其帮助文档中的例子,然后学习如何准备自己的数据,并利用这个包中的函数来绘图
查看帮助文档
library(GOplot)
help(package="GOplot")
重复帮助文档中的教程
data(EC)
class(EC)
dim(EC$david)
dim(EC$genelist)
circ<-circle_dat(EC$david,EC$genelist)
class(circ)
head(circ)
category ID term count genes
1 BP GO:0007507 heart development 54 DLC1
2 BP GO:0007507 heart development 54 NRP2
3 BP GO:0007507 heart development 54 NRP1
4 BP GO:0007507 heart development 54 EDN1
5 BP GO:0007507 heart development 54 PDLIM3
6 BP GO:0007507 heart development 54 GJA1
logFC adj_pval zscore
1 -0.9707875 2.17e-06 -0.8164966
2 -1.5153173 2.17e-06 -0.8164966
3 -1.1412315 2.17e-06 -0.8164966
4 1.3813006 2.17e-06 -0.8164966
5 -0.8876939 2.17e-06 -0.8164966
6 -0.8179480 2.17e-06 -0.8164966
我们自己的数据按照这个格式准备应该就可以
- 柱形图
GOBar(subset(circ,category=="BP"))

横坐标字体有点大,试了一下用ggplot2的主题来调节
GOBar(subset(circ,category=="BP"))+
theme(axis.text.x = element_text(size=5))

猜测这个GOBar函数其实就是ggplot2柱形图函数的封装
- 气泡图
GOBar(subset(circ,category=="BP"))

试了一下一下调节图例的位置,没有成功
GOBar(subset(circ,category=="BP"))+
theme(axis.text.x = element_text(size=5))
- 气泡图分面
GOBubble(circ, title = 'Bubble plot', colour = c('orange', 'darkred', 'gold'), display = 'multiple', labels = 3)

- 背景还可以添加颜色
GOBubble(circ, title = 'Bubble plot with background colour', display = 'multiple', bg.col = T, labels = 3)

以上的图用ggplot2应该也可以实现,但这个包可以一条命令出图,非常方便
接下来是弦图
chord <- chord_dat(circ, EC$genes, EC$process)
head(chord)
pdf("chord1.pdf",height = 13,width = 13)
GOChord(chord, space = 0.02, gene.order = 'logFC', gene.space = 0.25, gene.size = 5)
dev.off()

热图
GOHeat(chord[,-8], nlfc = 0)

聚类图
GOCluster(circ, EC$process, clust.by = 'logFC', term.width = 2)

韦恩图
l1 <- subset(circ, term == 'heart development', c(genes,logFC))
l2 <- subset(circ, term == 'plasma membrane', c(genes,logFC))
l3 <- subset(circ, term == 'tissue morphogenesis', c(genes,logFC))
GOVenn(l1,l2,l3, label = c('heart development', 'plasma membrane', 'tissue morphogenesis'))

对这个包的简单评价:一条函数出图非常方便,但是如何准备自己的数据可能会比较麻烦!
欢迎大家关注我的公众号
小明的数据分析笔记本
