I have a tab separated text file as shown below
a 0.311 0.510 0.123 0.002 0.001 0.417 0.572 0.074 0.169
b 0.324 0.592 0.070 0.028 0.028 0.535 0.535 0.127 0.113
I am trying to use heatmap.2 function from gplots package and want to change the color key so that it ranges from 0 to 1
Following is my code:
d <- read.table("file.txt",sep="\t",header=F,row.names = 1)
colnames(d) <- c("-3","-2","-1","+1","+2","+3","+4","+5","+6")
d_matrix <- data.matrix(d)
colors<-seq(0,1,length.out=100)
heatmap.2(d_matrix,scale="none",col = redblue(75),trace="none",Colv = FALSE,Rowv = FALSE,breaks=colors)
But this gives me error:
Error in image.default(1:nc, 1:nr, x, xlim = 0.5 + c(0, nc), ylim = 0.5 + :
must have one more break than colour
I want to change to color key such that it ranges from 0 to 1. How can I do it in the function heatmap.2
I added breaks argument to the heatmap.2 function as suggested from this post here but no luck..