Rev Language Reference


readTreeTrace - Function to read in a tree trace, usually produced as the output of an MCMC.

Reads trees (Nexus or Newick accepted) from a file or folder containing a set of trees and saves them in one object.

Usage

readTreeTrace(String file, String treetype, Bool unroot_nonclock, Clade outgroup, String separator/delimiter, Integer burnin, Natural thinning, Natural offset, Bool nexus, Natural nruns)

Arguments

file : String (pass by value)
The name of the tree trace file(s), or directories containing them.
treetype : String (pass by value)
The type of trees.
Default : clock
Options : clock|non-clock
unroot_nonclock : Bool (pass by value)
Remove a degree-2 root node and set the tree unrooted, if treetype is non-clock.
Default : TRUE
outgroup : Clade (pass by const reference)
The clade (consisting of one or more taxa) used as an outgroup.
Default : NULL
separator/delimiter : String (pass by value)
The field separator character. Values on each line of the file are separated by this character. If sep = "" the separator is 'white space', that is one or more spaces, tabs, newlines or carriage returns.
burnin : Integer (pass by value)
The fraction/number of samples to discard as burnin.
Default : 0.25
thinning : Natural (pass by value)
The frequency of samples to read, i.e., we will only used every n-th sample where n is defined by this argument.
Default : 1
offset : Natural (pass by value)
The offset of the first sample to read, i.e., how many samples should we skip before we take the first sample.
Default : 0
nexus : Bool (pass by value)
Whether the file to read is in NEXUS format.
Default : FALSE
nruns : Natural (pass by value)
The number of trace files with the same basename (i.e. the number of filenames with pattern _run_.trees)
Default : 1

Return Type

Details

Either a file name or a directory must be provided as argument. If a folder is provided, all the files that contain trees in that directory are read in the same object. `tree_trace = readTreeTrace(..., nruns = 1)` returns a `TraceTree` object. `tree_trace = readTreeTrace(..., nruns > 1)` returns a `TraceTree[]` object, in which `tree_trace[n]` corresponds to the trace of run `n`. The resulting `TraceTree` object stores every `thinning`th sample from a file, starting at the sample numbered `offset + 1`.

Example

# read a tree trace
tree_trace = readTreeTrace("my_filename.tree", treetype="clock", burnin=0.5)

# make a summary maximum clade credibility (MCC) tree
mcc_tree = mccTree(trace=tree_trace, file="mcc.tree")

See Also