phylo_generate_uncertainty: Function to generate uncertainty in branch lengths using a...

Description Usage Arguments Details Value Examples

View source: R/uncertainty.R

Description

Function to generate uncertainty in branch lengths using a lognormal

Usage

1
2
3
4
phylo_generate_uncertainty(phy, size = 100,
  uncertainty_method = "other", age_distribution = "uniform",
  age_sd = NULL, age_var = 0.1, age_scale = 0, alpha = 0.025,
  rescale = TRUE, verbose = FALSE)

Arguments

phy

The input tree

size

A numeric vector indicating the number of samples to be generated.

uncertainty_method

A character vector specifying the method to generate uncertainty. mrbayes is default.

age_distribution

A character string specifying the type of calibration. Only "fixed" and "uniform" are implemented for now.

fixed

The age given in ncalibration will be used as fixed age.

lognormal

The age given in ncalibration will be used as mean age. The standard deviation can be provided. # still need to add this option. By default, a 95 CI sd is used.

uniform

The age given in ncalibration will be used as mean age. Where min_age = 0.9 * mean age, and max_age = 1.1 * mean age.

age_sd

The standard deviation around the age to use for generating the uncertainty. If not a numeric value, var will be used to calculate it.

age_var

The variance to calculate age_sd and generate unvcertainty.

age_scale

How to scale sd by the depth of the node. If 0, same sd for all. If not, older nodes have more uncertainty

alpha

The significance level on uncertainty to generate. By default 0.025

rescale

Boolean. If true, observed age will be rescaled each round.

verbose

Boolean. If TRUE, it gives printed updates to the user.

Details

If you want to change the size of sampled trees you do not need to run mrbayes again. Just use sample_trees("mrbayes_trees_file_directory", size = new_size) and you will get a multiPhylo object with a new tree sample.

Value

A phylo or multiPhylo object with the same topology as phy but different branch lengths

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# generate uncertainty over feline species SDM chronogram
# load data
data(felid_sdm)
# by default, generates a sample of 100 trees with var = 0.1
unc <- phylo_generate_uncertainty(felid_sdm$phy)
length(unc)
# ltt plot:
max_age <- max(sapply(unc, ape::branching.times))
ape::ltt.plot(phy = unc[[1]], xlim = c(-max_age, 0), col = "#cce5ff50")
for (i in 2:100){
  ape::ltt.lines(phy = unc[[i]], col = "#cce5ff50")
}
ape::ltt.lines(felid_sdm$phy, col = "red")
title(c("fake uncertainty", "in Felidae SDM chronogram"))

phylotastic/datelife documentation built on Jan. 22, 2019, 12:29 a.m.