Skip to contents

Creates a Newick tree from a TreeMan object.

Usage

writeTree(
  tree,
  file,
  append = FALSE,
  ndLabels = function(nd) {
     return(NULL)
 },
  parallel = FALSE,
  progress = "none"
)

Arguments

tree

TreeMan object

file

file path

append

T/F append tree to already existing file

ndLabels

node label function

parallel

logical, make parallel?

progress

name of the progress bar to use, see create_progress_bar

Details

The ndLabels argument can be used to add a user defined node label in the Newick tree. It should take only 1 argument, nd, the node represented as a list. It should only return a single character value that can be added to a newick string.

Examples


tree <- randTree(10)
# write out the tree with node labels as IDs
ndLabels <- function(n) {
  n[["id"]]
}
writeTree(tree, file = "example.tre", ndLabels = ndLabels)
#> NULL
file.remove("example.tre")
#> [1] TRUE