Skip to contents

Create a Newick formatted tree from a data.frame of taxonomic assignments

Usage

makeNewick(
  taxa,
  naSub = "_",
  excludeTerminalNAs = FALSE,
  quote = NULL,
  terminator = ";"
)

Arguments

taxa

a matrix with a row for each leaf of the tree and a column for each taxonomic classification e.g. the output from getTaxonomy

naSub

a character string to substitute in place of NAs in the taxonomy

excludeTerminalNAs

If TRUE then do not output nodes downstream of the last named taxonomic level in a row

quote

If not NULL then wrap all entries with this character

terminator

If not NULL then add this character to the end of the tree

Value

a string giving a Newick formatted tree

See also

Examples

taxa<-matrix(c('A','A','A','B','B','C','D','D','E','F','G','H'),nrow=3)
makeNewick(taxa)
#> [1] "((((F,G)D)B,((H)E)C)A);"
taxa<-matrix(c('A','A','A','B',NA,'C','D','D',NA,'F','G',NA),nrow=3)
makeNewick(taxa)
#> [1] "((((F)D)B,((G)D)_,((_)_)C)A);"
makeNewick(taxa,excludeTerminalNAs=TRUE)
#> [1] "((((F)D)B,((G)D)_,C)A);"
makeNewick(taxa,quote="'")
#> [1] "(((('F')'D')'B',(('G')'D')_,((_)_)'C')'A');"