## seriate dist of 20 flowers from the iris data set
data("iris")
x <- as.matrix(iris[-5])
x <- x[sample(1:nrow(x), 25),]
rownames(x) <- 1:25
d <- dist(x)
## create a list of different seriations
methods <- c("HC_single", "HC_complete", "OLO", "GW", "R2E", "VAT",
"TSP", "Spectral", "SPIN", "MDS", "Identity", "Random")
os <- sapply(methods, function(m) {
cat("Doing ", m, "... ")
tm <- system.time(o <- seriate(d, method = m))
cat("took ", tm[3],"s.
")
o
})
## compare the methods using distances (default distance ignores reversed orders)
ds <- seriation_dist(os)
hmap(ds, margin=c(7,7))
## comapte using actual correlation (reversed orders are neg. correlated!)
cs <- seriation_cor(os)
hmap(cs, margin=c(7,7))
## normalize direction of the seriation orders
os2 <- seriation_align(os)
cs2 <- seriation_cor(os2)
hmap(cs2, margin=c(7,7))
## plot the actual seriations
for(i in os2) pimage(d, i, main = get_method(i))
Run the code above in your browser using DataLab