View source: R/createMrBayesTipDatingNexus.R
createMrBayesTipDatingNexus | R Documentation |
This function is meant to expedite the creation of NEXUS files formatted
for performing tip-dating analyses in the popular phylogenetics software MrBayes,
particularly clock-less tip-dating analyses executed with 'empty' morphological matrices
(i.e. where all taxa are coded for a single missing character), although a pre-existing
morphological matrix can also be input by the user (see argument origNexusFile
).
Under some options, this pre-existing matrix may be edited by this function.
The resulting full NEXUS script is output as a set of character strings either
printed to the R console, or output to file which is then overwritten.
createMrBayesTipDatingNexus( tipTimes, outgroupTaxa = NULL, treeConstraints = NULL, ageCalibrationType, whichAppearance = "first", treeAgeOffset, minTreeAge = NULL, collapseUniform = TRUE, anchorTaxon = TRUE, newFile = NULL, origNexusFile = NULL, parseOriginalNexus = TRUE, createEmptyMorphMat = TRUE, orderedChars = NULL, morphModel = "strong", morphFiltered = "parsInf", runName = NULL, ngen = "100000000", doNotRun = FALSE, autoCloseMrB = FALSE, cleanNames = TRUE, printExecute = TRUE )
tipTimes |
This input may be either: (a) a |
outgroupTaxa |
A vector of type 'character', containing taxon names designating the outgroup.
All taxa not listed in the outgroup will be constrained to be a monophyletic ingroup, for sake of rooting
the resulting dated tree.
Either |
treeConstraints |
An object of class |
ageCalibrationType |
This argument decides how age calibrations are defined,
and currently allows for four options: |
whichAppearance |
Which appearance date of the taxa should be used:
their |
treeAgeOffset |
A parameter given by the user controlling the offset between the minimum and expected tree age prior. mean tree age for the offset exponential prior on tree age will be set to the minimum tree age, plus this offset value. Thus, an offset of 10 million years would equate to a prior assuming that the expected tree age is around 10 million years before the minimum age. |
minTreeAge |
if |
collapseUniform |
MrBayes won't accept uniform age priors where the maximum and
minimum age are identical (i.e. its actually a fixed age). Thus, if this argument
is |
anchorTaxon |
This argument may be a logical (default is |
newFile |
Filename (possibly with path) as a character string
leading to a file which will be overwritten with the output tip age calibrations.
If |
origNexusFile |
Filename (possibly with path) as a character
string leading to a NEXUS text file, presumably containing a matrix
of character date formated for MrBayes. If supplied
(it does not need to be supplied), the listed file is read as a text file, and
concatenated with the MrBayes script produced by this function, so as to
reproduce the original NEXUS matrix for executing in MrBayes.
Note that the taxa in this NEXUS file are NOT checked against the user
input |
parseOriginalNexus |
If |
createEmptyMorphMat |
If |
orderedChars |
Should be a vector of numbers, indicating which characters should have their
character-type in MrBayes changed to 'ordered'.
If |
morphModel |
This argument can be used to switch between two end-member models of
morphological evolution in MrBayes, here named 'strong' and 'relaxed', for the 'strong assumptions'
and 'relaxed assumptions' models described by Bapst et al. (2018, Syst. Biol.).
The default is a model which makes very 'strong' assumptions about the process of morphological evolution,
while the 'relaxed' alternative allows for considerably more heterogeneity in the rate
of morphological evolution across characters, and in the forward and reverse transition
rates between states. Also see argument |
morphFiltered |
This argument controls what type of filtering the input
morphological data is assumed to have been collected under. The likelihood of
the character data will be modified to take into account the apparent filtering
(Lewis, 2001; Allman et al., 2010). The default value, |
runName |
The name of the run, used for naming the log files and MCMC output files.
If not set, the name will be taken from the name given for outputting
the NEXUS script ( |
ngen |
Number of generations to set the MCMCMC to run for.
Default ( |
doNotRun |
If |
autoCloseMrB |
If |
cleanNames |
If |
printExecute |
If |
Users must supply a data set of tip ages (in various formats),
which are used to construct age calibrations commands on the tip taxa
(via paleotree function createMrBayesTipCalibrations
).
The user must also supply some topological constraint:
either a set of taxa designated as the outgroup, which
is then converted into a command constraining
the monophyly on the ingroup taxa, which is presumed to be
all taxa not listed in the outgroup.
Alternatively, a user may supply a tree which is then
converted into a series of hard topological constraints
(via function createMrBayesConstraints
.
Both types of topological constraints cannot be applied.
Many of the options available with createMrBayesTipCalibrations
are available with this function, allowing users to choose between fixed
calibrations or uniform priors that approximate stratigraphic uncertainty.
In addition, the user may also supply a path to a text file
presumed to be a NEXUS file containing character
data formatted for use with MrBayes.
The taxa listed in tipTimes
must match the taxa in
treeConstraints
, if such is supplied. If supplied, the taxa in outgroupTaxa
must be contained within this same set of taxa. These all must have matches
in the set of taxa in origNexusFile
, if provided and
if parseOriginalNexus
is TRUE
.
Note that because the same set of taxa must be contained in all inputs,
relationships are constrained as 'hard' constraints, rather than 'partial' constraints,
which allows some taxa to float across a partially fixed topology.
See the documentation for createMrBayesConstraints
,
for more details.
If argument newFile
is NULL
, then the text of the
generated NEXUS script is output to the console as a series of character strings.
This function allows a user to take an undated phylogenetic tree in R, and a set of age estimates for the taxa on that tree, and produce a posterior sample of dated trees using the MCMCMC in MrBayes, while treating an 'empty' morphological matrix as an uninformative set of missing characters. This 'clock-less tip-dating' approach is essentially an alternative to the cal3 method in paleotree, sharing the same fundamental theoretical model (a version of the fossilized birth-death model), but with a better algorithm that considers the whole tree simultaneously, rather than evaluating each node individually, from the root up to the tips (as cal3 does it, and which may cause artifacts). That said, cal3 still has a few advantages: tip-dating as of April 2017 still only treats OTUs as point observations, contained in a single time-point, while cal3 can consider taxa as having durations with first and last occurrences. This means it may be more straightforward to assess the extent of budding cladogenesis patterns of ancestor-descendant relationships in cal3, than in tip-dating.
David W. Bapst. This code was produced as part of a project funded by National Science Foundation grant EAR-1147537 to S. J. Carlson.
The basic MrBayes commands utilized in the output script are a collection of best practices taken from studying NEXUS files supplied by April Wright, William Gearty, Graham Slater, Davey Wright, and guided by the recommendations of Matzke and Wright, 2016 in Biology Letters.
The basic fundamentals of tip-dating, and tip-dating with the fossilized birth-death model are introduced in these two papers:
Ronquist, F., S. Klopfstein, L. Vilhelmsen, S. Schulmeister, D. L. Murray, and A. P. Rasnitsyn. 2012. A Total-Evidence Approach to Dating with Fossils, Applied to the Early Radiation of the Hymenoptera. Systematic Biology 61(6):973-999.
Zhang, C., T. Stadler, S. Klopfstein, T. A. Heath, and F. Ronquist. 2016. Total-Evidence Dating under the Fossilized Birth-Death Process. Systematic Biology 65(2):228-249.
For recommended best practices in tip-dating analyses, please see:
Matzke, N. J., and A. Wright. 2016. Inferring node dates from tip dates in fossil Canidae: the importance of tree priors. Biology Letters 12(8).
The rationale behind the two alternative morphological models are described in more detail here:
Bapst, D. W., H. A. Schreiber, and S. J. Carlson. 2018. Combined Analysis of Extant Rhynchonellida (Brachiopoda) using Morphological and Molecular Data. Systematic Biology 67(1):32-48.
This function wraps various aspects of the functions createMrBayesConstraints
and the function createMrBayesTipCalibrations
. In many ways, this functionality is a
replacement for the probabilistic dating method represented by the cal3
dating functions.
For putting the posterior estimated trees on an absolute time scale, see
functions obtainDatedPosteriorTreesMrB
. Use the argument getFixedTimes = TRUE
if you used a taxon with a fixed age, and function setRootAges
to set the root age.
# load retiolitid dataset data(retiolitinae) # let's try making a NEXUS file! # Use a uniform prior, with a 10 million year offset for # the expected tree age from the earliest first appearance # Also set average tree age to be 10 Ma earlier than first FAD outgroupRetio <- "Rotaretiolites" # this taxon will now be sister to all other included taxa # the following will create a NEXUS file # with an 'empty' morph matrix # where the only topological constraint is on ingroup monophyly # Probably shouldn't do this: leaves too much to the FBD prior # with doNotRun set to TRUE for troubleshooting createMrBayesTipDatingNexus( tipTimes = retioRanges, outgroupTaxa = outgroupRetio, treeConstraints = NULL, ageCalibrationType = "uniformRange", whichAppearance = "first", treeAgeOffset = 10, newFile = NULL, origNexusFile = NULL, createEmptyMorphMat = TRUE, runName = "retio_dating", doNotRun = TRUE ) # let's try it with a tree for topological constraints # this requires setting outgroupTaxa to NULL # let's also set doNotRun to FALSE createMrBayesTipDatingNexus( tipTimes = retioRanges, outgroupTaxa = NULL, treeConstraints = retioTree, ageCalibrationType = "uniformRange", whichAppearance = "first", treeAgeOffset = 10, newFile = NULL, origNexusFile = NULL, createEmptyMorphMat = TRUE, runName = "retio_dating", doNotRun = FALSE ) # the above is essentially cal3 with a better algorithm, # and no need for a priori rate estimates # just need a tree and age estimates for the tips! #################################################### # some more variations for testing purposes # no morph matrix supplied or generated # you'll need to manually append to an existing NEXUS file createMrBayesTipDatingNexus( tipTimes = retioRanges, outgroupTaxa = NULL, treeConstraints = retioTree, ageCalibrationType = "uniformRange", whichAppearance = "first", treeAgeOffset = 10, newFile = NULL, origNexusFile = NULL, createEmptyMorphMat = FALSE, runName = "retio_dating", doNotRun = TRUE ) ## Not run: # let's actually try writing an example with topological constraints # to file and see what happens # here's my super secret MrBayes directory file <- "D:\\dave\\workspace\\mrbayes\\exampleRetio.nex" createMrBayesTipDatingNexus( tipTimes = retioRanges, outgroupTaxa = NULL, treeConstraints = retioTree, ageCalibrationType = "uniformRange", whichAppearance = "first", treeAgeOffset = 10, newFile = file, origNexusFile = NULL, createEmptyMorphMat = TRUE, runName = "retio_dating", doNotRun = FALSE ) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.