An interface to the Nexus Class Library which allows parsing of NEXUS, Newick and other phylogenetic tree file formats. It provides elements of the file that can be used to build phylogenetic objects such as ape's 'phylo' or phylobase's 'phylo4(d)'. This functionality is demonstrated with 'read_newick_phylo()' and 'read_nexus_phylo()'.
This R package provides an interface to the C++ library NCL. It can parse efficiently common file formats used to store phylogenetic trees, especially NEXUS and Newick files.
This package is primarily intended to be used by package developers as it
extracts the elements needed to build R objects that represent the content of
the file. For instance, phylobase
rncl to extract trees and/or data stored in NEXUS and Newick files to
create objects of class
The package however provides two functions for users:
read_newick_phylo(). They read NEXUS and Newick files respectively, and return
multiPhylo object from the package
ape. These functions differ from those
found in ape (respectively
rncl functions can
read trees with singletons, and missing branch lengths. However,
to the NEXUS standards and only accepts tip labels without white spaces and tip
labels cannot be duplicated in the same tree.
Because this package contains some C++ code, it can be tricky to build if you
are using Windows. Unless you need a feature only available on GitHub, install
rncl from CRAN.
Otherwise, you can obtain a binary version from
the AppVeyor badge on top is gray, in which case you can download an older
version or come back in a few minutes, or red meaning the current version is
broken and you need to get an older version). Once in appveyor, look for the
X.Y.Z represent the version number (e.g.,
rncl_0.4.0.zip). Then you can install this compiled version of the package
directly from R.
The re-numbering of the edge matrix to deal with singleton is now performed in C++, leading to improved speed (about 3x for a 1700 tip tree) (#11).
A progress bar is displayed when removing the singleton, which is useful when the tree is very large.
rnclnow allows the parsing of tree files where the trees contain a subset of the taxa listed in the TAXA block.
rncl now allows the parsing of tree files that contain some missing edge
lengths, using the
missing_edge_length argument in the
read_nexus_phylo. By default, if a tree has at least one missing edge
length, all edge lengths are dropped. Alternatively, the user can provide a
numeric value that will be used to replace all missing edge lengths. (#33 from
read_nexus_phylo return a list of trees, the
elements of the list are named according to the names found in the tree file.
Parsing tree files is now quiet, the default output of NCL is silenced. Because of the implementation of this output, it's difficult to give control to the user over this, but it's probably best to keep it quiet rather than having unneeded messages pollute the screen.
The documentation of the function
rncl is improved.
make_phylo is now deprecated and will be removed in the next
The option spacesAsUnderscore now also applies to the slot
taxaNames and not
only to the elements of the slot
If the file parsed contains trees that only include a subset of the taxa listed in the NEXUS taxa block, the function fails more explicitly.
treeNameshad duplicated values for each tree name.