更改 R 中 pheatmap 中树状图的线宽

2024-01-11

我使用存储在单细胞实验测定中的单细胞 RNA-seq 数据,使用 R 中的 pheatmap 对约 11.3000 个表达基因(不是聚类样本)进行分层聚类,以显示数据的异质性。我需要输出图像为 2 x 4 英寸,这使得树状图变得模糊。是否可以减少用于树状图的线宽?我尝试通过gpar设置线宽,但它似乎没有改变

会话信息() R版本3.4.1 (2017-06-30) 平台:i386-w64-mingw32/i386(32位) 运行环境: Windows >= 8 x64 (build 9200) pheatmap_1.0.8

R code

gpar(lwd = 0.5)

pheatmap(assay(sce.tpm),  cellwidth = 10, cellheight= 0.009, fontsize = 5, 
fontsize_row = 6, fontsize_col = 6, 
scale = "row", cluster_cols = F, cluster_rows = T, 
clustering_distance_rows = "euclidean", clustering_method = "average"
color = colorRampPalette(c("blue", "white", "red"))(256), 
show_colnames = T, show_rownames = F)

您可以直接操作 pheatmap 调用返回的 gtable 对象。每个grob都有一个gp参数是一个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()

它生成以下聚类热图:

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

更改 R 中 pheatmap 中树状图的线宽 的相关文章

随机推荐