plot.states.matrix: Plot tree and ancestral states

View source: R/plot.algorithm.R

plot.states.matrixR Documentation

Plot tree and ancestral states

Description

Plots an ancestral states reconstruction and tree score

Usage

## S3 method for class 'states.matrix'
plot(
  x,
  passes = 1:4,
  show.labels = 0,
  col.tips.nodes = c("#fc8d59", "#eeeeeed0", "#7fbf7be0", "#af8dc3e0"),
  counts = 0,
  use.edge.length = FALSE,
  col.states = FALSE,
  state.labels = character(0),
  legend.pos = "bottomleft",
  y.lim = NULL,
  cex = 1,
  ...
)

Arguments

x

A states.matrix list from apply.reconstruction

passes

numeric, the number of passes to plot (default = c(1,2,3,4)). Set to 0 to leave nodes unlabelled.

show.labels

numeric, either 1 for showing the tip labels, 2 for the node labels or c(1,2) for both (default = NULL).

col.tips.nodes

character, a vector of up to four colors to be used for displaying respectively the tips, the nodes, and (if counts != 0) the activated/counted nodes and the nodes at which regions are counted.

counts

numeric, whether to display the activations (1) or/and the homoplasies (2) or nothing (0; default).

use.edge.length

logical indicating whether to use the edge lengths of the phylogeny to draw the branches or not (default).

col.states

logical, whether to colour the states of the tips (TRUE) or not (FALSE, default).

state.labels

vector of mode character containing labels for each state of the character, in order, to be plotted if col.states is TRUE. Set to NA to suppress state legend.

legend.pos

character, where to position the legend – e.g. bottomleft. Sent as x parameter to legend. Specify none to hide the legend.'

y.lim

numeric x and y coordinates for limits of the plot, calculated automatically based on presence of legend if set to NULL (the default).

cex

numeric Character expansion scaling factor for text.

...

any optional arguments to be passed to plot.phylo

Author(s)

Thomas Guillerme, Martin R. Smith

See Also

apply.reconstruction, runInapp

Examples

## A balanced 12 taxa tree
tree <- ape::read.tree(
                 text = "((((((1,2),3),4),5),6),(7,(8,(9,(10,(11,12))))));")
## A character with inapplicable data
character <- "23--1??--032"

## NA algorithm
NA_matrix <- apply.reconstruction(tree, character, passes = 4, method = "NA")

## Plotting the tree and the states
plot(NA_matrix)

## Plotting the tree and the states with the state changes and regions
plot(NA_matrix, counts = c(1,2))

## Plot the tree with tip/node labels, and only the 1st and 2nd downpass
plot(NA_matrix, passes = c(1,3), show.labels = c(1,2))

## Plot the tree only the 2nd uppass with the state changes in green
plot(NA_matrix, show.labels = 2, col.tips.nodes = c("red", "pink", "green"),
     counts = c(1,2), passes = c(3,4))


TGuillerme/Inapp documentation built on Feb. 4, 2024, 7:26 a.m.