gg_ordicluster: Add Dendrogram to Ordination Plot

gg_ordiclusterR Documentation

Add Dendrogram to Ordination Plot

Description

Modeled after the ordicluster function in vegan, this function overlays an ordination object with a cluster dendogram. Functionality has been added to include treatment groups.

Usage

gg_ordicluster(
  ord,
  cluster,
  treatments = NA,
  choices = c(1, 2),
  prune = 0,
  col = 1,
  pt.size = 3,
  plot = TRUE
)

Arguments

ord

An ordination object.

cluster

A cluster object from 'hclust' based on the same distance as 'ord.'

treatments

A vector assigning treatments to samples.

choices

Ordination axes to be plotted.

prune

Number of upper level hierarchies removed from the dendrogram. If prune > 0, dendrogram will be disconnected.

col

A vector of cluster group memberships. Used to assign colors to line segments for each cluster group.

pt.size

Symbol size.

plot

A logical; defaults to TRUE.

Details

'treatments' should be a vector of class factor and length equal to the number of samples included in the ordination and cluster; integers are not coerced into factors.

Value

Invisibly returns a list of the data frames used to make the plot (df_ord, df_segments) and the plot itself (plot).

Author(s)

Jari Oksanen, John Quensen

Examples

data(dune)
data(dune.env)
dune.bray <- vegdist(dune, method="bray")
ord <- metaMDS(dune, k=3)
cl <- hclust(dune.bray, method="complete")
gg_ordicluster(ord, cluster=cl, treatments=dune.env$Management, prune=3, col=cutree(cl, 4))


jfq3/ggordiplots documentation built on Feb. 3, 2024, 11:50 p.m.