Description Usage Arguments Details Value Author(s) Examples
These functions read annotated trees from files in Newick or NEXUS
formats. Except for the annotations, these functions mimic ape's
functions read.tree
and read.nexus
.
Annotations are ordered by edges, i.e. matching the edge.length
slot of a phylo
object.
1 2 3 | read.annotated.tree(file="", text = NULL, tree.names = NULL, skip = 0,
comment.char = "#", keep.multi = FALSE, ...)
read.annotated.nexus(file, tree.names = NULL)
|
file |
a file name specified by either a variable of mode character, or a double-quoted string; if ‘file = ""’ (the default) then the tree is input on the keyboard, the entry being terminated with a blank line |
text |
alternatively, the name of a variable of mode character which contains the tree(s) in parenthetic format. By default, this is ignored (set to ‘NULL’, meaning that the tree is read in a file); if ‘text’ is not ‘NULL’, then the argument ‘file’ is ignored. |
tree.names |
if there are several trees to be read, a vector of mode character that gives names to the individual trees; if ‘NULL’ (the default), the trees are named ‘"tree1"’, ‘"tree2"’, ... |
skip |
the number of lines of the input file to skip before beginning to read data (this is passed directly to‘ scan()’). |
comment.char |
a single character, the remaining of the line after this character is ignored (this is passed directly to ‘scan()’). |
keep.multi |
if ‘TRUE’ and ‘tree.names = NULL’ then single trees are returned in ‘"multiPhylo"’ format, with any name that is present (see details). Default is ‘FALSE’. |
... |
further arguments to be passed to ‘scan()’. |
See read.nexus
in the ape package for a specification of NEXUS formatted
tree files. This function additionally extracts BEAST annotations for all
branches/nodes in the trees and returns these annotations as lists of lists in
the resulting "phylo" objects
An object of class "phylo" with an additional slot called annotations. This slot is a list indexed by the nodes.
Marc Suchard
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | ## Not run:
## read annotated tree from Nexus file
## (note: do not use 'system file' for your own file!)
tre <- read.annotated.nexus(system.file("files/BEAST-expl.nex", package="OutbreakTools"))
## ladderize the tree
tre <- ladderize(tre)
## this tree has annotations
##
names(tre)
class(tre$annotations)
length(tre$annotations)
## for each edge (each edge is identified by a terminal node), we have:
tre$annotations[[1]]
names(tre$annotations[[1]])
## extract rates from annotations
rates <- unlist(sapply(tre$annotations, function(e) e$rate_median))
## plot tree, show median rates as colors
plot(tre, show.tip=FALSE, edge.col=num2col(rates, col.pal=seasun))
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.