【问题标题】:change line width of dendrogram in pheatmap in R更改 R 中 pheatmap 中树状图的线宽
【发布时间】:2018-05-22 14:11:31
【问题描述】:

我使用存储在单细胞实验分析中的单细胞 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(内部版本 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)

【问题讨论】:

    标签: pheatmap


    【解决方案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()
    

    它会生成以下集群热图:

    【讨论】:

      猜你喜欢
      • 2020-04-30
      • 1970-01-01
      • 2019-09-17
      • 2014-05-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-02-10
      • 1970-01-01
      相关资源
      最近更新 更多