Question: No color observed in Colour Key of HeatMap.2
0
gravatar for Ming
8 months ago by
Ming40
Ming40 wrote:

Dear All,

I am trying to plot a heatmap with the heatmap.2 function, but I am not getting any color on my Color Key.

The following are my code:

col1 <- colorRampPalette(c("green", "black", "red"))(499)

> col_breaks = c(seq(0, 0.002, length = 50),
>                seq(0.0021, 0.004, length = 50),
>                seq(0.0041, 0.006, length = 50),
>                seq(0.0061, 0.008, length = 50),
>                seq(0.0081, 0.01, length = 50),
>                seq(0.011, 0.04, length = 50),
>                seq(0.041, 0.08, length = 50),
>                seq(0.081, 1.2, length = 50),
>                seq(1.21, 1.4, length = 50),
>                seq(1.41, 1.6, length = 50))
heatmap.2(data.matrix(MTB_genus_RA_T), scale = "none", 
          trace = "none", density.info = "density",
          col = col1, breaks = col_breaks,
          Rowv = as.dendrogram(row.clus), Colv = as.dendrogram(col.clus.MTB),
          margins = c(13, 8),
          main = "Heatmap of MTB at the genus level",
          cexRow = 1.1, cexCol = 1.1,
          keysize = 2,
          # key.par=list(mar=c(bottom, left, top, right))
          key.par=list(mar=c(3,5,4,5)))#, lhei = c(0.1, 0.1), lwei = c(0.1, 0.1))
  

I am not getting any color on my color key. Can anyone please help?

enter image description here

Thank you!

heatmap.2 R • 845 views
ADD COMMENTlink modified 8 months ago by ATpoint29k • written 8 months ago by Ming40

Perhaps provide an example with a more complete dataset?

Many of your objects (e.g. MTB*) were not included - so we cannot say for sure whether this is a problem that is specifically happening to you or if it is reproducible for others.

ADD REPLYlink written 8 months ago by benformatics1.4k

Dear @benformatics, what other kind of information will you like?

ADD REPLYlink written 8 months ago by Ming40

Why not replace col = col1, breaks = col_breaks, with just col = greenred,? Depending on your purpose, but it seems the values are from 0 to ~1.5 instead of something like -3 to 3 (perhaps using a sequential palette here, for example, brewer.pal(9, "YlGnBu"), would be better).

ADD REPLYlink modified 8 months ago • written 8 months ago by SMK1.9k

Dear @SMK, how would you change the code?

ADD REPLYlink written 8 months ago by Ming40

Hi Ming,

Something like:

library(gplots)
library(RColorBrewer)

heatmap.2(
  data.matrix(MTB_genus_RA_T),
  scale = "none",
  trace = "none",
  density.info = "density",
  col = greenred,
  main = "Heatmap of MTB at the genus level"
)

heatmap.2(
  data.matrix(MTB_genus_RA_T),
  scale = "none",
  trace = "none",
  density.info = "density",
  col = brewer.pal(9, "YlGnBu"),
  main = "Heatmap of MTB at the genus level"
)
ADD REPLYlink written 8 months ago by SMK1.9k
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: 1676 users visited in the last hour