Skip to content

Issues with Heat Map Images

6 messages · David Winsemius, cpleisner

#
Hello,
I have a large data set from RNA sequencing and I am trying to make a heat
map of my data.  I have am having issues formatting my heat map figure.  My
data set is large with the log2 fold change for over 6oo genes across 4
treatments.  My csv file is formatted as such:
Gene	                           Drought	                Ozone	                
Temp1	          Temp2
Glyma0041s00260	-0.130545875	-0.098349739	0.170508007	      0.091996284
....

So far I have gotten an image, but I can't seem to get the gene names to
display properly.  Here is my code:
heatdata <- read.csv("logFC_bin17.csv", sep=",")
heatdata <- heatdata[,2:5]
heatdata_matrix <- data.matrix(heatdata)
rownames(heatdata_matrix) = paste("Gene", 2:655)
x11()
data_heatmap <- heatmap.2(heatdata_matrix, col=redblue(75), scale="row",
key=TRUE, symkey=FALSE, density.info="none", trace="none", margins=c(10,10),
cexRow=0.5)
jpeg("Heatmap_bin17.jpeg", width=8, height=8, units="in", res=300,
quality=100)

The heat map looks like this (with red green coloring):
<http://r.789695.n4.nabble.com/file/n4648806/Heatmap_bin20.jpeg> 

I fixed the margin issues (not seen in image), but I would like on the right
axis to have the list of gene names so I can pull out the important genes
based on the cluster analysis and heat map.  Also, when I try and output the
figure as a jpeg the jpeg file is found in the correct folder, but when I
open it it is empty (?).  How can I fix these issues?

Thanks!



--
View this message in context: http://r.789695.n4.nabble.com/Issues-with-Heat-Map-Images-tp4648806.html
Sent from the R help mailing list archive at Nabble.com.
#
On Nov 7, 2012, at 3:31 PM, cpleisner wrote:

            
The 'rowInd' component of the list returned from the plotting function call would appear to be of use here. You might try using (wild-assed guess, totally untested in the absence of a working example):

jpeg("Heatmap_bin17.jpeg", width=8, height=8, units="in", res=300,
quality=100)
data_heatmap <- heatmap.2(heatdata_matrix, col=redblue(75), scale="row",
key=TRUE, symkey=FALSE, density.info="none", trace="none", margins=c(10,10),
cexRow=0.5)
axis(4,
      at=1:NROW(heat_datamatrix), 
      labels=rownames(heatdata_matrix[dat_heatmap$rowInd] ), 
      cex=<some small number> )
dev.off()
The last issue can be easily fixed by using dev.off() after the jpeg() call. You will need to execute jpeg(...) first, then the heatmap.2 call, then dev.off().


Read:

?Devices
?dev.off()
#
David,
Thanks for the help.  I tried the following code:

heatdata <- read.csv("logFC_bin17.csv", sep=",")
heatdata <- heatdata[,2:5]
heatdata_matrix <- data.matrix(heatdata)
rownames(heatdata_matrix) = paste("Gene", 2:655)
jpeg("Heatmap_bin17.jpeg", width=8, height=8, units="in", res=300, 
quality=100) 
data_heatmap <- heatmap.2(heatdata_matrix, col=redblue(75), scale="row", 
key=TRUE, symkey=FALSE, density.info="none", trace="none", margins=c(10,10), 
cexRow=0.5) 
axis(4, 
      at=1:NROW(heatdata_matrix), 
      labels=rownames(heatdata_matrix[data_heatmap$rowInd] ), 
      cex=0.5) 
dev.off() 

It solved the issue with the jpeg, but I am still getting the following
image:
<http://r.789695.n4.nabble.com/file/n4648906/Heatmap_bin17.jpeg> 

The axis labels are still off and now there is this '1' in the upper right
hand corner.  Thoughts?
Courtney







--
View this message in context: http://r.789695.n4.nabble.com/Issues-with-Heat-Map-Images-tp4648806p4648906.html
Sent from the R help mailing list archive at Nabble.com.
#
On Nov 8, 2012, at 7:58 AM, cpleisner wrote:

            
I suspect that the labels are in that smeared black band on the RHS of the plot. You should consider plotting this with pdf() and zooming in to see if you even need an extra axis call.

  
    
#
David,
I tried that and zoomed in on the labels.  It seems that the labels are
oriented wrong with is possibly why they are smearing.  Instead of reading
left to right they are turned 90 degrees and read from the top to the bottom
along the axis of the heatmap.  How do I fix this?

Thanks!
Courtney



--
View this message in context: http://r.789695.n4.nabble.com/Issues-with-Heat-Map-Images-tp4648806p4648967.html
Sent from the R help mailing list archive at Nabble.com.
#
On Nov 8, 2012, at 1:09 PM, cpleisner wrote:

            
I don't really know that I can help. I do not have the data and the first example from help(heatmap.2) seems to be  printing the labels in sensible orientation , so at this point ... who knows?