markChanges: Add marked changes to a plotted tree with mapped discrete...

View source: R/utilities.R

markChangesR Documentation

Add marked changes to a plotted tree with mapped discrete character

Description

Adds the reconstructed changes to a plotted tree with a stochastically mapped discrete character.

Usage

markChanges(tree, colors=NULL, cex=1, lwd=2, plot=TRUE)

Arguments

tree

an object of class "simmap".

colors

a named vector of colors used to plot the stochastically mapped character on the tree.

cex

expansion factor for line height.

lwd

line width.

plot

logical value indicating whether the changes should be plotted or not.

Value

This function returns (invisibly) a matrix containing the x & y coordinates of the marked changes on the plotted tree.

Author(s)

Liam Revell liam.revell@umb.edu

References

Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). Methods Ecol. Evol., 3, 217-223.

See Also

plotSimmap

Examples

## load tree and data from Revell & Collar (2009)
data(sunfish.tree)
data(sunfish.data)
## extract discrete character (feeding mode)
fmode<-setNames(sunfish.data$feeding.mode,
  rownames(sunfish.data))
## fit model
er_model<-fitMk(sunfish.tree,fmode,model="ER",
  pi="fitzjohn")
## generate single stochastic map
sunfish_smap<-simmap(er_model,nsim=1)
## plot stochastic map & mark changes
cols<-setNames(c("blue","red"),levels(fmode))
plot(sunfish_smap,cols,ftype="i")
markChanges(sunfish_smap,colors=cols,lwd=6)
par(mar=c(5.1,4.1,4.1,2.1))

phytools documentation built on Nov. 10, 2023, 1:08 a.m.