View source: R/obtainDatedPosteriorTreesMrB.R
obtainDatedPosteriorTreesMrB | R Documentation |
MrBayes is not great for getting samples of dated posterior phylogenies, or for obtaining certain summary trees from the posterior (specifically the MCCT and MAP, which are specific trees in the posterior). This is because the tree samples as returned are scaled relative to rate parameters in a separate file. This function attempts to automate the handling of multiple files (both .t tree files and .p parameter files), as well as multiple files associated with separate runs, to obtain samples of posterior trees, or summary trees such as the MCCT or MAP. These resulting trees are now scaled to units of time, but not be placed correctly on an absolute time-scale if all tips are extinct. See details of output below.
obtainDatedPosteriorTreesMrB( runFile, nRuns = 2, burnin = 0.5, outputTrees, labelPostProb = FALSE, getFixedTimes = FALSE, getRootAges = FALSE, originalNexusFile = NULL, file = NULL )
runFile |
A filename in the current directory,
or a path to a file that is either a .p
or .t file from a MrBayes analysis. This filename
and path will be used for finding additional
.t and .p files, via the |
nRuns |
The number of runs in your analysis. This variable is used for figuring out what filenames will be searched for: if you specify that you have less runs than you actually ran in reality, then some runs won't be examined in this function. Conversely, specify too many, and this function will throw an error when it cannot find files it expects but do not exist. The default for this argument (two runs) is based on the default number of runs in MrBayes. |
burnin |
The fraction of trees sampled in the posterior discarded and not returned by this function directly, nor included in calculation of summary trees. Must be a numeric value greater than 0 and less than 1. |
outputTrees |
Determines the output trees produced; for format of output, see section
on returned Value below. Must be of length one, and either |
labelPostProb |
Logical. If |
getFixedTimes |
If Please note: the code for |
getRootAges |
|
originalNexusFile |
Filename (and possibly path too) to the original NEXUS file for this analysis.
Only tried if |
file |
Filename (possibly with path) as a character string
leading to a file which will be overwritten with the output trees (or summary tree),
as a NEXUS file. If |
This function is most useful for dealing with dating
analyses in MrBayes, particularly when tip-dating
a tree with fossil taxa, as the half-compatibility
and all-compatibility summary trees offered by the
'sumt
' command in MrBayes can have issues properly
portraying summary trees from such datasets.
Depending on argument file
, the output tree or trees is either
returned directly, or instead written out in NEXUS format via
ape's write.NEXUS
function to an external file. The output
will consist either of multiple trees sampled from the post-burn-in posterior,
or will consist of a single phylogeny (a summary tree, either
the MCCT or the MAP - see the details for the argument outputTrees
).
If the argument setRootAges = TRUE
is not used,
users are warned that the resulting dated trees will
not have $root.time
elements necessary
for comparison against an absolute time-scale. Wile the
trees may be scaled to units of absolute
time now, rather than with branch lengths expressed in
the rate of character change, the dates
estimated by some phylogenetics functions in
R may give inaccurate estimates of when events
occur on the absolute time-scale if all tips are extinct.
This is because most functions for phylogenetics in R (and
elsewhere) will instead presume that the latest tip
will be at time 0 (the modern), which
may be wrong if you are using paleotree
for
analyzing paleontological datasets
consisting of entirely extinct taxa. This can be
solved by using argument getFixedTimes = TRUE
to obtain fixed tip ages, and then scaling the resulting output to absolute time using
the argument setRootAges = TRUE
, which obtains
a $root.time
element for each tree
using the functions setRootAge
and
setRootAges
(for single and multiple phylogenies).
David Bapst, with rescaling of raw output trees via code originally written by Nicholas Crouch.
When the arguments getFixedTimes = TRUE
and
setRootAges = TRUE
are used, the resulting output will be scaled to absolute time
with the available fixed ages using functions setRootAge
and setRootAges
(for single and multiple phylogenies).
This is only done if fixed ages are available and if the tree is not
being saved to an external file.
Maximum Clade Credibility trees are estimated using the function
maxCladeCred
in package phangorn.
See function link{tipDatingCompatabilitySummaryMrB}
for additional
ways of solely evaluating the topoligical information
in trees taken from MrBayes posterior samples.
## Not run: MCCT <- obtainDatedPosteriorTreesMrB( runFile = "C:\\myTipDatingAnalysis\\MrB_run_fossil_05-10-17.nex.run1.t", nRuns = 2, burnin = 0.5, outputTrees = "MCCT", file = NULL) MAP <- obtainDatedPosteriorTreesMrB( runFile = "C:\\myTipDatingAnalysis\\MrB_run_fossil_05-10-17.nex.run1.t", nRuns = 2, burnin = 0.5, getFixedTimes = TRUE, outputTrees = "MAPosteriori", file = NULL) # get a root age from the fixed ages for tips setRootAge(tree = MAP) #pull a hundred trees randomly from the posterior hundredRandomlySelectedTrees <- obtainDatedPosteriorTreesMrB( runFile = "C:\\myTipDatingAnalysis\\MrB_run_fossil_05-10-17.nex.run1.t", nRuns = 2, burnin = 0.5, getFixedTimes = TRUE, getRootAges = TRUE, outputTrees = 100, file = NULL) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.