Learn R Programming

rphast (version 1.0)

rescale.tree: Scale a Tree or Subtree

Description

Rescale a tree

Usage

rescale.tree(tree, scale, subtree=NULL)

Arguments

tree
A vector of character strings, each containing a newick tree
scale
A vector of scale factors for each tree (will be recycled as necessary if shorter than trees)
subtree
If not NULL, scaling will be on subtree defined by the named node. Subtrees will be recycled as necessary if shorter than trees.

Value

  • A vector of trees whose branches have been scaled

Examples

Run this code
trees <- c("((hg18:1.0, panTro2:2.0):3.0, mm9:4.0);",
           "((hg18:0.142679,(mm9:0.083220,rn4:0.090564):0.269385):
                0.020666,canFam2:0.193569);")
rescale.tree(trees, 0.5)
rescale.tree(trees, c(0.5, 2.0))
trees <- name.ancestors(trees)
rescale.tree(trees, 0.5, c("hg18-panTro2", "hg18-mm9"))
      
#' rename.tree
trees <- c("((hg18:1.0, panTro2:2.0):3.0, mm9:4.0);",
           "((hg18:0.142679,(mm9:0.083220,rn4:0.090564):0.269385):
                0.020666,canFam2:0.193569);")
rename.tree(trees,
            old.names=c("hg18", "panTro2", "mm9", "rn4", "canFam2"),
            new.names=c("human", "chimp", "mouse", "rat", "dog"))

Run the code above in your browser using DataLab