Question: Making a heat map more clear
0
gravatar for Za
6 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 • 1.1k views
ADD COMMENTlink modified 6 months ago • written 6 months ago by Za120
1

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

ADD REPLYlink written 6 months ago by Gjain5.2k
5
gravatar for Kevin Blighe
6 months ago by
Kevin Blighe33k
Republic of Ireland
Kevin Blighe33k wrote:

Just scale it yourself and set breaks accordingly. Then, it will 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 modified 6 months ago • written 6 months ago by Kevin Blighe33k

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 6 months ago by Za120
1

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 6 months ago • written 6 months ago by Kevin Blighe33k
3
gravatar for Friederike
6 months ago by
Friederike2.3k
United States
Friederike2.3k 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 6 months ago by Friederike2.3k

That is a great link ... thanks a lot

ADD REPLYlink written 6 months ago by Gjain5.2k

Thanks a lot, always helpful you are

ADD REPLYlink written 6 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: 2174 users visited in the last hour