ecluster.fn <- function(data, distance.method, linkage.method, key.txt=NULL, clab=NULL, rlab=NULL, clab.col=NULL, rlab.col=NULL, gamma=0.75){ array.hclust <- hclust( dist(t(data),distance.method), linkage.method) # cluster the arrays/columns genes.hclust <- hclust( dist(data, distance.method), linkage.method) # cluster the genes/rows genes.dend <- as.dendrogram(genes.hclust) data.re <- data[ rev(genes.hclust$order), array.hclust$order ] # reorder the data def.par <- par() nf <- layout(matrix(c(4,3,2,1),2,2,byrow=TRUE), c(1,3), c(1,3), TRUE); layout.show(nf) if(is.null(rlab)) rlab <- dimnames(data.re)[[1]] else rlab <- rlab[rev(genes.hclust$order)] if(is.null(clab)) clab <- dimnames(data.re)[[2]] else clab <- clab[array.hclust$order] if(is.null(rlab.col)) rlab.col <- 1 else rlab.col <- rlab.col[rev(genes.hclust$order)] if(is.null(clab.col)) clab.col <- 1 else clab.col <- clab.col[array.hclust$order] par(mar=c(1,1,1,1)) plot.mat(data.re, nrgcol=100, rlabels=rlab, clabels=clab, rcols=rlab.col, ccols= clab.col, gamma=gamma) par(mar=c(0,3,0.25,2)) plot(genes.dend, horiz=T, ann=F, axes=F) par(mar=c(1,0.25,1,0.25)) plclust(array.hclust, axes=F, ann=F, label=F, hang=-1) par(mar=c(0,0.25,1,0.25)) plot.new() text(0.25, 0, paste(dim(data.re)[1], "genes used."), cex=0.8, adj=c(0,0)) # Number of genes used if(is.null(key.txt)==F){ for(i in 1:length(key.txt)){ text(0.25, 0.125*i, key.txt[i], col=i, cex=0.8, adj=c(0,0))}} }