You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用clusterProfiler绘制富集分析条形图时出现报错求助

解决clusterProfiler绘制GSEA条形图报错问题

问题说明

使用clusterProfiler完成GSEA富集分析后,dotplot、ridgeplot等图均可正常生成,但执行barplot(gse, split = "ONTOLOGY")时触发报错:

Error in barplot.default(gse, split = "ONTOLOGY") :
'height' must be a vector or a matrix

报错原因

gse是GSEA分析返回的gseaResult类型对象,R基础包的barplot.default函数被优先调用,它无法识别gseaResult这类S4对象;而enrichplot包中专门处理GSEA结果的barplot.gseaResult方法未被正确触发,通常是命名空间冲突或包加载顺序导致。

解决方案

方案1:明确指定调用enrichplot包的barplot方法

修改代码为:

enrichplot::barplot(gse, split = "ONTOLOGY") + 
  facet_grid(ONTOLOGY~., scale = "free") + 
  ggtitle("Barplot for GO")

通过enrichplot::强制调用对应包的方法,避免与基础包的barplot函数冲突。

方案2:重新加载enrichplot包

如果之前加载的其他包覆盖了barplot函数,先重新加载enrichplot再绘图:

library(enrichplot)
barplot(gse, split = "ONTOLOGY") + 
  facet_grid(ONTOLOGY~., scale = "free") + 
  ggtitle("Barplot for GO")

补充说明

GSEA结果的条形图逻辑与普通ORA富集分析不同,enrichplot的barplot.gseaResult会基于富集得分(ES)或标准化富集得分(NES)绘制,而基础包的barplot仅支持向量或矩阵输入,因此必须确保调用的是enrichplot提供的专用方法。

内容的提问来源于stack exchange,提问作者assemkadry

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.20 10:10:00