Learn R Programming

phylogram (version 1.0.0)

read.dendrogram: Read a dendrogram from parenthetic text.

Description

read.dendrogram parses a text file or character string in Newick (New Hampshire) format and creates an object of class "dendrogram".

Usage

read.dendrogram(file = "", text = NULL, edges = TRUE, ...)

Arguments

file

character string giving a valid path to the file from where to read the data.

text

optional character string in lieu of a "file" argument. If a text argument is provided instead of a file path, the data are read via a text connection.

edges

logical indicating whether edge weights provided in the Newick string should be retained in the returned object (defaults to TRUE).

...

further arguments to be passed to scan.

Value

Returns an object of class "dendrogram".

Details

There are varying interpretations of the Newick/New Hampshire text format. This function tries to adhere to the Felsenstein standard outlined here. The function supports weighted edges, labels with special metacharacters (enclosed in single quotation marks), comments (enclosed in square brackets; ignored by the parser), multifuricating nodes, and both rooted and unrooted trees. Comments enclosed in square brackets are also discarded. Inner-node labels (for example "(B:6.0,(A:5.0,C:3.0,E:4.0)Ancestor1:5.0,D:11.0);"); are also currently ignored; however, the parsing of <U+201C>label<U+201D> attributes for non-leaf dendrogram nodes will be available in a future version.

References

http://evolution.genetics.washington.edu/phylip/newicktree.html http://evolution.genetics.washington.edu/phylip/newick_doc.html

See Also

write.dendrogram writes an object of class "dendrogram" to a text string. The read.tree function in the ape package performs a similar operation for objects of class "phylo" and "multiPhylo".

Examples

Run this code
  newick <- "(A:0.1,B:0.2,(C:0.3,D:0.4):0.5);"
  x <- read.dendrogram(text = newick)
  plot(x, horiz = TRUE)

Run the code above in your browser using DataLab