Learn R Programming

Momocs (version 1.2.9)

CLUST: Hierarchical clustering

Description

Performs hierarchical clustering through dist and hclust. So far it is mainly a wrapper around these two functions, plus plotting using plot.phylo from the package ape.

Usage

CLUST(x, fac, type = "fan", dist_method = "euclidean",
  hclust_method = "complete", retain = 0.99, tip_labels,
  palette = col_qual, ...)

# S3 method for default CLUST(x, ...)

Arguments

x

a PCA object (Coe method deprecated so far)

fac

the id or column name or formula for columns to use from $fac.

type

to pass to ape::plot.phylo's type argument, one of "cladogram", "phylogram", "radial", "unrooted" or "fan" (by default)

dist_method

to feed dist's method argument, one of "euclidean", "maximum", "manhattan", "canberra", "binary" or "minkowski".

hclust_method

to feed hclust's method argument, one of "ward.D", "ward.D2", "single", "complete" (default), "average", "mcquitty", "median" or "centroid".

retain

number of axis to retain from the PCA as a range of number eg 1:5 to retain the first 5 PCs. If a number <= 1 is passed, then the number of PCs retained will be enough to capture this proportion of variance.

tip_labels

the id or column name in $fac to use as tip_labels rather than rownames. Note that you can also pass a character (or a factor) with the same number of rows of x$x

palette

a color palette to use (col_qual by default). If NULL, par("fg") is used

...

additional parameters to feed plot.phylo

Value

the phylo object, invisibly

See Also

Other multivariate: KMEANS, LDA, MANOVA_PW, MANOVA, PCA, classification_metrics, mshapes

Examples

Run this code
# NOT RUN {
# we prepare a PCA with shorter names
olea_lite <- olea
names(olea_lite) <- as.character(olea$fac$var)
x <- olea_lite %>% opoly(5) %>% PCA()

# By default
CLUST(x)

# With a fac
CLUST(x, 1)

# plot.phylo types
CLUST(x, "var", type="cladogram")
CLUST(x, "var", type="phylogram")
CLUST(x, "var", type="radial")
CLUST(x, "var", type="unrooted")

# other dist/hclust methods
CLUST(x, "var", layout="cladogram", dist_method="minkowski", hclust_method="average")

# With another
CLUST(x, "domes", tip_labels="var", palette=col_india)

# Alternative ways to pass a factor
CLUST(x, 1)
CLUST(x, "var")
CLUST(x, ~var)
# Strict equivalent before but formula allows this:
CLUST(x, ~ domes + var, tip_labels = ~ domes + var)

# More arguments to plot.phylo
CLUST(x, cex=0.5)

# }

Run the code above in your browser using DataLab