paint_clades: Add regimes to a treedata object

View source: R/treeplyr_functions.R

paint_cladesR Documentation

Add regimes to a treedata object

Description

This function paints clades on the phylogeny and adds a data column that specifies to which clade each species belongs

Usage

paint_clades(
  tdObject,
  nclades = 1,
  name = "clades",
  interactive = TRUE,
  type = "nodes",
  ids = NULL,
  plot = TRUE
)

Arguments

tdObject

A treedata object

nclades

The number of clades that will be specified if used interactively

name

The name of the resulting data column

interactive

If TRUE, then a plot will appear that will allow the user to click on nclades branches. The selections will then be coverted into the data table.

type

Either "nodes" or "branches" specifying if the ids provided specify the branch id (assuming a post-ordered tree) or the node number. Ignored if interactive = TRUE.

ids

A vector of node numbers of branch numbers that specify clades. Ignored if interactive=TRUE.

plot

If TRUE and interactive = FALSE then a simmap plot is produced.

Examples

data(anolis)
td <- make.treedata(anolis$phy, anolis$dat)
td <- reorder(td, "postorder")
td.painted <- paint_clades(td, interactive=FALSE, type="nodes",
                                   ids=c(184, 160, 135, 122), plot=TRUE)
td.painted <- group_by(td.painted, clades)
summarise(td.painted,
             psig1 = phytools::phylosig(setNames(SVL, phy$tip.label), tree=phy),
                   meanSVL = mean(SVL))

uyedaj/treeplyr documentation built on March 9, 2023, 6:37 p.m.