Reputation: 125
I'm trying to get a heatmap to work in R, but I've noticed some rather erratic behaviour of the colour maps. Small extract from the data:
data = matrix(c(0,0,1,1,1,2,2,2,2,2,1,1,1,0,1,1,1,1,1,1,0,0,0,0,0),5,5,byrow=TRUE)
This yields a 5x5 matrix, with three of the rows being occupied by all 2's, all 1's and all 0's respectively. However, when I try to apply a colour map, I get pure white on all three of those rows, instead of different colours as expected.
library(RColorBrewer)
heatmap(data,col=brewer.pal(3,'RdBu'),Colv=NA,Rowv=NA)
It's not the colour map of choice being wonky, I observe analogous behaviour when I leave the default colour map on. What's going on here, how do I make this go away? I want the 0's to be one colour, the 1's to be one colour, the 2's to be one colour. In the grand scope of things, I also need to be able to add separately computed dendrograms to the rows/columns, with the dendrograms not being convertible to hclusts because of reasons beyond my control, what makes pheatmap not an immediately viable solution.
Upvotes: 0
Views: 124
Reputation: 125
Immediately after submitting this question, I found the scale option of the heatmap. The solution thus becomes:
heatmap(data,col=brewer.pal(3,'RdBu'),Colv=NA,Rowv=NA,scale="none")
Apologies, I'll show myself out
Upvotes: 1