On Nov 7, 2012, at 3:31 PM, cpleisner wrote:
> 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()
>
> 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.
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()
> 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?
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 Winsemius, MD
Alameda, CA, USA