change line width of dendrogram in pheatmap in R

浪子不回头ぞ 提交于 2019-12-06 11:25:27

You can directly manipulate the gtable object returned by the pheatmap call. Each grob has a gp parameter that is a gpar object.

library(pheatmap)
library(grid)

set.seed(42)
ph <- pheatmap(matrix(runif(100), nrow = 10), silent = TRUE)

ph$gtable$grobs[[1]]$gp <- gpar(lwd = 5)
ph$gtable$grobs[[2]]$gp <- gpar(col = 'blue')

png('pheatmap_gpar.png', height = 400, width = 400)
grid.newpage()
grid.draw(ph$gtable)
dev.off()

It generates the following clustered heat map:

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!