gpt4 book ai didi

r - 如何将键值和图例放在热图的底部

转载 作者:行者123 更新时间:2023-12-05 04:58:27 26 4
gpt4 key购买 nike

有没有人告诉我如何使用 pheatmap 将表达式键索引和图例键显示在热图的底部?您可以使用以下代码生成热图。非常感谢!

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 = "")
annotation_col = data.frame(
CellType = factor(rep(c("CT1", "CT2"), 5)), Time = c("A", "B", "C","D","E"))
rownames(annotation_col) = paste("Test",1:10, sep = "")
ann_colors = list(
Time = c(A = "white", B= "firebrick", C= "#fdbb84",D = "#e34a33", E = "red"),
CellType = c(CT1 = "#1B9E77", CT2 = "#D95F02"))

library("pheatmap")
pheatmap(test, annotation_col = annotation_col, annotation_colors = ann_colors)

最佳答案

pheatmap 似乎没有提供控制图例位置的能力。

可以在此处找到绘制热图的代码 https://github.com/raivokolde/pheatmap .

查看 R/pheatmap-package.r 文件。

那个图例似乎是硬编码的,参见# Legend positiondraw_legend = function(color, breaks, legend, ...

关于r - 如何将键值和图例放在热图的底部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63951276/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com