Read Tree File in Nexus Format

View source: R/

read.nexusR Documentation

Read Tree File in Nexus Format


This function reads one or several trees in a NEXUS file.

Usage, tree.names = NULL, force.multi = FALSE)



a file name specified by either a variable of mode character, or a double-quoted string.


if there are several trees to be read, a vector of mode character giving names to the individual trees (by default, this uses the labels in the NEXUS file if these are present).


a logical value; if TRUE, an object of class "multiPhylo" is always returned even if the file contains a single tree (see details).


The present implementation tries to follow as much as possible the NEXUS standard (but see the restriction below on TRANSLATION tables). Only the block “TREES” is read; the other data can be read with other functions (e.g., read.dna, read.table, ...).

If a TRANSLATION table is present it is assumed that only the tip labels are translated and they are all translated with integers without gap. Consequently, if nodes have labels in the tree(s) they are read as they are and not looked for in the translation table. The logic behind this is that in the vast majority of cases, node labels will be support values rather than proper taxa names. This is consistent with which translates only the tip labels.

Using force.multi = TRUE when the file contains a single tree makes possible to keep the tree name (as names of the list).

‘’ tries to represent correctly trees with a badly represented root edge (i.e. with an extra pair of parentheses). For instance, the tree "((A:1,B:1):10);" will be read like "(A:1,B:1):10;" but a warning message will be issued in the former case as this is apparently not a valid Newick format. If there are two root edges (e.g., "(((A:1,B:1):10):10);"), then the tree is not read and an error message is issued.


an object of class "phylo" or "multiPhylo".


Emmanuel Paradis


Maddison, D. R., Swofford, D. L. and Maddison, W. P. (1997) NEXUS: an extensible file format for systematic information. Systematic Biology, 46, 590–621.

See Also

read.tree,, write.tree,,

ape documentation built on March 31, 2023, 6:56 p.m.