GO功能注释条目图

在这里插入图片描述

> go <- read.csv("go.csv",header = T)    #Go 条目一般只选择最显著的前10个或20个Term来绘图#
> head(go)
            Ontology
1 Biological process
2 Biological process
3 Biological process
4 Biological process
5 Biological process
6 Biological process
                                                                  Term      GO_ID
1                                                  signal transduction GO:0007165
2 positive regulation of transcription from RNA polymerase II promoter GO:0045944
3 negative regulation of transcription from RNA polymerase II promoter GO:0000122
4                                                        cell adhesion GO:0007155
5                            positive regulation of cell proliferation GO:0008284
6                  positive regulation of transcription, DNA-templated GO:0045893
  Input_number Percentage
1           72   8.062710
2           66   7.390817
3           64   7.166853
4           46   5.151176
5           41   4.591265
6           40   4.47928

在这里插入图片描述

> library(ggplot2)
> go_sort <- go[order(go$Ontology,-go$Percentage),]#根据go$Percentage和go$Percentage排序

在这里插入图片描述

> m <- go_sort[go_sort$Ontology=="Molecular function",][1:10,]
> head(m)
             Ontology
31 Molecular function
32 Molecular function
33 Molecular function
34 Molecular function
35 Molecular function
36 Molecular function
                                                           Term      GO_ID
31                                              protein binding GO:0005515
32                            protein homodimerization activity GO:0042803
33 transcription factor activity, sequence-specific DNA binding GO:0003700
34                                          calcium ion binding GO:0005509
35                                    identical protein binding GO:0042802
36                                sequence-specific DNA binding GO:0043565
   Input_number Percentage
31          455  50.951848
32           60   6.718925
33           59   6.606943
34           58   6.494961
35           49   5.487122
36           41   4.591265
> c <- go_sort[go_sort$Ontology=="Cellular component",][1:10,]
> b <- go_sort[go_sort$Ontology=="Biological process",][1:10,]
> slimgo <- rbind(b,c,m)  #把b,c,m合并到了一起#

在这里插入图片描述


> slimgo$Term = factor(slimgo$Term,levels = slimgo$Term) # 将term列转换为因子#
> class(slimgo$Term)
[1] "factor"
> colnames(slimgo)  #ggplot2用到好多列名,先输出来#
[1] "Ontology"     "Term"         "GO_ID"        "Input_number" "Percentage"  
 
> pp <- ggplot(data = slimgo,mapping = aes(x=Term,y=Percentage,fill=Ontology))
#fill=Ontology,意为Ontology为填充色#
> pp

在这里插入图片描述

 > pp+geom_bar(stat = "identity")

在这里插入图片描述

> pp+geom_bar(stat = "identity")+coord_flip()  #Term太多了,反转一下x,y轴#

在这里插入图片描述

#term是从小到大排列,习惯从大到小排列#
> pp+geom_bar(stat = "identity")+coord_flip()+scale_x_discrete(limits=rev(levels(slimgo$Term)))

在这里插入图片描述

> pp+geom_bar(stat = "identity")+coord_flip()+scale_x_discrete(limits=rev(levels(slimgo$Term)))+guides(fill=FALSE)
#去掉了图列#

在这里插入图片描述

> pp+geom_bar(stat = "identity")+coord_flip()+scale_x_discrete(limits=rev(levels(slimgo$Term)))+guides(fill=FALSE)+theme_bw()
#切换成黑白背景的主题#

在这里插入图片描述
链接:https://pan.baidu.com/s/1Yp4XMHxGrjfaOPNM-PCg_w
提取码:gw3x
复制这段内容后打开百度网盘手机App,操作更方便哦
《R语言与生物信息绘图》课程笔记

  • 0
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

紫霄zixiao

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值