R语言学习之GO富集分析结果可视化(柱状图、网络图)

读取gene symbol

library(clusterProfiler)

library(org.Hs.eg.db)

input <- read.table("gene.csv",sep = ",",header = T)

把symbol转换为ENTREZID

genetransform <- bitr(input$target,

              fromType = "SYMBOL",

              toType = c("ENSEMBL","ENTREZID"),

              OrgDb =org.Hs.eg.db )

#注意:此处物种是人类

GO富集分析

Go <- enrichGO(gene = genetransform$ENTREZID,

                OrgDb = org.Hs.eg.db,

                pvalueCutoff =0.05,

                qvalueCutoff =0.05,

                readable = TRUE)

head(Go)

将GO富集结果写出到文件

write.table(Go,file="GO RESULT.txt",sep="\t",

            quote=F,row.names = F)

#把结果保存为R数据。

save(Go,file ="Go result.Rda" )

###################################################################

绘制柱状图

library(ggplot2)

library(org.Hs.eg.db)

library(clusterProfiler)

library(cowplot)

画图

barplot(Go,showCategory=20,color="pvalue")

导出图

tiff(file="Go image.tiff",width=35,height = 22,units = "cm",

    compression = "lzw",bg="white",res=300)

barplot(Go,showCategory=20,color="pvalue")

dev.off()

####################################################################

绘制网络图

library(ggplot2)

library(org.Hs.eg.db)

library(clusterProfiler)

library(cowplot)

install.packages("ggnewscale")

library(ggnewscale)

cnetplot(Go,circular=T,colorEdge=T)
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容