3

Pheatmap only creates a square plot when legend=FALSE. I have tried using par() to allow more oma() and mar() space without luck. The legend is also really big and i cannot find any documentation on reducing this or changing its position. The first plot doesn't have a dendrogram fitted but this is irrelevant to the sizing issue. The same happens regardless of the clustering. I would appreciate any comments

png(filename="tmpfile.png", width=1500, height=1500, res=500)
pheatmap(res, cluster_rows=FALSE, cluster_cols=FALSE, main="Default_clust", annotation=res2, color = rainbow(n, start=.7, end=.1), show_rownames=FALSE, show_colnames=FALSE, border_col=NA, fontsize=6)
dev.off()

Square plot with no legend plot has legend but is not square

4

3 回答 3

4

关于平方图的问题实际上与绘制皮尔逊相关性非常相关。我来到这里希望得到答案,最后我想出了一个解决方法来手动设置单元格宽度,例如:

pheatmap(...,     
cellheight=3, cellwidth = 3)

但我想要一个更好的方法。

于 2020-05-06T10:11:11.817 回答
2

使用建议的示例,这就是我得到的:

test = matrix(rnorm(200), 20, 10)
test[1:10, seq(1, 10, 2)] = test[1:10, seq(1, 10, 2)] + 3
test[11:20, seq(2, 10, 2)] = test[11:20, seq(2, 10, 2)] + 2
test[15:20, seq(2, 10, 2)] = test[15:20, seq(2, 10, 2)] + 4
colnames(test) = paste("Test", 1:10, sep = "")
rownames(test) = paste("Gene", 1:20, sep = "")

# Draw heatmaps
pheatmap(test, cluster_row = FALSE, legend_breaks = -1:4, legend=T, legend_labels = c("this is a     really long item", "1e-4", "1e-3", "1e-2", "1e-1", "1"))

标签和图例现在可见:

在此处输入图像描述

于 2014-08-26T00:32:13.873 回答
2

更改图例大小的一种巧妙方法是设置字体大小。也就是说,pheatmap 中的图例大小与字体大小成正比。然后,您可以独立设置行和列标签大小(fontsize_row、fontsize_col)。这种方法的唯一问题是你的注释标签当然也会被放大或缩小,但看起来你无论如何都没有使用它们。

另外,很确定您的热图是方形的,因为您的 png 是方形的。

于 2017-11-30T21:31:44.093 回答