aweSOMdendrogram: Dendogram of hierarchical clustering of SOM cells

View source: R/plots.R

aweSOMdendrogramR Documentation

Dendogram of hierarchical clustering of SOM cells

Description

Plots the dendogram of a hierarchical clustering of the SOM prototypes.

Usage

aweSOMdendrogram(clust, nclass)

Arguments

clust

an object of class hclust, the result of a hierarchical clustering performed by stats::hclust.

nclass

an integer, number of superclasses

Value

Returns NULL if nclass is 1, or else a list containing the indices of the SOM cells in each superclass.

Examples

## Build training data
dat <- iris[, c("Sepal.Length", "Sepal.Width", "Petal.Length", "Petal.Width")]
### Scale training data
dat <- scale(dat)
## Train SOM
### Initialization (PCA grid)
init <- somInit(dat, 4, 4)
ok.som <- kohonen::som(dat, grid = kohonen::somgrid(4, 4, 'hexagonal'),
                       rlen = 100, alpha = c(0.05, 0.01),
                       radius = c(2.65,-2.65),
                       init = init, dist.fcts = 'sumofsquares')
## Group cells into superclasses (hierarchical clustering)
superclust <- hclust(dist(ok.som$codes[[1]]), 'complete')
## Plot superclasses dendrogram
aweSOMdendrogram(superclust, 2)

aweSOM documentation built on Aug. 30, 2022, 5:05 p.m.