How to make heatmap more bright with proper color spectrum ?
2
0
Entering edit mode
9.9 years ago
jack ▴ 980

Hi,

I need to create heatmap with bright colors which different values have different colors. all the enteris of my matrix is between -0.1- 0.9.

I have tried the following command, but the heatmap is not interesting. How can I make it nice with more colors such that the different values have different colors?

Here is my command :

heatmap.2(Gene, col=greenred(10),   key=TRUE, symkey=FALSE, symm=F,symbreaks=T,cexRow=1,cexCol=1,margins=c(6,11), scale= "column" ,trace="none",srtCol=45)
dev.off()

Here is the image :

heatmap

heatmap genomics R • 9.0k views
ADD COMMENT
1
Entering edit mode

Have you tried rainbow() instead of greenred()?

ADD REPLY
1
Entering edit mode

What about scale = "row"? Assuming rows represent different genes the heatmap just highlights most abundant genes when scale = "column".

ADD REPLY
0
Entering edit mode

BTW, linking to an image in your gmail inbox won't work. You need to post it somewhere and then link to it there. Well, unless you want to give us your email login details, but that's a bad idea...

ADD REPLY
0
Entering edit mode

i thought that I have copeid inot the post. well, where can I upload image ?

ADD REPLY
1
Entering edit mode

Imgur, tinypic, postimage, etc. Just google "free image hosting" for more sites than you could ever need.

ADD REPLY
0
Entering edit mode

I updated the post.

ADD REPLY
2
Entering edit mode
9.9 years ago

Your problem is largely due to using symmetric colors. The other thing to consider is using manual color breaks. See the answer from "Lippy" here for an example of how to change these.

ADD COMMENT
0
Entering edit mode

the entries of the matrix is the correlation value and I don't scale it. I did with column (which was wrong and I tried without scaling, the plot more or less was the same)/

ADD REPLY
2
Entering edit mode
9.9 years ago
Manvendra Singh ★ 2.2k

The problem is with your range of values that's why on the either ways to zero its 1;9 and then you scale columns, try with scaling rows and add breaks in your heatmap command as;

breaks=c(-0.1,0,0.2,0.3,0.4,0.5,0.6,0.7,0,8,0.9)

or better to plot a heatmap of z-score and use colors from RColorBrewer

e.g. I would do in this way

library(gplots)
library(RColorBrewer)
hr <- hclust(as.dist(1-cor(t(Gene), method="pearson")), method="average"); 
hc <- hclust(as.dist(1-cor(Gene, method="spearman")), method="average")  
# Cuts the tree and creates color vector for clusters.
mycl <- cutree(hr,k=4, h=max(hr$height)/1.5); 
mycolhc <- rainbow(length(unique(mycl)), start=0.1, end=0.9)
mycolhc <- mycolhc[as.vector(mycl)] ; myheatcol <- bluered(75)
heatmap.2(as.matrix(Gene), Colv=as.dendrogram(hc), 
          col=myheatcol, scale="row", density.info="none", 
          trace="none", RowSideColors=mycolhc,cexRow=1.5, 
          cexCol=1.5, keysize=1,margins=c(20,10))

hth

ADD COMMENT

Login before adding your answer.

Traffic: 2083 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