Wednesday, April 20, 2011

heatmap using a custom distance for hclust clustering

# Correlation distance function.
cordist <- function(x ) {
return( as.dist(( 1 - cor(t(x), use = "pairwise.complete.obs"))))
}

# Getting nice aligned clustering trees. Assume given my.dists.
clus<-hclust(my.dists,method = "a")

# Plot heatmap
#heatmap(x, Rowv=as.dendrogram(hclust(cordist(x))))
heatmap(x, Rowv=as.dendrogram(clus))

No comments: