Question: color gradient for heatmap2
0
gravatar for jtehmsen
5 months ago by
jtehmsen20
jtehmsen20 wrote:

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.

ADD COMMENTlink modified 5 months ago by Tao410 • written 5 months ago by jtehmsen20
0
gravatar for regmkbl
5 months ago by
regmkbl66k
regmkbl66k wrote:

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

ADD COMMENTlink modified 5 months ago • written 5 months ago by regmkbl66k
1

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.

ADD REPLYlink written 5 months ago by jtehmsen20
0
gravatar for Tao
5 months ago by
Tao410
Tao410 wrote:

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).

ADD COMMENTlink written 5 months ago by Tao410

Thank you Tao, I'll explore this too.

ADD REPLYlink written 5 months ago by jtehmsen20
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 2001 users visited in the last hour