进行GO和KEGG富集后,想使用dotplot
进行可视化,代码如下:
goEnrichment <- function(x, pvalueCutoff = 0.05, pAdjustMethod = "BH"){
en <- enricher(gene=x,
pvalueCutoff = pvalueCutoff,
pAdjustMethod = pAdjustMethod,
qvalueCutoff = 0.1,
TERM2GENE = term2gene,
TERM2NAME = go2term)
res <- en@result
res <- merge(res, go2ont, by.x="ID", by.y="go_id", all.x=T)
res <- res[order(res[,"p.adjust"]),]
return(na.omit(res))
}
GO_A9_12_up <- goEnrichment(A9_12_up)
dotplot(GO_A9_12_up)
报错
> dotplot(GO_A9_12_up)
Error in (function (classes, fdef, mtable) :
unable to find an inherited method for function ‘dotplot’ for signature ‘"data.frame"’
原因在于富集后的对象为enrichResult
,而在函数中,我将输出对象转换为了data.frame
。
如果使用dotplot(en)
则正确,或者重新创建enrichResult
对象
y <- new("enrichResult",
result=GO_A9_12_up)
dotplot(y)
即可正常出图
![](https://img.haomeiwen.com/i14719393/39b4d44fe1877273.png)
网友评论