coalescentMCMC (version 0.4-1)

coalescentMCMC: Run MCMC for Coalescent Trees

Description

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.

Usage

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()

Arguments

x

a set of DNA sequences, typically an object of class "DNAbin" or "phyDat".

ntrees

the number of trees to output.

burnin

the number of trees to discard as ``burn-in''.

frequency

the frequency at which trees are sampled.

tree0

the initial tree of the chain; by default, a UPGMA tree with a JC69 distance is generated.

model

the coalescent model to be used for resampling. By default, a constant-THETA is used.

printevery

an integer specifying the frequency at which to print the numbers of trees proposed and accepted; set to 0 to cancel all printings.

chain

an integer giving which lists of trees to extract

destdir

a character string giving the location where to save the files; by default, this is the current working directory.

format

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).

X

an bject of class "multiPhylo".

Value

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.

Details

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)]].

References

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.

See Also

dcoal, treeOperators

Examples

Run this code
# NOT RUN {
data(woodmouse)
out <- coalescentMCMC(woodmouse)
plot(out)
getMCMCtrees() # returns 3000 trees
# }

Run the code above in your browser using DataCamp Workspace