This function runs a Markov chain Monte Carlo (MCMC) algorithm to generate a set of trees which is returned with their likelihoods.
getMCMCtrees
extracts the trees from previous MCMC runs.
saveMCMCtrees
saves the lists of trees from previous runs on
the user's hard disk.
cleanMCMCtrees
deletes the lists of trees from previous runs
(the files possibly on the hard disk are not changed).
getLastTree
extracts the last tree from a list of trees (object
of class "multiPhylo"
).
getMCMCstats
returns the summary data for the different chains
run during a session.
coalescentMCMC(x, ntrees = 3000, burnin = 1000, frequency = 1,
tree0 = NULL, model = NULL, printevery = 100)
getMCMCtrees(chain = NULL)
saveMCMCtrees(destdir = ".", format = "RDS", ...)
cleanMCMCtrees()
getLastTree(X)
getMCMCstats()
a set of DNA sequences, typically an object of class
"DNAbin"
or "phyDat"
.
the number of trees to output.
the number of trees to discard as ``burn-in''.
the frequency at which trees are sampled.
the initial tree of the chain; by default, a UPGMA tree with a JC69 distance is generated.
the coalescent model to be used for resampling. By default, a constant-THETA is used.
an integer specifying the frequency at which to print the numbers of trees proposed and accepted; set to 0 to cancel all printings.
an integer giving which lists of trees to extract
a character string giving the location where to save the files; by default, this is the current working directory.
the format of the tree files. Three choices are
possible (cae-insensitive): "RDS"
, "Newick"
,
"NEXUS"
, or any unambiguous abbreviation of these.
options passed to the function used to write the tree files (see below).
an bject of class "multiPhylo"
.
coalescentMCMC
returns an object of class "coda"
with
the log-likelihood and the parameters of each tree.
getLastTree
returns an object of class "phylo"
.
getMCMCstats
returns a data frame.
A simple MCMC algorithm is programmed using at each step the ``neighborhood rearrangement'' operation (Kuhner et al., 1995) and Hastings's ratio for acceptance/rejection of the proposed tree.
The number of generations of the chain is determined by: `frequency' times `ntrees' plus `burnin'. Only the `ntrees' trees are output whereas all the log-likelihood values are output.
The list of trees is returned in a specific environment and can be
extracted with getMCMCtrees
.
saveMCMCtrees
saves the files with, by default, the RDS format
using saveRDS
. If format = "Newick"
,
write.tree
is used.; if format = "NEXUS"
,
write.nexus
is used. Options can be passed to any
of these functions with …
.
getLastTree(X)
is a short-cut to X[[length(X)]]
.
Hastings, W. K. (1970) Monte Carlo sampling methods using Markov chains and their applications. Biometrika, 57, 97--109.
Kuhner, M. K., Yamato, J. and Felsenstein, J. (1995) Estimating effective population size and mutation rate from sequence data using Metropolis-Hastings sampling. Genetics, 140, 1421--1430.
# NOT RUN {
data(woodmouse)
out <- coalescentMCMC(woodmouse)
plot(out)
getMCMCtrees() # returns 3000 trees
# }
Run the code above in your browser using DataCamp Workspace