Hi Kevin, thanks for your help and quick response, looking at your example helped solve the problem. I guess I was trying to use one less color in the gradient than needed for the number of breaks. Using your example I changed it to "col=colorRampPalette(c("yellow", "orange", "red"))(100)" and this seems to have resolved the issue. Thank you for your time and help, stay safe and well.
Hello,
I'd like to create a continuous gradient of warm colors (e.g., yellow-orange-red) from the values 4-9 using heatmap2. Can anyone please suggest code to replace "col=bluered(100)" in the code below?
> heatmap.2(as.matrix(dataSub), Colv=FALSE, Rowv=FALSE, trace="none", dendrogram="none", scale="none", density.info="none", breaks = seq(4,9, length.out = 101), col=bluered(100), cexCol=0.75,margins=c(15,24))
I've tried colorRampPalette but can't seem to get what I'm looking for.
Thanks very much for any help.
2 answers
You likely need to scale your data, or set the breaks to match the data distribution that you currently have.
If you simply set scale = 'row', for all intents and purposes, that may improve the heatmap from an aesthetics standpoint. This will result in heamap.2() Z-scaling your data per row. However, your current chosen values for breaks seems strange to me.
Another way to do this is to scale your input data via:
heatmap.2(
t(scale(t(dataSub))),
...)
This has the exact same effect as setting scale = 'row'.
Take a quick look at my example here, ignoring the zFPKM part, though: Heatmap based with FPKM values
Kevin
I think you can try to remove col=bluered(100), because in default, they use yellow-red schema. P.S. You can create a vector of n contiguous colors using the functions rainbow(n), heat.colors(n), terrain.colors(n), topo.colors(n), and cm.colors(n).
Thank you Tao, I'll explore this too.
Log in to answer this question.