I am trying to create a heatmap using the heatmap.2
package. My data has lot's of NaN
values in it, and what I would like to do is the following. Every time there is a NaN
value, simply have the cell be colored as light grey (or some other neutral color, maybe white), and all of the other values (which are log2 expression) to have a standard green/yellow/red coloring scheme. Here is my code that I have ben using:
heatmap.2(as.matrix(foo2[rowSums (abs(foo2)) != 0,]), col = redgreen, margins = c(12, 22), trace = "none", xlab = "Comparison", lhei = c(2, 8), scale = c("none"), symbreaks = min(foo2 = 0, na.rm = TRUE), na.color = "blue", cexRow = 0.5, cexCol = .7, main = "DE geness", Colv = F)
This works well when there is no NaN
values, but when the data has NaN
, I am getting an error which says:
Error in hclustfun(distfun(x)) : NA/NaN/Inf in foreign function call (arg 11)
Essentially, I would like to have it ignore the NaN
's in the data. I am not sure how to handle this. any help would be greatly appreciated.