plt_recpd_ape: Plot feature RecPD ancestral lineage reconstruction onto a...

View source: R/tree_plots.R

plt_recpd_apeR Documentation

Plot feature RecPD ancestral lineage reconstruction onto a species phylogenetic tree.

Description

The version of plt_recpd which uses tree plotting functions from plot.phylo.

Usage

plt_recpd_ape(
  res,
  feat,
  test = "a",
  branch.lengths = TRUE,
  axis = FALSE,
  map = c("anc_new", "anc_old"),
  direction = c("rightwards", "downwards")
)

Arguments

res

A results data.frame generated by recpd_calc().

feat

A user-provided array of at least length 2, containing named features, or indices, corresponding to the feature column/rows of the recpd_calc() results data.frame.

test

Tree mappings to plot. An array: all ('a'), none ('-a'); or combinations of tips ('t'), nodes ('n'), or branches ('b').

branch.lengths

logical. Use branch.lengths (TRUE), or plot in willow tree format (FALSE).

axis

logical. Add a y-axis of branch length to root distance.

map

Use finalized RecPD ancestral lineages ('anc_new') or preliminary state mappings ('anc_old')

direction

Plot tree in vertical ('downwards') or horizontal ('rightwards') orientation.

Value

A list returned by plot.phylo.

Author(s)

Cedoljub Bundalovic-Torma

See Also

plt_recpd for the ggtree version.

Examples

library(ape)
library(dplyr)
library(ggplot2)

##Test case for a randomly generated tree (10 tips) and 10 randomly generated
##feature presence/absence (1, 0) data.frame.

#Generate a random phylogenetic tree:
n_tip <- 10
tree <- rtree(n_tip)

#Generate 10 randomly distributed features (rows = features, columns =
#phylogenetic tree tips):
tab <- replicate(10,
                 sapply(10, function(x) sample(c(0,1), x, replace=TRUE)),
                 simplify='matrix') %>%
  t() %>%
  data.frame(check.names=FALSE) %>%
  rename_with(function(x) tree$tip.label[as.numeric(x)])


#Perform ancestral lineage reconstruction with recpd_calc():
#res <- recpd_calc(tree, tab, calc=TRUE)

#plt_recpd_ape(res, 1)


cedatorma/recpd documentation built on April 25, 2022, 10:14 p.m.