Hi ,

I am trying to plot a heatmap with a correlation matrix and trying to
highlight significant correlations .

i am using
my matrix d874n has 78 columns
ex2<-corAndPvalue(data.matrix(d874n),use = "pairwise.complete.obs")
##creating a matrix of true false using p values
sig<-ex2$p<0.05
nx=78
ny=78
makeRects <- function(tfMat,border){
  cAbove = expand.grid(1:nx,1:ny)[tfMat,]
  xl=cAbove[,1]-0.49
  yb=cAbove[,2]-0.49
  xr=cAbove[,1]+0.49
  yt=cAbove[,2]+0.49
  rect(xl,yb,xr,yt,border=border,lwd=3)
}

###heatmap without reordering ##############
heatmap.2(ex2$cor,Colv=FALSE,dendrogram="none",Rowv=FALSE,col=redgreen(25),
density.info
="none",trace="none",add.expr={makeRects(sig,"orange")},revC=TRUE)


I want to create a heatmap with clustering and reordering but my sig matrix
is according to unordered matrix .

I tried usings

cluster1<-hclust(dist(d874n))
cluster1$order

The resulting order of columns on the dendrogram is not same as on heatmap
with
heatmap.2(ex2$cor,Colv=FALSE,dendrogram="none",Rowv=FALSE,col=redgreen(25),
density.info="none",trace="none",revC=TRUE)

if i get this cluster1$order i can change the order in my "sig" matrix to
get the correct "add.expr"
heatmap.2 description says that it uses dist matrix and hclust by
default.Please if anyone can guide me y do i get different clusters order
with "cluster1<-hclust(dist(d874n))" and " heatmap.2"




Tanu Soni

	[[alternative HTML version deleted]]

