在R中的pheatmap中更改树形图的线宽

时间:2018-05-22 14:11:31

标签: pheatmap

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

sessionInfo() R版本3.4.1(2017-06-30) 平台:i386-w64-mingw32 / i386(32位) 运行于:Windows> = 8 x64(build 9200) pheatmap_1.0.8

R代码

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)

1 个答案:

答案 0 :(得分:1)

您可以直接操纵通过pheatmap调用返回的gtable对象。每个grob都有一个gp对象的gpar参数。

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()

它生成以下聚类的热图:

pheatmap_dendrogram_adjust