make.states.matrix: Sates matrix

View source: R/NA.utilities.R

make.states.matrixR Documentation

Sates matrix

Description

Creates a states matrix

Usage

make.states.matrix(
  tree,
  character,
  inapplicable = NULL,
  match.tip.char = FALSE
)

Arguments

tree

phylo, a tree

character

Either vector of character states ("numeric" or "character") or a list of the same length of than the tips in the tree (see details)

inapplicable

When the intended reconstruction method is "Fitch", how do deal with inapplicable data: 1, 2 for respectively treating them as ? or an extra state (default = NULL).

match.tip.char

logical, TRUE to match the character to the tip labels (e.g character 1 matches with tip "a" or "1") or FALSE (default) to match the character to the tips entry (e.g. character 1 matches with the first tip). If a character is supplied as a named list, and the names correspond to the names of the tips, then this parameter will be ignored and the names of the characters will be used to match them to the names of the tips.

Details

If character argument is a list, each element of the list must be a "numeric" vector with "?" being all states and "-" being -1.

Value

A list of character states for each node and tip per pass: -$Char: a list of character states for the tips. -$Dp1: a list of the tips' and nodes' states after the first downpass. -$Up1: a list of the tips' and nodes' states after the first uppass. -$Dp2: a list of the tips' and nodes' states after the second downpass. -$Up2: a list of the tips' and nodes' states after the second uppass. -$tracker: a list tracking the applicable regions. -$regions: a single numeric value counting the number of applicable regions. -$changes: a numeric vector recording the node with state changes. -$score: a numeric vector recording the score of the tree. -$tree: a phylo object describing the tree. -$n_tip: a numeric vector recording the number of tips. -$n_node: a numeric vector recording the number of (internal) nodes within the tree.

Author(s)

Thomas Guillerme

See Also

apply.reconstruction.

Examples

## A simple topology
tree <- ape::read.tree(text = "((a,b),(c,d));")

## A simple character
character <- "0101"

## Create a states matrix for reconstruction
make.states.matrix(tree, character)

## A complex character
character <- "0{01}-?"


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