Question: Making a heat map more clear
0
gravatar for Za
20 months ago by
Za120
Za120 wrote:

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 • 3.1k views
ADD COMMENTlink modified 20 months ago • written 20 months ago by Za120
1

May be you can try pheatmap https://cran.r-project.org/web/packages/pheatmap/pheatmap.pdf

ADD REPLYlink written 20 months ago by Gjain5.4k
6
gravatar for Kevin Blighe
20 months ago by
Kevin Blighe54k
Kevin Blighe54k wrote:

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 COMMENTlink modified 8 months ago • written 20 months ago by Kevin Blighe54k

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 written 20 months ago by Za120
2

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 modified 20 months ago • written 20 months ago by Kevin Blighe54k
3
gravatar for Friederike
20 months ago by
Friederike5.2k
United States
Friederike5.2k wrote:

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 written 20 months ago by Friederike5.2k

That is a great link ... thanks a lot

ADD REPLYlink written 20 months ago by Gjain5.4k

Thanks a lot, always helpful you are

ADD REPLYlink written 20 months ago by Za120
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: 1076 users visited in the last hour