jonas87
2011-Jul-24 12:10 UTC
[R] setting distance matrix and clustering methods in heatmap.2
heatmap.2 defaults to dist for calculating the distance matrix and hclust for clustering. Does anyone now how I can set dist to use the euclidean method and hclust to use the centroid method? I provided a compilable sample code bellow. I tried: distfun = dist(method = "euclidean"), but that doesn't work. Any ideas? library("gplots") library("RColorBrewer") test <- matrix(c(79,38.6,30.2,10.8,22, 81,37.7,28.4,9.7,19.9, 82,36.2,26.8,9.8,20.9, 74,29.9,17.2,6.1,13.9, 81,37.4,20.5,6.7,14.6),ncol=5,byrow=TRUE) colnames(test) <- c("18:0","18:1","18:2","18:3","20:0") rownames(test) <- c("Sample 1","Sample 2","Sample 3", "Sample 4","Sample 5") test <- as.table(test) mat=data.matrix(test) #pdf("heatmap.pdf", height=10, width=10) heatmap.2(mat, dendrogram="row", Rowv=TRUE, Colv=NULL, distfun = dist, hclustfun = hclust, xlab = "Lipid Species", ylab = NULL, colsep=c(1), sepcolor="black", key=TRUE, keysize=1, trace="none", density.info=c("none"), margins=c(8, 12), col=bluered ) -- View this message in context: http://r.789695.n4.nabble.com/setting-distance-matrix-and-clustering-methods-in-heatmap-2-tp3690173p3690173.html Sent from the R help mailing list archive at Nabble.com. [[alternative HTML version deleted]]