PlotCharacter: Plot the distribution of a character on a tree

PlotCharacterR Documentation

Plot the distribution of a character on a tree

Description

Reconstructs the distribution of a character on a tree topology using the modified Fitch algorithm presented in \insertCiteBrazeau2019;textualTreeSearch.

Usage

PlotCharacter(
  tree,
  dataset,
  char = 1L,
  updateTips = FALSE,
  plot = TRUE,
  tokenCol = NULL,
  ambigCol = "grey",
  inappCol = "lightgrey",
  ambigLty = "dotted",
  inappLty = "dashed",
  plainLty = par("lty"),
  tipOffset = 1,
  unitEdge = FALSE,
  ...
)

Arguments

tree

A tree of class phylo.

dataset

A phylogenetic data matrix of phangorn class phyDat, whose names correspond to the labels of any accompanying tree.

char

Index of character to plot.

updateTips

Logical; if FALSE, tips will be labelled with their original state in dataset.

plot

Logical specifying whether to plot the output.

tokenCol

Palette specifying colours to associate with each token in turn, in the sequence listed in attr(dataset, "levels").

ambigCol, ambigLty, inappCol, inappLty, plainLty

Colours and line types to apply to ambiguous, inapplicable and applicable tokens. See the lty graphical parameter for details of line styles. Overrides tokenCol.

tipOffset

Numeric: how much to offset tips from their labels.

unitEdge

Logical: Should all edges be plotted with a unit length?

...

Further arguments to pass to plot.phylo().

Value

PlotCharacter() invisibly returns a matrix in which each row corresponds to a numbered tip or node of tree, and each column corresponds to a token; the tokens that might parsimoniously be present at each point on a tree are denoted with TRUE.

Author(s)

Martin R. Smith (martin.smith@durham.ac.uk)

References

\insertAllCited

Examples

# Set up plotting area
oPar <- par(mar = rep(0, 4))

tree <- ape::read.tree(text = 
  "((((((a, b), c), d), e), f), (g, (h, (i, (j, (k, l))))));")
## A character with inapplicable data
dataset <- TreeTools::StringToPhyDat("23--1??--032", tips = tree)
plotted <- PlotCharacter(tree, dataset)
plotted

# Character from a real dataset 
data("Lobo", package = "TreeTools")
dataset <- Lobo.phy
tree <- TreeTools::NJTree(dataset)
PlotCharacter(tree, dataset, 14)
par(oPar)

TreeSearch documentation built on Aug. 26, 2023, 9:06 a.m.