Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

add.tree

Plot tool to add phylogenetic trees to ordination plots


Description

Function adds a tree based on a description of edges from a class phylo object to an existing plot made from an ordinate object.

Usage

add.tree(
  OP,
  tree,
  edge.col = 1,
  edge.lty = 1,
  edge.lwd = 1,
  anc.pts = FALSE,
  return.ancs = FALSE,
  ...
)

Arguments

OP

An object with class plot.ordinate.

tree

An object of class phylo.

edge.col

A single value or vector equal to the number of edges for edge colors.

edge.lty

A single value or vector equal to the number of edges for edge line type

edge.lwd

A single value or vector equal to the number of edges for edge line weight.

anc.pts

A logical value for whether to add points for ancestral values.

return.ancs

A logical value for whether ancestral values should be printed.

...

Arguments passed onto points, used only for ancestral points.

Details

With some ordinate plots, it might be desirable to add a tree connecting points in a prescribed way, which would be tedious using points or lines. This function will project a tree from an object of class phylo into a plot with class, plot.ordinate. Using an edges matrix from a phylo object, this function will systematically connect plot points with lines that pass through estimated ancestral character points in the same plot space. Ancestral states are estimated assuming a Brownian motion model of evolutionary divergence.

Author(s)

Michael Collyer

See Also

Examples

# Examples use residuals from a regression of salamander morphological 
# traits against body size (snout to vent length, SVL).
# Observations are species means and a phylogenetic covariance matrix
# describes the relatedness among observations.

data("PlethMorph")
Y <- as.data.frame(PlethMorph[c("TailLength", "HeadLength", 
"Snout.eye", "BodyWidth", 
"Forelimb", "Hindlimb")])
Y <- as.matrix(Y)
R <- lm.rrpp(Y ~ SVL, data = PlethMorph, 
iter = 0, print.progress = FALSE)$LM$residuals

PCA <- ordinate(R, scale. = TRUE)
pc.plot <- plot(PCA, pch = 19, col = "blue")

add.tree(pc.plot, tree = PlethMorph$tree, anc.pts = TRUE, 
pch = 19, cex = 0.5, col = "red")

RRPP

Linear Model Evaluation with Randomized Residuals in a Permutation Procedure

v1.0.0
GPL (>= 3)
Authors
Michael Collyer [aut, cre] (<https://orcid.org/0000-0003-0238-2201>), Dean Adams [aut] (<https://orcid.org/0000-0001-9172-7894>)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.