plt_recpdcor: Plot RecPD ancestral lineage reconstructions for a pair of...

View source: R/tree_plots.R

plt_recpdcorR Documentation

Plot RecPD ancestral lineage reconstructions for a pair of features onto a species phylogenetic tree.

Description

Combines the RecPD lineage reconstructions of two features, incidating ancestral branches which are shared, unique, or absent between them.

Usage

plt_recpdcor(
  res,
  feats,
  lab = NULL,
  colnames.angle = 45,
  colnames.offset = 0,
  sep.col = "transparent",
  offset = 0,
  width = 0.1,
  tree.format = c("willow", "phylo"),
  direction = c("v", "h")
)

Arguments

res

A results data.frame generated by recpd_calc().

feats

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

lab

An array of labels for the presence/absence strips (features).

colnames.angle

Angle of feature labels.

colnames.offset

Offset of feature labels.

sep.col

Separator line colour of feature presence/absence strips. Set to 'transparent' to remove.

offset

Offset of feature presence/absence strips from the phylogenetic tree.

width

Relative width of the feature presence/absence strips to the phylogenetic trree.

tree.format

Plot tree as phylogram ('phylo') or in willow-tree ('willow') format.

direction

Plotting direction of the tree: either vertical ('v') or horizontal ('h').

Value

A ggtree object.

Author(s)

Cedoljub Bundalovic-Torma

See Also

plt_recpd

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)

#Plot the combined lineages of features 1 and 2:
#plt_recpdcor(res, c(1,2))


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