Learn R Programming

ggphylo (version 0.1)

tree.translate: Translates all labels in the tree based on a list of label mappings.

Description

Translates all labels in the tree based on a list of label mappings.

Usage

tree.translate(phylo, map)

Arguments

phylo
input phylo object
map
a list of key-value pairs by which to translate node labels

Value

phylo, the original tree with all matching labels mapped to their new values.

Examples

Run this code
# Translate a tree of NCBI taxa to their common names
taxon.tree <- tree.read('((9606,9598),9593);')
taxon.map <- list('9606'='Human', '9598'='Chimpanzee', '9593'='Gorilla')
readable.tree <- tree.translate(taxon.tree, taxon.map)
print(as.character(readable.tree)) # ((Human,Chimpanzee),Gorilla)

Run the code above in your browser using DataLab