setwd("[% TEMPDIR %]") user <- read.delim("[% DATA %]", sep="\t", header=FALSE) # # Got this from # https://stat.ethz.ch/pipermail/bioconductor/2003-October/002874.html # na.dist <- function(x,...) { t.dist <- dist(x,...) t.dist <- as.matrix(t.dist) t.limit <- 1.1*max(t.dist,na.rm=T) t.dist[is.na(t.dist)] <- t.limit t.dist <- as.dist(t.dist) return(t.dist) } label <- user[,1] selection <- as.matrix(user[,-1]) gene_distances <- na.dist( selection ) attr(gene_distances,"Labels") <- label gene_dendro <- hclust(gene_distances) dimnames(selection)[[1]] <- user[,1] dimnames(selection)[[2]] <- 1:length(selection[1,]) postscript(file= "[% HEATMAP %]", width=9, height=9, paper="special", horizontal=FALSE) # See # https://stat.ethz.ch/pipermail/bioconductor/2003-November/003144.html # for the coercion heatmap(selection,Rowv=as.dendrogram(gene_dendro)) postscript(file= "[% DENDROGRAM %]", width=9, height=9, paper="special", horizontal=FALSE) plot(gene_dendro)