Biostar Beta. Not for public use.
Making a heat map more clear
0
Entering edit mode
18 months ago
Za • 120

Hi,

I have plotted log normalised data in a heatmap as this picture but how I can make the dots more clrear and darker please?

heatmap.2(d, Rowv=as.dendrogram(hr), Colv=as.dendrogram(hc), scale="row", density.info="none", trace="none",col=colfunc(20))
heatmap R • 2.0k views
ADD COMMENTlink
1
Entering edit mode
ADD REPLYlink
6
Entering edit mode
15 months ago
Republic of Ireland

Just scale it yourself and set breaks accordingly. Then, it will [usually] look better.

Pick a color scheme and set breaks

require("RColorBrewer")
myCol <- colorRampPalette(c("dodgerblue", "black", "yellow"))(100)
myBreaks <- seq(-2, 2, length.out=101)

Transform your data to the Z-scale

heat <- t(scale(t(sc_DEGG)))

Plot the heatmap, specify your custom breaks and colour scheme, and switch further scaling (by heatmap.2) off

require("gplots")

heatmap.2(heat,
  Rowv=as.dendrogram(hr),
  Colv=as.dendrogram(hc),
  col=myCol,
  breaks=myBreaks,
  main="Title",
  key=T,
  keysize=1.0,
  scale="none",
  density.info="none",
  reorderfun=function(d,w) reorder(d, w, agglo.FUN=mean),
  trace="none",
  cexRow=0.2,
  cexCol=0.8,
  distfun=function(x) dist(x, method="euclidean"),
  hclustfun=function(x) hclust(x, method="ward.D2"))
ADD COMMENTlink
0
Entering edit mode

Excuse me,

saying:

Error in if (key) { : argument is not interpretable as logical
In addition: Warning message:
In if (key) { :
  the condition has length > 1 and only the first element will be used

Sorry, you are using Ward clustering but in

hr <- hclust(as.dist(1-cor(t(y), method="pearson")), method="complete")


hc <- hclust(as.dist(1-cor(y, method="spearman")), method="complete")

you also using

Rowv=as.dendrogram(hr), Colv=as.dendrogram(hc)

Is this a double clustering?

ADD REPLYlink
1
Entering edit mode

Sorry, yes, you are supplying your own dendrograms. Regardng the 'key', you can just remove those, as they were just the default values. You just need to do:

heatmap.2(heat, Rowv=as.dendrogram(hr), Colv=as.dendrogram(hc), col=myCol, breaks=myBreaks, main="Title", scale="none", density.info="none", reorderfun=function(d,w) reorder(d, w, agglo.FUN=mean), trace="none", cexRow=0.8, cexCol=0.8)

By the way, in your original heatmap, the breaks were way to high with regard to colour and the distribution of values (-10, 0, +10). By scaling the data yourself and setting the breaks lower, you are virtually guaranteed to bring out more colour into the heatmap. Hope that this makes sense. Please feel free to change the breaks to -1/+1, -3+3, -5+5, etc.

ADD REPLYlink
3
Entering edit mode
16 months ago
United States

seems like it's mostly a problem of resolution, increasing the size of the image (and therefore of each dot) may help already.

Perhaps, Kamil's tips on how to map the color to quantiles rather than absolute numbers may also be of help.

ADD COMMENTlink
0
Entering edit mode

That is a great link ... thanks a lot

ADD REPLYlink
0
Entering edit mode

Thanks a lot, always helpful you are

ADD REPLYlink

Login before adding your answer.

Similar Posts
Loading Similar Posts
Powered by the version 2.3.1