使用R包topGO绘制GO有向无环图

GO有向无环图

topGO 官方说明链接:http://www.bioconductor.org/packages/release/bioc/html/topGO.html

实战代码

##R脚本
biocLite("topGO")
biocLite("ALL")
biocLite('hgu95av2.db')
biocLite('Rgraphviz')
library(topGO)
library(ALL)

data(ALL)
data(geneList)
affyLib <- paste(annotation(ALL), "db", sep = ".")
library(package = affyLib, character.only = TRUE)

sum(topDiffGenes(geneList))
##ontology参数可以选择BP,CC,MF
sampleGOdata <- new("topGOdata",
                    description = "Simple session", ontology = "BP",
                    allGenes = geneList, geneSel = topDiffGenes,
                    nodeSize = 10,
                    annot = annFUN.db, affyLib = affyLib)

resultFisher <- runTest(sampleGOdata, algorithm = "classic", statistic = "fisher")
resultKS <- runTest(sampleGOdata, algorithm = "classic", statistic = "ks")
resultKS.elim <- runTest(sampleGOdata, algorithm = "elim", statistic = "ks")

allRes <- GenTable(sampleGOdata, classicFisher = resultFisher,
                   classicKS = resultKS, elimKS = resultKS.elim,
                   orderBy = "elimKS", ranksOf = "classicFisher", topNodes = 10)
pValue.classic <- score(resultKS)
pValue.elim <- score(resultKS.elim)[names(pValue.classic)]

#保存图片
pdf('result.pdf',width = 10,height = 10)
showSigOfNodes(sampleGOdata, score(resultKS.elim), firstSigNodes = 5, useInfo ='all')
dev.off()

绘制结果

使用R包topGO绘制GO有向无环图_第1张图片

你可能感兴趣的:(R)