simulate.uncor.lnorm: simulate.uncor.lnorm

View source: R/simulate.uncor.lnorm.R

simulate.uncor.lnormR Documentation

simulate.uncor.lnorm

Description

Simulate the rate of evolution along a phylogenetic tree using the lognormal model described in Drummond et al. (2006)

Usage

simulate.uncor.lnorm(tree, params = list(mean.log = -5, sd.log = 0.5))

Arguments

tree

A phylogenetic tree of class 'phylo'. The branch lengths should be in units of time (chronogram)

params

parameters for the uncorrelated rates function. This should be a list with two items:

mean.log

This is the mean rate of the lognormal distribution. It should be in log scale

sd.log

The standard deviation of the lognormal distribution

Details

None

Value

An object of class 'ratesim'. This is a list with two items:

phylogram

The phylogenetic tree with branch lengths in units of substitutions (phylogram)

tree.data.matrix

This is a matrix with the number of substitutions, rates, and times along every branch in the tree. See get.tree.data.matrix for more details

Note

None

Author(s)

Sebastian Duchene. See the reference for the description of the model.

References

Drummond, A.J., et al. "Relaxed phylogenetics and dating with confidence." PLoS biology 4.5 (2006): e88.

See Also

simulte.uncor.exp

Examples

set.seed(1234525)

myTree <- rcoal(50)

rateTree <- simulate.uncor.lnorm(tree = myTree, params = list(mean.log = -5, sd.log = 0.5))
plot(rateTree, col.lineages = rainbow(50))

#See the histogram of the branch-wise rates
hist(rateTree$tree.data.matrix[, 5])


## The function is currently defined as
function (tree, params = list(mean.log = -5, sd.log = 0.5)) 
{
    mean.log <- params$mean.log
    sd.log <- params$sd.log
    data.matrix <- get.tree.data.matrix(tree)
    branch.rates <- rlnorm(n = length(tree$edge.length), meanlog = mean.log, 
        sdlog = sd.log)
    data.matrix[, 5] <- branch.rates
    data.matrix[, 6] <- data.matrix[, 5] * data.matrix[, 7]
    tree$edge.length <- data.matrix[, 6]
    res <- list(tree, data.matrix)
    names(res) <- c("phylogram", "tree.data.matrix")
    class(res) <- "ratesim"
    return(res)
  }

sebastianduchene/NELSI documentation built on Aug. 18, 2022, 11:45 p.m.