Reputation: 3024
I've seen a few sources to draw a heatmap in R using the standard heatmap
and heatmap.2
packages, but I have yet to come across an example using the new heatmap.3
package. The only source I could find for this was https://www.biostars.org/p/18211/. However, even here, the author makes his own heatmap.3
package, not the standard heatmap.3
package from CRAN http://cran.r-project.org/web/packages/GMD/GMD.pdf. I tried figuring out how to make a heatmap with heatmap.3
from that CRAN documentation, but I didn't even know where to start. I immediately got lost in all the 50+ options. Can anyone get me started?
My tab-delimited input file looks like this:
EntryA EntryB EntryC EntryD EntryE
John 48 31 57 55
Mary 88 11 89 78
Sarah 33 66 42 54
Upvotes: 0
Views: 5275
Reputation: 4921
See below a basic example using heatmap 3 on your data (for a nicer plot, axes etc need to be edited). The critical step is to create a matrix with rownames. I turned the data.frame to a matrix as this is done in the examples provided in the GMD manual but it also works fine on data.frames.
library(GMD)
dat<-data.frame(EntryA=as.numeric(c(48,88,33)), EntryB=as.numeric(c(31,11,66)), EntryC=as.numeric(c(57,89,42)), EntryD=as.numeric(c(55,78,54)))
rownames(dat)=c("John","Mary","Sarah")
ndat<-as.matrix(dat)
heatmap.3(ndat, Rowv=FALSE, Colv=FALSE)
Upvotes: 1