| Version: | 1.0.3 |
| Date: | 2026-02-03 |
| Title: | Dendrogram Seriation: Ordering for Visualisation |
| Description: | Re-arranges a dendrogram to optimize visualisation-based cost functions. The methods implemented here are described in "Advances in Dendrogram Seriation for Application to Visualization", Journal of Computational and Graphical Statistics (2015) D. Earle and C.B. Hurley <doi:10.1080/10618600.2013.874295>. |
| License: | GPL-2 |
| Encoding: | UTF-8 |
| RoxygenNote: | 7.3.3 |
| Imports: | gclus, graphics, seriation, stats, utils |
| Suggests: | HSAUR2, Iyer517, RColorBrewer, mvtnorm, scagnostics, knitr, rmarkdown |
| VignetteBuilder: | knitr |
| NeedsCompilation: | yes |
| Packaged: | 2026-02-13 16:08:56 UTC; catherine |
| Author: | Catherine B. Hurley [aut], Denise Earle [aut], Catherine Hurley [cre] |
| Maintainer: | Catherine Hurley <catherine.hurley@mu.ie> |
| Repository: | CRAN |
| Date/Publication: | 2026-02-13 17:40:17 UTC |
DendSer: Dendrogram Seriation: Ordering for Visualisation
Description
Re-arranges a dendrogram to optimize visualisation-based cost functions. The methods implemented here are desribed in Advances in Dendrogram Seriation for Application to Visualization, JCGS (2015) D. Earle and C.B. Hurley doi:10.1080/10618600.2013.874295.
Author(s)
Maintainer: Catherine Hurley catherine.hurley@mu.ie
Authors:
Catherine B. Hurley
Denise Earle
Implements dendrogram seriation
Description
Implements dendrogram seriation.
Usage
DendSer(
h,
ser_weight,
cost = costBAR,
node_op = NULL,
costArg = NULL,
maxloops = NULL,
saveinfo = FALSE,
direction = NULL,
GW = NULL,
...
)
Arguments
h |
An object of class hclust |
ser_weight |
Used by cost function to evaluate ordering. For cost=costLS, this is a vector of object weights. Otherwise is a dist or symmetric matrix. |
cost |
Function used to evaluate permutation.Current choices are costLS, costPL, costLPL, costED, costARc, costBAR. |
node_op |
Function used to reorder branches at a dendrogram node. DendSer picks default depending on cost function. NULL means use default depending on cost. |
costArg |
Other args for cost function. |
maxloops |
Maximum number of iterations allowed. NULL means use default depending on cost. |
saveinfo |
Logical, whether info associated with search is saved. |
direction |
Order of visiting nodes. Values are "up" or "down", for nodes in order of increasing or decreasing height.NULL means use default depending on cost. |
GW |
Logical, initial GW step or not. NULL means use default depending on cost. |
... |
Not used. |
Details
costED uses the Gruvaeus and Wainer 1972 algorithm, as provided by package gclus.
Value
Numeric vector giving an optimal dendrogram order
Author(s)
Catherine Hurley & Denise Earle
References
Gruvaeus, G. & Wainer, H. (1972), “Two additions to hierarchical cluster analysis”, British Journal of Mathematical and Statistical Psychology, 25, 200-206.
See Also
Examples
d<- dist(iris[,-5])
h <- hclust(d,method="average")
ob<- DendSer(h,d)
opl<- DendSer(h,d,cost=costPL)
plotAsColor(d,ob)
w <- rowSums(iris[,-5])
ow <- DendSer(h,w,cost=costLS) # arranges cases by size, within hclust
stars(iris[ow,-5],labels=NULL, col.stars=cutree(h,3)[ow]) # and color by cluster
#stars(iris[ow,-5],labels=NULL, col.stars=iris[ow,5]) # or by species
Cost functions for DendSer Each of these functions evaluates the cost of an ordering.
Description
Cost functions for DendSer Each of these functions evaluates the cost of an ordering.
Usage
costLS(sw, o, target = seq_along(sw), ...)
costARc(sw, o, target = nrow(sw) - 1, ...)
costED(sw, o, node, se, ...)
costPL(sw, o, ...)
costLPL(sw, o, target = (nrow(sw) - 1):1, ...)
costBAR(sw, o, target = max(2, floor(nrow(sw)/5)), ...)
Arguments
sw |
For cost=costLS, this is a vector of object weights. Otherwise is a symmetric matrix. |
o |
An ordering vector. |
target |
Parameter used by cost function. |
... |
Other args. |
node |
The node |
se |
Extra info |
Value
Result of cost
Author(s)
Catherine Hurley & Denise Earle
Cost function from seriation criterion
Description
Returns a cost function from seriation criterion (package seriation)
Usage
crit2cost(crit)
Arguments
crit |
One of seriation::list_criterion_methods("dist") |
Examples
d<- dist(iris[1:20,-5])
h <- hclust(d)
DendSer(h,d,cost=function(x,o,...) seriation::criterion(as.dist(x),o,method="AR_deviations"))
DendSer(h,d,cost=crit2cost("AR_deviations")) # short version of above
DendSer(h,d,cost=crit2cost("ME"))
# use DendSer methods via seriate
# seriation::get_order(seriate(d,method="Dendser", control=list(hclust=h,cost=costARc)))
DendSer(h,d, cost=costARc)
Implements dendrogram seriation. Interface to DendSer.
Description
Implements dendrogram seriation. Interface to DendSer.
Usage
dser(x, ser_weight, cost = costBAR, ...)
## S3 method for class 'data.frame'
dser(x, ser_weight, cost = costBAR, ...)
## S3 method for class 'matrix'
dser(x, ser_weight, cost = costBAR, scale = TRUE, dmethod = "euclidean", ...)
## S3 method for class 'dist'
dser(x, ser_weight, cost = costBAR, hmethod = "average", ...)
## S3 method for class 'hclust'
dser(x, ser_weight, cost = costBAR, ...)
Arguments
x |
Used to select method. |
ser_weight |
Seriation weights. For cost=costLS, defaults to first column of matrix x, otherwise to symmetric matrix version of dist d. |
cost |
Current choices are costLS, costPL, costLPL, costED, costARc, costBAR. |
... |
Other args |
scale |
Logical value,controls whether matrix x should be scaled prior to forming dist. |
dmethod |
Method of dist calculation. See function |
hmethod |
Method of hclust calculation. See function |
Details
When x is a matrix or data.drame, forms a dist of rows using function dist with method = dmethod. When x is a dist, forms a hclust with method = hmethod which is then reordered.
Value
Numeric vector giving an optimal dendrogram order
Methods (by class)
-
dser(data.frame): dser method -
dser(matrix): dser method -
dser(dist): dser method -
dser(hclust): dser method
Author(s)
Catherine Hurley & Denise Earle
Examples
iriss <- scale(iris[,-5])
plotAsColor(iriss,order.row=dser(iriss))
w <- prcomp(iris[,-5],scale=TRUE)$x[,1]
h<- hclust(dist(iriss))
h$order <- ow <- dser(h,w,cost=costLS) # arranges cases along first PC, within dendrogram
# compare re-rordered dendrogram to PC scores, w
dev.new(width=10,height=5)
par(mar=c(0,2,1,1))
layout(matrix(1:2, nrow = 2), heights = c(4,1.5) )
par(cex=.7)
plot(h,main="",xlab="",hang=-1,labels=FALSE)
u <- par("usr")
par(mar=c(1,2,0,1))
plot.new()
par(usr=c(u[1:2],min(w),max(w)))
x<- 1:length(w)
rect(x-.5,0,x+.5,w[ow],col=cutree(h,3)[ow]+1)
Function that plots a matrix as a color image
Description
Function that plots a matrix as a color image, in matrix order.
Usage
plotAsColor(
m,
order = NULL,
order.col = order,
order.row = order,
rank = FALSE,
border.color = "grey70",
labels = FALSE,
x = 1:ncol(d),
y = 1:nrow(d),
...
)
Arguments
m |
Numeric matrix. |
order |
Default order used for rows and columns. |
order.col |
Column order. |
order.row |
Row order |
rank |
Logical, whether matrix m should be converted to ranks or not. |
border.color |
Color of border. Null for no border. |
labels |
If TRUE, add labels obtained from m. |
x |
X coordinates, passed to |
y |
Y coordinates, passed to |
... |
passed to |
See Also
See Also as image.
Examples
d<- dist(scale(iris[,-5]))
plotAsColor(d,dser(d,hmethod="average"))