问题描述
我正在尝试显示矩阵中每一行的颜色(最小到最大渐变):
[1,] 8 12 11 5 24
[2,] 1 2 7 0 8
[3,] 53 99 1501 15 9859
[4,] 59 24 19 19 32
[5,] 4 2 11 0 68
[6,] 4 9 177 2 710
[7,] 2 1 2 2 3
[8,] 0 5 133 0 2195
[9,] 3 3 2 1 15
[10,] 0 1 0 0 14
[11,] 0 3 21 0 17
[12,] 2 1 2 0 6
[13,] 11 26 22 3 16
[14,] 6 38 217 1 354
[15,] 3 10 17 0 68
[16,] 3 3 12 2 19
[17,] 7 5 26 1 40
[18,] 1 0 6 0 27
[19,] 1 0 37 0 434
[20,] 30 15 20 9 27
我的代码如下:
RT<-read.table("tmp",header=FALSE,sep="\t");
mat <-data.frame(RT)
pheatmap(mat,scale = "row",cluster_cols=FALSE,cluster_rows = FALSE,row.names =FALSE);
dev.off()
我收到了以下图片:
正如您在第 2 行中看到的,最大值需要为红色,但它是橙色的,因为第 2 行的第 3 列和第 5 列具有相似的值。对于每行的最大值和最小值之间的值,我想做最大值为红色,最小值为蓝色,以及红色、黄色和蓝色之间的渐变。 0 永远是蓝色的。只有相同的值才能获得相同的颜色。我尝试了 R: Row scaling not working correctly for heatmap 的其他解决方案,但对我不起作用。请帮忙。