pkg <- 'seriation' source("https://raw.githubusercontent.com/mhahsler/pkg_helpers/main/pkg_helpers.R") pkg_title(pkg)
Seriation arranges a set of objects into a linear order given available data with the goal of revealing structural information. This package provides the infrastructure for ordering objects with an implementation of many seriation/ordination techniques to reorder data matrices, dissimilarity matrices, correlation matrices, and dendrograms (see below for a complete list). The package provides several visualizations (grid and ggplot2) to reveal structural information, including permuted image plots, reordered heatmaps, Bertin plots, clustering visualizations like dissimilarity plots, and visual assessment of cluster tendency plots (VAT and iVAT).
Here are some quick guides and references
pkg_usage(pkg) pkg_citation(pkg, 2L) pkg_install(pkg)
The used example dataset contains the joint probability of disagreement between Supreme Court Judges from 1995 to 2002. The goal is to reveal structural information in this data. We load the library, read the data, convert the data to a distance matrix, and then use the default seriation method to reorder the objects.
library(seriation) data("SupremeCourt") d <- as.dist(SupremeCourt) d order <- seriate(d) order
Here is the resulting permutation vector.
get_order(order)
Next, we visualize the original and permuted distance matrix.
pimage(d, main = "Judges (original alphabetical order)") pimage(d, order, main = "Judges (reordered by seriation)")
Darker squares around the main diagonal indicate groups of similar objects. After seriation, two groups are visible.
We can compare the available seriation criteria. Seriation improves all measures. Note that some measures are merit measures while others represent cost. See the manual page for details.
rbind( alphabetical = criterion(d), seriated = criterion(d, order) )
Some seriation methods also return a linear configuration where more similar objects are located closer to each other.
get_config(order) plot_config(order)
We can see a clear divide between the two groups in the configuration.
Seriation methods for dissimilarity data reorder the set of objects in the data. The methods fall into several groups based on the criteria they try to optimize, constraints (like dendrograms), and the algorithmic approach.
These methods create a dendrogram using hierarchical clustering and then derive the seriation order from the leaf order in the dendrogram. Leaf reordering may be applied.
Find a seriation order by reducing the dimensionality to 1 dimension. This is typically done by minimizing a stress measure or the reconstruction error.
These methods try to optimize a seriation criterion directly, typically using a heuristic approach.
A detailed comparison of the most popular methods is available in the paper An experimental comparison of seriation methods for one-mode two-way data. (read the preprint).
For matrices, rows and columns are reordered.
Row and column order influence each other.
These methods need access to the data matrix instead of dissimilarities to reorder objects (rows). The same approach can be applied to columns.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.