为什么我不能使用"标签"更改pheatmap中图例的标签。句子?

时间:2016-10-19 15:13:03

标签: r legend pheatmap

我是新手,我有生物信息学数据,如下所示

Symbol  p53s_svsWT  9B1vsWT G3_3vsWT    G1_3vsWT    G5_2vsWT    G3_2vsWT    G1_2vsWT
Aldh1a7 -4.2159 -4.3323 -4.4237 -6.6921 -1.8665 -2.3748 -2.4946
Cobl    -2.9233 -1.7885 -3.8384 -4.2456 -2.2089 -3.0172 -2.7454
Ngf -1.9121 -2.1857 -2.7835 -4.0677 -2.4026 -2.3534 -2.8909

在pheatmap中,我无法更改图例标签,标签始终是默认的。

这是我的代码

data<-read.csv("4of6.csv", header=TRUE, row.name=1)
library(pheatmap)
pheatmap(data, legend_breaks= -6:1,legend=TRUE, 
         legend_labels = c("-6","-5","-4","-3","-2","-1","0","1"), cellwidth = 20, 
         cellheight = 20, fontsize = 15,filename = "46.pdf")

通过使用上面的代码,图例显示如下

enter image description here

但我想将传奇改为下面的

enter image description here

1 个答案:

答案 0 :(得分:0)

我认为这就是你要找的东西。基本上,您需要扩展色图的范围,使其对称为零。

library(pheatmap)
library(RColorBrewer)

mymat <- matrix(rnorm(600, mean=-5, sd=2), ncol=12)
colnames(mymat) <- c(rep("treatment_1", 3), rep("treatment_2", 3), rep("treatment_3", 3), rep("treatment_4", 3))
rownames(mymat) <- paste("gene", 1:dim(mymat)[1], sep="_")

pheatmap(mymat, color = colorRampPalette(rev(brewer.pal(n = 7, name ="RdYlBu")))(100),
         breaks = seq(min(mymat), abs(min(mymat)), length.out = 101),
         legend_breaks = c(-10, -8,-6,-4,-2,0,2,4,6,8,10),
         cluster_rows = FALSE,
         cluster_cols = FALSE,
         cellheight = 6,
         cellwidth = 20,
         border_color=NA,
         fontsize_row = 6
)

NTS

Vs以上。没有居中的色彩图

enter image description here