美文网首页R-作图
Pheatmap转ggplot2

Pheatmap转ggplot2

作者: Cdudu | 来源:发表于2020-10-10 09:46 被阅读0次

问题

pheatmap出的热图添加脚注、拼图等都非常麻烦

老的解决方案

由于pheatmap是基于grid画图的,因此可以用grid的语句添加注释,但是功能有限,例如不能换行

grid.text(label = 'Fig.3 Hierarchical clustering analysis of DEGs.', 
          x=0.5 , y=0.065,
          gp = gpar(fontsize = 10))

新的方案

用ggplotify将pheatmap转化为ggplot2

#pheatmap出图
d <- matrix(rnorm(100), ncol=10)
library(pheatmap)
p <- pheatmap(d)

#转换
require(ggplotify)
g = as.ggplot(p)

#随后就可以将g当作一个ggplot2的对象进行图层添加了

参考资料

Y叔 听说你想把pheatmap和ggplot2拼在一起

相关文章

网友评论

    本文标题:Pheatmap转ggplot2

    本文链接:https://www.haomeiwen.com/subject/pxedpktx.html