1

我是新手,我有一个生物信息学数据如下

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")

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

在此处输入图像描述

但我想把图例改成下面

在此处输入图像描述

4

1 回答 1

1

我想这就是你要找的。基本上,您需要扩展颜色图的范围,使其关于零对称。

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
)

在此处输入图像描述

比。不使颜色图居中

在此处输入图像描述

于 2017-01-13T19:10:25.033 回答