r - 如何将键值和图例放在热图的底部
问题描述
有没有人告诉我如何使用 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 position
参阅 draw_legend = function(color, breaks, legend, ...
推荐阅读
- sql - Sql如何有一个重复的数字,直到某个数字然后重新开始
- go - args ...interface{} 对方法的参数到底意味着什么?
- ionic-framework - 连接到 Ionic Deploy 的 CORS 问题
- javascript - 如何组合多个正则表达式
- excel - 范围参数应用程序定义或对象定义错误
- arrays - 更新嵌套在数组中的多个级别的文档
- html - 将类添加到具有动态值的 div
- javascript - 在获取内容之前检查文件是否存在
- lisp - 定义原子函数
- google-cloud-dataflow - 处理卡在步骤中 将突变写入 Cloud Spanner 到 Spanner 而不在状态过程中输出或完成