Making a heat map more clear
2
0
Entering edit mode
5.9 years ago
Za ▴ 140

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 • 7.5k views
ADD COMMENT
1
Entering edit mode
ADD REPLY
8
Entering edit mode
5.9 years ago

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 (row-wise)

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 COMMENT
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 REPLY
2
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 REPLY
4
Entering edit mode
5.9 years ago

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 COMMENT
0
Entering edit mode

That is a great link ... thanks a lot

ADD REPLY
0
Entering edit mode

Thanks a lot, always helpful you are

ADD REPLY

Login before adding your answer.

Traffic: 2701 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6