Title: | Prepare MCMCtree Analyses and Plot Bayesian Divergence Time Analyses Estimates on Trees |
Version: | 1.1 |
Author: | Mark Puttick [aut,cre], Pascal Title [ctb] |
Maintainer: | Mark Puttick <mark.puttick@bristol.ac.uk> |
Description: | Provides functions to prepare time priors for 'MCMCtree' analyses in the 'PAML' software from Yang (2007)<doi:10.1093/molbev/msm088> and plot time-scaled phylogenies from any Bayesian divergence time analysis. Most time-calibrated node prior distributions require user-specified parameters. The package provides functions to refine these parameters, so that the resulting prior distributions accurately reflect confidence in known, usually fossil, time information. These functions also enable users to visualise distributions and write 'MCMCtree' ready input files. Additionally, the package supplies flexible functions to visualise age uncertainty on a plotted tree with using node bars, using branch widths proportional to the age uncertainty, or by plotting the full posterior distributions on nodes. Time-scaled phylogenetic plots can be visualised with absolute and geological timescales . All plotting functions are applicable with output from any Bayesian software, not just 'MCMCtree'. |
Depends: | R (≥ 3.3), ape (≥ 3.0-7), sn, coda |
Imports: | methods, utils, stats, grDevices, graphics |
License: | GPL-2 | GPL-3 [expanded from: GPL (≥ 2)] |
Encoding: | UTF-8 |
LazyData: | true |
RoxygenNote: | 6.1.1 |
Suggests: | knitr, rmarkdown |
VignetteBuilder: | knitr |
NeedsCompilation: | no |
Packaged: | 2019-05-21 19:24:11 UTC; markputtick |
Repository: | CRAN |
Date/Publication: | 2019-05-21 22:20:31 UTC |
Plot time-scaled phylogenies
Description
Plot time-scaled phylogenies with node uncertainty and timescale
Usage
MCMC.tree.plot(phy = NULL, analysis.type = "MCMCtree",
MCMC.chain = NULL, node.ages = NULL, directory.files = NULL,
plot.type = "phylogram", build.tree = FALSE, node.method = "bar",
all.nodes = NULL, add.time.scale = TRUE, add.abs.time = TRUE,
scale.res = "Epoch", label.timescale.names = FALSE,
time.correction = 1, col.age = "blue", tip.lengths = FALSE,
density.col = "#00000050", density.border.col = "#00000080",
cex.tips = 1, show.tip.label = TRUE, col.tree = "black",
tip.color = "black", lwd.bar = 1, grey.bars = TRUE, cex.age = 1,
cex.labels = 1, cex.names = 1, relative.height = 0.08,
tip.bar.col = "#ff000050", burn.in = 0.25,
distribution.height = 0.8, abs.age.mgp = c(3, 0.35, 0),
abs.age.lwd.ticks = 0.7, abs.age.lwd = 0, tck.abs.age = -0.01,
abs.age.line = -0.4, pos.age = NULL, n.runs = 2,
ladderize.tree = TRUE, ...)
Arguments
phy |
A timescaled phylogeny, unless analysis.type="MCMCtree" and build.tree=TRUE |
analysis.type |
The method used to generate the time-scale tree, one of MCMCtree, MrBayes, RevBayes, or User. |
MCMC.chain |
The full posterior of age estimates for all nodes (default NULL) |
node.ages |
List of user-supplied node ages applicable for analysis.type user. Either all nodes or a selection of nodes. Each list element must be named with its corresponding node label from the APE format. |
directory.files |
The directory for files to summarise for MrBayes and RevBayes analyses |
plot.type |
The plotting method for the phylogram corresponding to the APE definition. Phylogram is available for all analysis types, but cladogram is only avilable for MCMCtree analyses at present. Type distributions plots a phylogram with stats::density distributions on each of the nodes. |
build.tree |
Logical. Only applicable to MCMCtree analyses, whether to timescale the phylogeny based on the full MCMC chain |
node.method |
For plot.type phylogram the method to dispay age uncertainty on each node, either bar, node.length, or full.length. If 'none' is supplied plotting node uncertainty is suppressed. |
all.nodes |
If NULL (default) node uncertainty is plotted on all nodes. If node numbers are supplied, only these nodes will be labelled with uncertainty. |
add.time.scale |
Logical. Adds a timescale to the plotted phylogeny. |
add.abs.time |
Logical. Adds an absolute timescale alongside the geological timescale. Only applicable if add.time.scale is TRUE |
scale.res |
The geological age designation to add to the plot can be one or a combination of Eon, Period, Epoch, Age. The order of plot (from bottom to top) is the same as the supplied order. Subsequent arguments add.abs.time and grey.bars are based on the last supplied age designation. |
label.timescale.names |
Logical. Add names (Eon, Period, Epoch, Age, Ma) to axis if timescale used |
time.correction |
Number to place branch lengths and age estimates in absolute time, deafult to one. |
col.age |
The colouring of the node.method bars to summarise node age uncertainty |
tip.lengths |
Logical. If the tree contains non-present tip ages, the age uncertainty associated with them will be added to the plot |
density.col |
Colour of the node distributions (if analysis.type=distributions) |
density.border.col |
Colour of the node distributions (if analysis.type=distributions) borders |
cex.tips |
Size of the phylogeny tip labels |
show.tip.label |
Logical. Should the tree tip labels be displayed |
col.tree |
Colour of the phylogeny edges |
tip.color |
Colour of the phylogeny tip labels |
lwd.bar |
Width of the bar to summarise age uncertainty, applicable only if plot.type is phylogram and node.method is bar |
grey.bars |
Logical. Should grey bars be used to signify time bins, applicable only if add.time.scale is TRUE |
cex.age |
Size of the labels for the absolute timescale |
cex.labels |
Size of the labels for the geological timescale |
cex.names |
Logical. Add label.timescale.names, if applicable. |
relative.height |
the relative height of the timescale labels |
tip.bar.col |
The colour of uncertainty around non-contemporary tips |
burn.in |
The number of points in the chain to discard for MrBayes and RevBayes analyses |
distribution.height |
The relative height of node distributions when plot.type is distributions measured as the relative height of the descendent node |
abs.age.mgp |
mgp values for the absolute age axis, only applicable if add.abs.time is TRUE |
abs.age.lwd.ticks |
lwd values for the absolute age axis ticks, only applicable if add.abs.time is TRUE |
abs.age.lwd |
lwd values for the absolute age axis horizontal line, only applicable if add.abs.time is TRUE |
tck.abs.age |
tck values for the absolute age axis tick height, only applicable if add.abs.time is TRUE |
abs.age.line |
line correction for the absolute age axis tick, only applicable if add.abs.time is TRUE |
pos.age |
position position of absolute age axis |
n.runs |
For analysis.type mrbayes, the number of independent chains to summarise |
ladderize.tree |
Logical. Plot a ladderized tree (TRUE) or not (FALSE) |
... |
further arguments to be used in |
Details
The primary inputs for the 'method' options are outputs from analysis conducting using MCMCtree, MrBayes, RevBayes, or User.
For analyses under the 'MCMCtree' option (the default) the function only requires a 'FigTree' output from MCMCtree analysis or the full MCMCtree posterior. For option "MrBayes" and "RevBayes", the method argument takes the user-supplied directory address in which all the output files are stored.
For the option 'User' the function requires a full posterior distribution and time-scaled phylogeny. This function can take any posterior distribution, but it may require some manipulation. The argument node.ages in MCMC.tree.plot takes a named list containing the posterior ages for each node, with the name of each element corresponding to the node in the phylogeny.
Value
If plot=TRUE plot of distributions in file 'pdfOutput' written to current working directory
Author(s)
Mark Puttick
Examples
data(MCMCtree.output)
attach(MCMCtree.output)
## if it is necessary to read in file manually
## MCMCtree.posterior <- read.csv("mcmc.posterior.file.directory", sep="\t")
MCMCtree.file <- readMCMCtree(MCMCtree.phy, from.file=FALSE)$apePhy
MCMC.tree.plot(phy=MCMCtree.file, analysis.type="MCMCtree",
MCMC.chain=MCMCtree.posterior, plot.type="distributions", cex.tips=0.5)
MCMCtree.output
Description
Phylogeny output from MCMCtree, and posterior estimates from MCMCtree 'out' file from a re-analysis of data from Morris et al. 2018
Usage
data(MCMCtree.output)
Format
An object of class list
of length 2.
References
Morris et al. 2018
Examples
data(MCMCtree.output)
attach(MCMCtree.output)
names(MCMCtree.output)
MCMCtreePhy
Description
Wrapper function to estimate node distributions and add them to tree and output MCMCtree format phylogeny file. If parameter values are in vectors shorter than the number of nodes they are recycled.
Usage
MCMCtreePhy(phy, minAges, maxAges, monoGroups, method = c("cauchy",
"upper", "bound", "gamma", "skewNormal", "skewT", "fixed"),
offset = 0.1, df = 1, shape = 50, scale = 1.5, minProb = 1e-08,
addMode = 0, maxProb = 0.975, rightTail = 0.025, alpha = 188,
beta = 100, estimateScale = TRUE, estimateShape = FALSE,
estimateMode = FALSE, estimateAlpha = TRUE, estimateBeta = FALSE,
plot = FALSE, pdfOutput = "nodeDistributions.pdf",
writeMCMCtree = TRUE, MCMCtreeName = "output.tre")
Arguments
phy |
fully resolved phylogeny in ape format |
minAges |
vector of minimum age bounds for nodes matching order in monoGroups |
maxAges |
vector of maximum age bounds for nodes matching order in monoGroups |
monoGroups |
list with each element containing species that define a node of interest |
method |
vector of the type of calibration distribution for each node |
offset |
offset value for distribution (default = 50) |
df |
degrees of freedom for skew-t distribution (default = 1) |
shape |
shape value for skew-t distribution (default = 50) |
scale |
scale value for distribution (default = 1.5) |
minProb |
probability of left tail (minimum bound) - default to hard minimum (minProb=0) |
addMode |
addition to the minimum age to give the location of the distribution |
maxProb |
probability of right tail (maximum bound. default = 0.975) |
rightTail |
probability of right tail (maximum bound default = 0.025) |
alpha |
alpha value for gamma distribution (default = 188) |
beta |
beta value for gamma distribution (default = 2690) |
estimateScale |
logical specifying whether to estimate scale with a given shape value (default = TRUE) |
estimateShape |
logical specifying whether to estimate shape with a given scale value |
estimateMode |
logical speciftying whether to estimate the scale that produces probabilities of each tail that corresponds roughly to the values given by minProb (lower tail) and maxProb (upper tail) |
estimateAlpha |
logical specifying whether to estimate alpha with a given beta value (default = TRUE) |
estimateBeta |
logical specifying whether to estimate beta with a given alpha value (default = FALSE) |
plot |
logical specifying whether to plot to PDF |
pdfOutput |
pdf output file name |
writeMCMCtree |
logical whether to write tree in format that is compatible with MCMCTree to file |
MCMCtreeName |
MCMCtree.output file name |
Value
list containing node estimates for each distribution
"parameters" estimated parameters for each node
"apePhy" phylogeny in APE format with node labels showing node distributions
"MCMCtree" phylogeny in MCMCtree format
"nodeLabels" node labels in MCMCtreeR format
If plot=TRUE plot of distributions in file 'pdfOutput' written to current working directory
If writeMCMCtree=TRUE tree in MCMCtree format in file "MCMCtreeName" written to current working directory
Author(s)
Mark Puttick
Examples
data(apeData)
attach(apeData)
## extract taxon descending from calibrated nodes 8, 10, 11, 13
## these nodes can be visualised using plot.phylo
## and nodelabels from ape
monophyleticGroups <- tipDes(apeData$apeTree, c(8,10,11,13))
minimumTimes <- c("nodeOne"=15, "nodeTwo"=6,
"nodeThree"=8, "nodeFour"=13) / 10
maximumTimes <- c("nodeOne" = 30, "nodeTwo" = 12,
"nodeThree"=12, "nodeFour" = 20) / 10
# Cauchy, upper age, bound, and gamma applied individually to each node
MCMCtreePhy(phy=apeTree, minAge=minimumTimes, maxAge=maximumTimes,
monoGroups=monophyleticGroups, plot=FALSE,
method=c("cauchy", "upper", "bound", "gamma"), writeMCMCtree=FALSE)
ApeData Ape phylogeny in ape format, monophyletic clades, and maximum and minimum ages
Description
ApeData Ape phylogeny in ape format, monophyletic clades, and maximum and minimum ages
Usage
data(apeData)
Format
An object of class list
of length 4.
References
Yang 2014
Examples
data(apeData)
attach(apeData)
names(apeData)
Estimate a Uniform Distribution for MCMCtree
Description
Estimate the paramaters of a soft-bounded uniform distribution and output trees for MCMCtree input
Usage
estimateBound(minAge, maxAge, minProb = 0.025, rightTail = 0.025, phy,
monoGroups, writeMCMCtree = FALSE, plot = TRUE,
MCMCtreeName = "bound.tre", pdfOutput = "uniformPlot.pdf")
Arguments
minAge |
vector of minimum age bounds for nodes matching order in monoGroups |
maxAge |
vector of maximum age bounds for nodes matching order in monoGroups |
minProb |
probability of left tail (minimum bound) - default to hard minimum (minProb=0) |
rightTail |
probability of right tail (maximum bound default = 0.975) |
phy |
fully resolved phylogeny in ape format |
monoGroups |
list with each element containing species that define a node of interest |
writeMCMCtree |
logical whether to write tree in format that is compatible with MCMCTree to file |
plot |
logical specifying whether to plot to PDF |
MCMCtreeName |
MCMCtree.output file name |
pdfOutput |
pdf output file name |
Value
list containing node estimates for each distribution
"parameters" estimated parameters for each node
"apePhy" phylogeny in ape format with node labels showing node distributions
"MCMCtree" phylogeny in MCMCtreeR format
"nodeLabels" node labels in MCMCtreeR format
If plot=TRUE plot of distributions in file 'pdfOutput' written to current working directory
If writeMCMCtree=TRUE tree in MCMCtree format in file "MCMCtreeName" written to current working directory
Author(s)
Mark Puttick
Examples
data(apeData)
attach(apeData)
## extract taxon descending from calibrated nodes 8, 10, 11, 13
## these nodes can be visualised using plot.phylo
## and nodelabels from ape
monophyleticGroups <- tipDes(apeData$apeTree, c(8,10,11,13))
minimumTimes <- c("nodeOne"=15, "nodeTwo"=6,
"nodeThree"=8, "nodeFour"=13) / 10
maximumTimes <- c("nodeOne" = 30, "nodeTwo" = 12,
"nodeThree"=12, "nodeFour" = 20) / 10
estimateBound(minAge=minimumTimes, maxAge=maximumTimes,
monoGroups=monophyleticGroups, phy=apeTree, plot=FALSE)$MCMCtree
Estimate Cauchy Distribution for MCMCtree
Description
Estimate the offset and scale paramaters of a soft-tailed cauchy distribution and output trees for MCMCtree input
Usage
estimateCauchy(minAge, maxAge, phy, monoGroups, scale = 1.5,
offset = 50, estimateScale = TRUE, minProb = 0, maxProb = 0.975,
plot = FALSE, pdfOutput = "cauchyPlot.pdf", writeMCMCtree = FALSE,
MCMCtreeName = "cauchyInput.tre")
Arguments
minAge |
vector of minimum age bounds for nodes matching order in monoGroups |
maxAge |
vector of maximum age bounds for nodes matching order in monoGroups |
phy |
fully resolved phylogeny in ape format |
monoGroups |
list with each element containing species that define a node of interest |
scale |
scale value for cauchy distribution (default = 1.5) (c in PAML manual page 49) |
offset |
offset value for cauchy distribution (default = 50) (p in PAML manual page 49) |
estimateScale |
logical specifying whether to estimate scale with a given shape value (default = TRUE) |
minProb |
probability of left tail (minimum bound) - default to hard minimum (minProb=0) |
maxProb |
probability of right tail (maximum bound. default = 0.975) |
plot |
logical specifying whether to plot to PDF |
pdfOutput |
pdf output file name |
writeMCMCtree |
logical whether to write tree in format that is compatible with MCMCTree to file |
MCMCtreeName |
MCMCtree.output file name |
Value
list containing node estimates for each distribution
"parameters" estimated parameters for each node
"apePhy" phylogeny in ape format with node labels showing node distributions
"MCMCtree" phylogeny in MCMCtree format
"nodeLabels" node labels in MCMCtreeR format
If plot=TRUE plot of distributions in file 'pdfOutput' written to current working directory
If writeMCMCtree=TRUE tree in MCMCtree format in file "MCMCtreeName" written to current working directory
Author(s)
Mark Puttick data(apeData) attach(apeData) ## extract taxon descending from calibrated nodes 8, 10, 11, 13 ## these nodes can be visualised using plot.phylo ## and nodelabels from ape monophyleticGroups <- tipDes(apeData$apeTree, c(8,10,11,13)) minimumTimes <- c("nodeOne"=15, "nodeTwo"=6, "nodeThree"=8, "nodeFour"=13) / 10 maximumTimes <- c("nodeOne" = 30, "nodeTwo" = 12, "nodeThree"=12, "nodeFour" = 20) / 10 estimateCauchy(minAge=minimumTimes, maxAge=maximumTimes, monoGroups=monophyleticGroups, offset=0.5, phy=apeTree, plot=FALSE)$MCMCtree
Fixed Age for MCMCtree analysis input
Description
Produce fixed age trees for MCMCtree analysis
Usage
estimateFixed(minAge, phy, monoGroups, writeMCMCtree = FALSE,
MCMCtreeName = "estimateFixed.tre")
Arguments
minAge |
vector of fixed age bounds for nodes matching order in monoGroups |
phy |
fully resolved phylogeny in ape format |
monoGroups |
list with each element containing species that define a node of interest |
writeMCMCtree |
logical whether to write tree in format that is compatible with MCMCTree to file |
MCMCtreeName |
MCMCtree.output file name |
Value
list containing node estimates for each distribution
"parameters" estimated parameters for each node
"apePhy" phylogeny in ape format with node labels showing node distributions
"MCMCtree" phylogeny in MCMCtreeR format
"nodeLabels" node labels in MCMCtreeR format
If writeMCMCtree=TRUE tree in MCMCtree format in file "MCMCtreeName" written to current working directory
Author(s)
Mark Puttick
Examples
data(apeData)
attach(apeData)
## extract taxon descending from calibrated nodes 8, 10, 11, 13
## these nodes can be visualised using plot.phylo
## and nodelabels from ape
monophyleticGroups <- tipDes(apeData$apeTree, c(8,10,11,13))
minimumTimes <- c("nodeOne"=15, "nodeTwo"=6,
"nodeThree"=8, "nodeFour"=13) / 10
maximumTimes <- c("nodeOne" = 30, "nodeTwo" = 12,
"nodeThree"=12, "nodeFour" = 20) / 10
estimateFixed(minAge=minimumTimes[1],
monoGroups=monophyleticGroups[[1]], phy=apeTree)$MCMCtree
Estimate Gamma Distribution for MCMCtree analysis
Description
Estimate the shape and rate paramaters of Gamma distribution and output trees for MCMCtree input
Usage
estimateGamma(minAge, maxAge, phy, monoGroups, alpha = 188,
beta = 2690, offset = 0.1, estimateAlpha = TRUE,
estimateBeta = FALSE, plot = FALSE, pdfOutput = "gammaPlot.pdf",
writeMCMCtree = FALSE, MCMCtreeName = "gammaInput.tre")
Arguments
minAge |
vector of minimum age bounds for nodes matching order in monoGroups |
maxAge |
vector of maximum age bounds for nodes matching order in monoGroups |
phy |
fully resolved phylogeny in ape format |
monoGroups |
list with each element containing species that define a node of interest |
alpha |
alpha value for gamma distribution (default = 188) |
beta |
beta value for gamma distribution (default = 2690) |
offset |
distance of mean value from minimum bound |
estimateAlpha |
logical specifying whether to estimate alpha with a given beta value (default = TRUE) |
estimateBeta |
logical specifying whether to estimate beta with a given alpha value (default = FALSE) |
plot |
logical specifying whether to plot to PDF |
pdfOutput |
pdf output file name |
writeMCMCtree |
logical whether to write tree in format that is compatible with MCMCTree to file |
MCMCtreeName |
MCMCtree.output file name |
Value
list containing node estimates for each distribution
"parameters" estimated parameters for each node
"apePhy" phylogeny in APE format with node labels showing node distributions
"MCMCtree" phylogeny in MCMCtreeR format
"nodeLabels" node labels in MCMCtreeR format
If plot=TRUE plot of distributions in file 'pdfOutput' written to current working directory
If writeMCMCtree=TRUE tree in MCMCtree format in file "MCMCtreeName" written to current working directory
Author(s)
Mark Puttick
Examples
data(apeData)
attach(apeData)
## extract taxon descending from calibrated nodes 8, 10, 11, 13
## these nodes can be visualised using plot.phylo
## and nodelabels from ape
monophyleticGroups <- tipDes(apeData$apeTree, c(8,10,11,13))
minimumTimes <- c("8"=15, "10"=6,
"11"=8, "13"=13) / 10
maximumTimes <- c("8" = 30, "10" = 12,
"11"=12, "13" = 20) / 10
gamma.nodes <- estimateGamma(minAge=minimumTimes, maxAge=maximumTimes,
monoGroups=monophyleticGroups, alpha=188, beta=2690,
offset=0.1, phy=apeTree, plot=FALSE)
gamma.nodes
Estimate Skew Normal for MCMCtree analysis
Description
Estimate the shape, scale, and location paramaters of a skew normal distribution and output trees for MCMCtree input
Usage
estimateSkewNormal(minAge, maxAge, monoGroups, phy, shape = 50,
scale = 1.5, addMode = 0, maxProb = 0.975, minProb = 0.003,
estimateScale = TRUE, estimateShape = FALSE, estimateMode = FALSE,
plot = FALSE, pdfOutput = "skewNormalPlot.pdf",
writeMCMCtree = FALSE, MCMCtreeName = "skewNormalInput.tre")
Arguments
minAge |
vector of minimum age bounds for nodes matching order in monoGroups |
maxAge |
vector of maximum age bounds for nodes matching order in monoGroups |
monoGroups |
list with each element containing species that define a node of interest |
phy |
fully resolved phylogeny in ape format |
shape |
shape value for skew normal distribution (default = 50) |
scale |
scale value for skew normal distribution (default = 1.5) |
addMode |
addition to the minimum age to give the location of the distribution |
maxProb |
probability of right tail (maximum bound default = 0.975) |
minProb |
probability of left tail (maximum bound default = 0.003) |
estimateScale |
logical specifying whether to estimate scale with a given shape value (default = TRUE) |
estimateShape |
logical specifying whether to estimate shape with a given scale value (default = FALSE) |
estimateMode |
logical speciftying whether to estimate the scale that produces probabilities of each tail that corresponds roughly to the values given by minProb (lower tail) and maxProb (upper tail) |
plot |
logical specifying whether to plot to PDF |
pdfOutput |
pdf output file name |
writeMCMCtree |
logical whether to write tree in format that is compatible with MCMCTree to file |
MCMCtreeName |
MCMCtree.output file name |
Value
list containing node estimates for each distribution
"parameters" estimated parameters for each node
"apePhy" phylogeny in ape format with node labels showing node distributions
"MCMCtree" phylogeny in MCMCtree format
"nodeLabels" node labels in MCMCtreeR format
If plot=TRUE plot of distributions in file 'pdfOutput' written to current working directory
If writeMCMCtree=TRUE tree in MCMCtree format in file "MCMCtreeName" written to current working directory
Author(s)
Mark Puttick
See Also
Examples
data(apeData)
attach(apeData)
monophyleticGroups <- list()
## extract taxon descending from calibrated nodes 8, 10, 11, 13
## these nodes can be visualised using plot.phylo
## and nodelabels from ape
monophyleticGroups <- tipDes(apeData$apeTree, c(8,10,11,13))
minimumTimes <- c("nodeOne"=15, "nodeTwo"=6,
"nodeThree"=8, "nodeFour"=13) / 10
maximumTimes <- c("nodeOne" = 30, "nodeTwo" = 12,
"nodeThree"=12, "nodeFour" = 20) / 10
estimateSkewNormal(minAge=minimumTimes, maxAge=maximumTimes,
monoGroups=monophyleticGroups, phy=apeTree, plot=FALSE)
Estimate Skew-t Distribution for MCMCtree analysis
Description
Estimate the shape, scale, and location paramaters of a Skew-t distribution and output trees for MCMCtree input
Usage
estimateSkewT(minAge, maxAge, monoGroups, phy, shape = 50, scale = 1.5,
df = 1, addMode = 0, maxProb = 0.975, minProb = 0.003,
estimateScale = TRUE, estimateShape = FALSE, estimateMode = FALSE,
plot = FALSE, pdfOutput = "skewTPlot.pdf", writeMCMCtree = FALSE,
MCMCtreeName = "skewTInput.tre")
Arguments
minAge |
vector of minimum age bounds for nodes matching order in monoGroups |
maxAge |
vector of maximum age bounds for nodes matching order in monoGroups |
monoGroups |
list with each element containing species that define a node of interest |
phy |
fully resolved phylogeny in ape format |
shape |
shape value for skew-t distribution (default = 50) |
scale |
scale value for skew-t distribution (default = 1.5) |
df |
degrees of freedom for skew-t distribution (default = 1) |
addMode |
addition to the minimum age to give the location of the distribution |
maxProb |
probability of right tail (maximum bound default = 0.975) |
minProb |
probability of left tail (maximum bound default = 0.003) |
estimateScale |
logical specifying whether to estimate scale with a given shape value (default = TRUE) |
estimateShape |
logical specifying whether to estimate shape with a given scale value (default = FALSE) |
estimateMode |
logical speciftying whether to estimate the scale that produces probabilities of each tail that corresponds roughly to the values given by minProb (lower tail) and maxProb (upper tail) |
plot |
logical specifying whether to plot to PDF |
pdfOutput |
pdf output file name |
writeMCMCtree |
logical whether to write tree in format that is compatible with MCMCTree to file |
MCMCtreeName |
MCMCtree.output file name |
Value
list containing node estimates for each distribution
"parameters" estimated parameters for each node
"apePhy" phylogeny in APE format with node labels showing node distributions
"MCMCtree" phylogeny in MCMCtree format
"nodeLabels" node labels in MCMCtreeR format
If plot=TRUE plot of distributions in file 'pdfOutput' written to current working directory
If writeMCMCtree=TRUE tree in MCMCtree format in file "MCMCtreeName" written to current working directory
Author(s)
Mark Puttick
See Also
Examples
data(apeData)
attach(apeData)
## extract taxon descending from calibrated nodes 8, 10, 11, 13
## these nodes can be visualised using plot.phylo
## and nodelabels from ape
monophyleticGroups <- tipDes(apeData$apeTree, c(8,10,11,13))
minimumTimes <- c("nodeOne"=15, "nodeTwo"=6,
"nodeThree"=8, "nodeFour"=13) / 10
maximumTimes <- c("nodeOne" = 30, "nodeTwo" = 12,
"nodeThree"=12, "nodeFour" = 20) / 10
estimateSkewT(minAge=minimumTimes, maxAge=maximumTimes,
monoGroups=monophyleticGroups, phy=apeTree, plot=FALSE)$MCMCtree
Estimate Upper Age for MCMCtree analysis
Description
Estimate the upper age distribution and output trees for MCMCtree input
Usage
estimateUpper(maxAge, rightTail = 0.025, phy, monoGroups,
writeMCMCtree = FALSE, MCMCtreeName = "estimateUpper.tre")
Arguments
maxAge |
vector of maximum age bounds for nodes matching order in monoGroups |
rightTail |
probability of right tail (maximum bound default = 0.025) |
phy |
fully resolved phylogeny in ape format |
monoGroups |
list with each element containing species that define a node of interest |
writeMCMCtree |
logical whether to write tree in format that is compatible with MCMCTree to file |
MCMCtreeName |
MCMCtree.output file name |
Value
list containing node estimates for each distribution
"parameters" estimated parameters for each node
"apePhy" phylogeny in APE format with node labels showing node distributions
"MCMCtree" phylogeny in MCMCtree format
"nodeLabels" node labels in MCMCtreeR format
If plot=TRUE plot of distributions in file 'pdfOutput' written to current working directory
If writeMCMCtree=TRUE tree in MCMCtree format in file "MCMCtreeName" written to current working directory
Author(s)
Mark Puttick
Examples
data(apeData)
attach(apeData)
## extract taxon descending from calibrated nodes 8, 10, 11, 13
## these nodes can be visualised using plot.phylo
## and nodelabels from ape
monophyleticGroups <- tipDes(apeData$apeTree, c(8,10,11,13))
minimumTimes <- c("nodeOne"=15, "nodeTwo"=6,
"nodeThree"=8, "nodeFour"=13) / 10
maximumTimes <- c("nodeOne" = 30, "nodeTwo" = 12,
"nodeThree"=12, "nodeFour" = 20) / 10
estimateUpper(maxAge=maximumTimes, monoGroups=monophyleticGroups,
rightTail=0.025, phy=apeTree)
Add Node Constraints to Tree in MCMCtree Format
Description
Produce tree with node labels in MCMCtree format
Usage
nodeToPhy(phy, monoGroups, nodeCon, returnPhy = TRUE)
Arguments
phy |
fully resolved phylogeny in ape format |
monoGroups |
list with each element containing species that define a node of interest |
nodeCon |
node distributions in MCMCtreeR format |
returnPhy |
logical specifying whether to return phy to console or write MCMCtree for input (default = TRUE) |
Value
If returnPhy=TRUE phylogeny with node labels in ape format
If returnPhy=FALSE phylogeny with node labels in MCMCtree format
Author(s)
Mark Puttick
Plot distribution from MCMCtree node estimations
Description
Estimate the offset and scale paramaters of a soft-tailed cauchy distribution and output trees for MCMCtree input
Usage
plotMCMCtree(parameters, method = c("skewT", "skewNormal", "cauchy",
"gamma", "bound"), title, upperTime, lowerTime = 0,
plotMCMCtreeData = TRUE)
Arguments
parameters |
output parameters from node estimation function |
method |
one of skewT, skewNormal, cauchy, gamma, or bound |
title |
title for the plot |
upperTime |
maxmimum age for x-axis plot |
lowerTime |
maxmimum age for x-axis plot (default = 0) |
plotMCMCtreeData |
If TRUE returns co-ordinates to plot distributions to allow greater flexibility (default = TRUE) |
Value
plot of the specified prior applied for a node
If plotMCMCtreeData=TRUE x and y coordinates of distributions from 0 to upperTime on x axis
Author(s)
Mark Puttick
Examples
data(apeData)
attach(apeData)
# create monophyletic groups descending from nodes 8, 10, 11, and 13
monophyleticGroups <- tipDes(apeData$apeTree, c(8,10,11,13))
minimumTimes <- c("nodeOne"=15, "nodeTwo"=6,
"nodeThree"=8, "nodeFour"=13) / 10
maximumTimes <- c("nodeOne" = 30, "nodeTwo" = 12,
"nodeThree"=12, "nodeFour" = 20) / 10
cauchy <- estimateCauchy(minAge=minimumTimes[1], maxAge=maximumTimes[1],
monoGroups=monophyleticGroups[[1]], offset=0.5, phy=apeTree, plot=FALSE)
## un-comment to run
plotMCMCtree(parameters=cauchy$parameters, method="cauchy",
title="cauchyPlot", upperTime=maximumTimes[1]+1)
priorPosterior
Description
Analyse prior and posterior node distributions from MCMCtree analysis
Usage
priorPosterior(MCMCPrior, MCMCPosterior = NULL, inputTree,
return.density = FALSE, rootCalibration = NULL)
Arguments
MCMCPrior |
prior of MCMC file from MCMCtree analysis using data=0 |
MCMCPosterior |
posterior of MCMC file from MCMCtree analysis using data |
inputTree |
phylogeny in MCMCtree format used in MCMCtree analysis |
return.density |
Logical. Whether to return the density or original values for the effective prior and posterior. |
rootCalibration |
= NULL If NULL, then behaves as by default. Alternatively, if a user has specified a root prior in the MCMCtreeR control file it can be added here as a vector in the form it would appear tree. |
Value
list containing node estimates for each distribution
"prior" distribution of effective prior
"posterior" distribution of posterior
"specifiedPrior" distribution of specified prior
Author(s)
Mark Puttick, Pascal Title
Examples
data(MCMCtree.output)
# priorPosterior(MCMCPrior,
# MCMCPosterior=MCMCtree.output$MCMCtree.posterior,
# path.to.input.tree)
Read MCMCtree output tree into R
Description
Read MCMCtree output tree into R to produce time-scaled tree in APE format, and a table of the mean and 95
Usage
readMCMCtree(inputPhy, forceUltrametric = TRUE, from.file = TRUE)
Arguments
inputPhy |
file directory of 'Figtree' output from MCMCtree |
forceUltrametric |
alters branch lengths at tips so tree is fully ultrametric (default = TRUE) |
from.file |
Logical. Read a tree from file or locally from within R? |
Value
apePhy time-scaled output tree from MCMCtree in APE format
nodeAges mean and 95
Author(s)
Mark Puttick
Examples
data(MCMCtree.output)
attach(MCMCtree.output)
# tree and node ages
readMCMCtree(MCMCtree.phy, from.file=FALSE)
Find Descendent Tips From A Common Ancestor
Description
This function finds tip descendants from a common ancestor
Usage
tipDes(phy, node)
Arguments
phy |
user tree in ape format |
node |
one or more nodes from the ape format that designate the crown monophyletic group |
Details
If a single node number is supplied the function returns a vector of tip labels. When more than one node number is supplied the function returns a list with each element a vector of tip labels for that node.
Author(s)
Mark Puttick
Examples
set.seed(1029)
# one node
phy <- rcoal(10)
node <- 13
tipDes(phy, node)
## multiple nodes
node <- c(13,14,15)
tipDes(phy, node)