Yes, I have noticed that heatmap.2 is still under development. I looked at the parameters yesterday and there are many more than when I first began to use it ~10 years ago. It is still not at the breadth of features of ComplexHeatmap, though.
Hello
I'm using the following code to generate a heatmap for my data, like this
library(gplots)
getwd()
row.names(fold_change_cuttoff_at_2_cuttoff_at_2) <- fold_change_cuttoff_at_2$Gene
y <-data.matrix(fold_change_cuttoff_at_2)
y <- y[1:2162, 2:13]
y
?heatmap.2
??heatmap.2
heatmap.2(y, main = "Secretome Profile", trace ="none", margins = c(10,12))
yb <- colorRampPalette(c("white","yellow","orange","darkorange","red","darkred","black"))(n = 299)
heatmap.2(y, col=yb, main = "Secretome Profile", trace ="none", margins = c(5,15), cexRow = 0.7)
However, because I have many null values (some genes appear as differentially expressed in some tumors, but not others) I get a pretty weird looking heatmap, as I replaced NAs with 0s. So, is there anyway to generate a heatmap anyway, but with the NAs as, say, gray?
2 answers
heatmap function in complexheatmap takes na_col for NA color.
heatmap.2(y, col=yb, main = "Secretome Profile", trace ="none", na.color="gray", margins = c(5,15), cexRow = 0.7)
Thank you for the help. I tried used the argument in the code above, but when I run it, it gives me the following error message:
Error in hclustfun(distr) : NA/NaN/Inf in foreign function call (arg 11)
So I have no idea what to do
NA/NaN/Inf in foreign function call
Try googling the error message. It is pretty specific and will give you leads on what to look for in your data.
You can use heatmap.2 breaks parameter to map between your 299 color shades and your fold-change values. Next assign NA to an "unused" figure (either larger than your maximum fold change or, in your case, possibly lower than your limit of 2). Finally, map this NA-figure to gray.
In my experience, the visual outcome is weird as well although scientifically more accurate.
Log in to answer this question.
I do this by replacing
NAwith"NA"and assigning a color to"NA". Maybe there's a better way?