phylepic {phylepic} | R Documentation |
Combine metadata (a line list) with a phylogenetic tree
Description
Some checks are performed to catch issues where the metadata and tree tips
don't match up. Any columns in metadata
that are factors have all levels
that do not appear in the data dropped.
Usage
phylepic(
tree,
metadata,
name,
date,
unmatched_tips = c("error", "drop", "keep")
)
Arguments
tree |
An object convertible to a |
metadata |
A data frame. |
name |
Column in |
date |
Column in |
unmatched_tips |
Action to take when |
Details
To reduce surprises when matching metadata
and tree
, by default an error
occurs when there are tree tips that do not have associated metadata. On the
other hand, it it expected that metadata
might contain rows that do not
correspond to the tips in tree
.
This often means that factor
columns from metadata
will contain levels
that do not appear at all in the tree. For plotting,
ggplot2::discrete_scale
normally solves this with drop = TRUE
, however
this can lead to inconsistencies when sharing the same scale across multiple
phylepic panels. phylepic()
drops unused levels in all factors so that
scales can use drop = FALSE
for consistency.
Value
An object of class "phylepic".
Examples
library(ape)
tree <- read.tree(system.file("enteric.newick", package = "phylepic"))
metadata <- read.csv(
system.file("enteric_metadata.csv", package = "phylepic")
)
phylepic(tree, metadata, name, as.Date(collection_date))