library(ClassDiscovery) suppressWarnings( RNGversion("3.5.3") ) set.seed(593996) dd <- matrix(rnorm(100*5, rnorm(100)), nrow=100, ncol=5) distanceMatrix(dd, 'pearson') distanceMatrix(dd, 'euclid') distanceMatrix(dd, 'sqrt') distanceMatrix(dd, 'weird') distanceMatrix(dd, 'cosine') rm(dd) # cleanup # simulate data from three different groups d1 <- matrix(rnorm(100*10, rnorm(100, 0.5)), nrow=100, ncol=10, byrow=FALSE) d2 <- matrix(rnorm(100*10, rnorm(100, 0.5)), nrow=100, ncol=10, byrow=FALSE) d3 <- matrix(rnorm(100*10, rnorm(100, 0.5)), nrow=100, ncol=10, byrow=FALSE) dd <- cbind(d1, d2, d3) # perform hierarchical clustering using correlation hc <- hclust(distanceMatrix(dd, 'pearson'), method='average') cols <- rep(c('red', 'green', 'blue'), each=10) labs <- paste('X', 1:30, sep='') # plot the dendrogram with color-coded groups plotColoredClusters(hc, labs=labs, cols=cols) #cleanup rm(d1, d2, d3, dd, hc, cols, labs)