I want to understand what heatmap.2() is exactly doing. So I tried the
following program. But the results by image() is still not the same as
the result by heatmap.2(). Could somebody let me know how to make both
results the same (in terms of the x and y axis label orders)?



#####################
set.seed(0)
m=10
n=40
x=replicate(n,rnorm(m))

rownames(x)=1:m
colnames(x)=1:n

dir.create('main', showWarnings=T)

ahclust=hclust(dist(x))
ahclustt=hclust(dist(t(x)))

png('main/image.png')

clustered_x=x[ahclust$order, ahclustt$order]

image(t(clustered_x),axes=F)
axis(side=1,at=seq(from=par()$usr[1],to=par()$usr[2],length=n),labels=colnames(clustered_x),las=2,cex.axis=.5)
axis(side=2,at=seq(from=par()$usr[3],to=par()$usr[4],length=m),labels=rownames(clustered_x),las=2,cex.axis=.5)

dev.off()

library(gplots)
png('main/heatmap.2.png')
heatmap.2(x,scale='none',trace='none')
dev.off()

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to