adjust_data: Adjusts the tree and traits to meet the requirements of...

View source: R/tools.R

adjust_dataR Documentation

Adjusts the tree and traits to meet the requirements of estimate_shift_configuration

Description

Returns a new tree and new data matrix, where the tree edges are in postorder, and the data row names match the order of the tree tip labels.

Usage

adjust_data(tree, Y, normalize = TRUE, quietly = FALSE)

Arguments

tree

ultrametric tree of class phylo with branch lengths.

Y

trait vector/matrix without missing entries.

normalize

logical. If TRUE, normalizes branch lengths to a unit tree height.

quietly

logical. If FALSE, changes in tree/trait are printed.

Value

tree

tree of class phylo, with the same topology as the input tree but adjusted edge order.

Y

trait vector/matrix with adjusted row names and row order.

Examples

data(lizard.tree, lizard.traits)
# here, lizard.traits is a matrix, so columns retain row names:
names(lizard.traits[,1])
lizard <- adjust_data(lizard.tree, lizard.traits[,1])

# for a data frame, make sure to retain row names if a single column is selected:
lizard.traits <- as.data.frame(lizard.traits)
lizard <- adjust_data(lizard.tree, subset(lizard.traits, select=1))

khabbazian/l1ou documentation built on Aug. 10, 2022, 7:41 p.m.