R 使用pheatmap中热图的特定值进行打印

R 使用pheatmap中热图的特定值进行打印,r,plot,heatmap,pheatmap,R,Plot,Heatmap,Pheatmap,我有这样一个数据框: gene s1 s2 s3 1 -3.83 -8.17 -8.59 2 0.33 -4.51 -7.27 3 0.15 -5.26 -6.2 4 -0.08 -6.13 -5.95 5 -1.15 -4.82 -5.75 6 -0.99 -4.11 -4.85 7 0.42 -4.18 -4.54 8 -0.32 -3.43 -4.4 9 -0.72 -3

我有这样一个数据框:

gene    s1  s2  s3
1   -3.83   -8.17   -8.59
2   0.33    -4.51   -7.27
3   0.15    -5.26   -6.2
4   -0.08   -6.13   -5.95
5   -1.15   -4.82   -5.75
6   -0.99   -4.11   -4.85
7   0.42    -4.18   -4.54
8   -0.32   -3.43   -4.4
9   -0.72   -3.37   -4.39
我想用pheatmap制作一张热图,如果任何东西低于-4,它应该是绿色的,超过+4的应该是红色的,中间的东西应该是红色/绿色。我也不想扩展我的数据,也不想进行集群。到目前为止,我在R中有以下代码:

d <- read.table("test.txt", header = TRUE, sep = "\t", row.names = 1, quote = "")

pheatmap(as.matrix(d),  # matrix
         scale = "none",         # z score scaling applied to rows 
         cluster_cols=FALSE,    # do not cluster columns
         cluster_rows = FALSE,
         treeheight_row=0,      # do not show row dendrogram
         show_rownames=FALSE,   # do not show row names i.e gene names
         main = "test.txt",
         color = colorRampPalette(c("#0016DB","#FFFFFF","#FFFF00"))(50),
         )

d
d非常感谢,这非常有效。有一个问题是我想要多少色调<代码>403-2=401
。我可以为调色板添加这个吗<代码>我的调色板@user3138373右。根据您对阴影的要求,您可以将
seq(-4,4,by=0.01)
更改为例如
seq(-4,4,by=0.1)
。是的,你可以定义你的中间颜色。