A package for applying Approximate Bayesian Computation to estimating parameters of trait evolution in comparative analyses.

Details

Package:TreEvo
Type:Package
Version:0.3.3
Date:2012-07-02
License:GPL

Author

Brian O'Meara, Barb L. Banbury, David W. Bapst

Maintainer: David Bapst <dwbapst@gmail.com>

Examples

# example analysis, using data simulated with TreEvo # \donttest{ set.seed(1) # let's simulate some data, and then try to infer the parameters using ABC # get a 20-taxon coalescent tree tree <- rcoal(20) # get realistic edge lengths tree$edge.length <- tree$edge.length*20 genRateExample <- c(0.01) ancStateExample <- c(10) #Simple Brownian motion simCharExample <- doSimulation( phy = tree, intrinsicFn = brownianIntrinsic, extrinsicFn = nullExtrinsic, startingValues = ancStateExample, #root state intrinsicValues = genRateExample, extrinsicValues = c(0), generation.time = 100000 )
#> Warning: You have only 22 timeSteps on the shortest branch in this dataset #> but should probably have a lot more if you expect change on this branch. #> Please consider decreasing timeStep to no more than 0.0016
# NOTE: the example analyses below sample too few particles, # over too few steps, with too few starting simulations # - all for the sake of examples that reasonably test the functions # Please set these values to more realistic levels for your analyses! resultsBMExample <- doRun_prc( phy = tree, traits = simCharExample, intrinsicFn = brownianIntrinsic, extrinsicFn = nullExtrinsic, startingPriorsFns = "normal", startingPriorsValues = list(c(mean(simCharExample[, 1]), sd(simCharExample[, 1]))), intrinsicPriorsFns = c("exponential"), intrinsicPriorsValues = list(10), extrinsicPriorsFns = c("fixed"), extrinsicPriorsValues = list(0), generation.time = 100000, nRuns = 2, nStepsPRC = 3, numParticles = 20, nInitialSimsPerParam = 10, jobName = "examplerun_prc", stopRule = FALSE, multicore = FALSE, coreLimit = 1 )
#> The effective timeStep for this tree will be 0.0035, #> as a proportion of tree height (root to furthest tip)...
#> Rescaling edge lengths relative to maximum tip-to-root distance...
#> The smallest edge length on the input tree is 0.0028
#> (This is 79000 in the same TreeYears units #> as used for the input generation.time ( = 1e+05))
#> Warning: Tree has rescaled branches shorter than generation.time/TreeYears #> No trait evolution will be simulated on these branches and #> thus ML summary statistic functions may fail or produce unexpected results.
#> Given generation time, a total of 1387 generations are #> expected to occur over this tree
#> Number of initial simulations to be performed (nInitialSims) not given #> Number of initial simulations will thus be the #> product of the number of free parameters multiplied by 10 #> ( = 20 initial simulations)
#> Beginning PRC Run 1 out of a total of 2...
#> Number of initial simulations set to 20
#> Doing initial simulations...
#> Initial simulations took 11.931 seconds
#> Finding distribution of distances...
#> Beginning partial rejection control algorithm...
#> #> STARTING DATA GENERATION STEP 1
#> Successes Attempts Distance starting_1 intrinsic_1
#> 1 40 240 11 0.1
#> 2 40 260 8.8 0.086
#> 3 40 240 10 0.058
#> 4 40 170 9 0.049
#> 5 40 68 9.2 0.019
#> 6 40 250 9.1 0.078
#> 7 40 71 9.4 0.023
#> 8 40 84 9.9 0.02
#> 9 40 200 10 0.08
#> 10 40 120 11 0.025
#> 11 40 97 10 0.033
#> 12 40 260 10 0.086
#> 13 40 210 9.6 0.055
#> 14 40 110 11 0.031
#> 15 40 90 9.8 0.008
#> 16 40 190 9.8 0.062
#> 17 40 220 11 0.051
#> 18 40 76 9.4 0.0079
#> 19 40 200 9.9 0.069
#> 20 40 160 9.8 0.062
#> 21 40 12 8.8 0.013
#> 22 40 270 10 0.12
#> 23 40 200 10 0.047
#> 24 40 260 9.4 0.1
#> 25 40 240 9.8 0.091
#> 26 40 100 11 0.019
#> 27 40 38 9.6 0.027
#> #> STARTING DATA GENERATION STEP 2
#> Successes Attempts Distance starting_1 intrinsic_1
#> 1 40 190 10 0.053
#> 2 40 190 11 0.049
#> 3 40 160 11 0.055
#> 4 40 180 9.9 0.043
#> 5 40 100 10 0.03
#> 6 40 110 8.9 0.023
#> 7 40 66 9.8 0.019
#> 8 40 170 9.6 0.059
#> 9 40 150 10 0.037
#> 10 40 190 10 0.062
#> 11 40 170 10 0.055
#> 12 40 150 11 0.045
#> 13 40 100 9.5 0.0043
#> 14 40 120 11 0.05
#> 15 40 180 10 0.066
#> 16 40 110 9.7 0.029
#> 17 40 12 9.9 0.015
#> 18 40 23 8.8 0.012
#> 19 40 30 9.9 0.016
#> 20 40 200 10 0.056
#> 21 40 150 11 0.059
#> 22 40 74 8.7 0.021
#> 23 40 120 11 0.047
#> 24 40 190 9.6 0.039
#> 25 40 70 9.5 0.0063
#> #> STARTING DATA GENERATION STEP 3
#> Successes Attempts Distance starting_1 intrinsic_1
#> 1 48 120 11 0.046
#> 2 48 120 11 0.051
#> 3 48 82 10 0.039
#> 4 48 15 8.7 0.013
#> 5 48 32 9.8 0.018
#> 6 48 75 10 0.017
#> 7 48 32 10 0.0098
#> 8 48 46 8.8 0.0082
#> 9 48 61 8.9 0.018
#> 10 48 19 10 0.01
#> 11 48 78 9.3 0.022
#> 12 48 33 9.6 0.015
#> 13 48 100 8.9 0.034
#> 14 48 110 10 0.0041
#> 15 48 110 9.6 0.054
#> 16 48 110 9.6 0.031
#> 17 48 140 9.8 0.037
#> 18 48 29 9.9 0.017
#> 19 48 40 8.6 0.019
#> 20 48 110 9.7 0.035
#> 21 48 120 10 0.028
#> 22 48 56 9.9 0.0088
#> Collection of simulation particles under PRC completed in 29 seconds...
#> Run finished... #> ... #>
#> Beginning PRC Run 2 out of a total of 2...
#> Number of initial simulations set to 20
#> Doing initial simulations...
#> Initial simulations took 12.287 seconds
#> Finding distribution of distances...
#> Beginning partial rejection control algorithm...
#> #> STARTING DATA GENERATION STEP 1
#> Successes Attempts Distance starting_1 intrinsic_1
#> 1 40 320 8.9 0.12
#> 2 40 3 9 0.013
#> 3 40 160 9.2 0.065
#> 4 40 24 9.4 0.014
#> 5 40 74 9.1 0.024
#> 6 40 100 8.8 0.04
#> 7 40 67 9.1 0.0056
#> 8 40 230 9.3 0.078
#> 9 40 200 9.1 0.056
#> 10 40 50 9.9 0.015
#> 11 40 300 9.5 0.093
#> 12 40 340 10 0.16
#> 13 40 310 9.2 0.14
#> 14 40 8.7 9 0.012
#> 15 40 26 9.9 0.021
#> 16 40 38 11 0.013
#> 17 40 300 10 0.084
#> 18 40 86 10 0.025
#> 19 40 14 10 0.013
#> 20 40 110 9.2 0.022
#> 21 40 3.7 10 0.0099
#> 22 40 280 10 0.15
#> 23 40 70 10 0.018
#> 24 40 170 10 0.057
#> 25 40 53 9.7 0.02
#> 26 40 16 11 0.017
#> #> STARTING DATA GENERATION STEP 2
#> Successes Attempts Distance starting_1 intrinsic_1
#> 1 40 190 9.1 0.0019
#> 2 40 160 10 0.037
#> 3 40 160 9.5 0.05
#> 4 40 160 9.3 0.043
#> 5 40 160 9.1 0.046
#> 6 40 35 9.6 0.019
#> 7 40 46 9.4 0.016
#> 8 40 47 10 0.019
#> 9 40 120 9.9 0.04
#> 10 40 6.4 10 0.0094
#> 11 40 66 10 0.024
#> 12 40 73 10 0.022
#> 13 40 210 8.8 0.048
#> 14 40 76 9.4 0.024
#> 15 40 130 9.9 0.0029
#> 16 40 94 10 0.0041
#> 17 40 140 9.4 0.0027
#> 18 40 9.6 8.8 0.015
#> 19 40 44 9.1 0.018
#> 20 40 68 8.7 0.0062
#> 21 40 32 10 0.0084
#> 22 40 140 9.1 0.035
#> 23 40 96 11 0.031
#> 24 40 41 9.3 0.0067
#> 25 40 170 8.7 0.051
#> 26 40 210 11 0.064
#> 27 40 170 9.1 0.0026
#> 28 40 37 9.6 0.0097
#> 29 40 5 9.1 0.015
#> 30 40 130 8.9 0.0049
#> 31 40 110 11 0.024
#> 32 40 180 8.8 0.043
#> #> STARTING DATA GENERATION STEP 3
#> Successes Attempts Distance starting_1 intrinsic_1
#> 1 40 160 9.2 0.068
#> 2 40 99 9.4 0.027
#> 3 40 49 10 0.0062
#> 4 40 34 9.2 0.016
#> 5 40 28 9.1 0.021
#> 6 40 17 9.3 0.0094
#> 7 40 61 10 0.02
#> 8 40 77 9.9 0.0047
#> 9 40 100 9.2 0.029
#> 10 40 140 9.6 0.049
#> 11 40 92 9.2 0.032
#> 12 40 43 9 0.0081
#> 13 40 33 8.8 0.021
#> 14 40 34 10 0.015
#> 15 40 93 9.2 0.028
#> 16 40 93 9.3 0.0047
#> 17 40 44 9.1 0.017
#> 18 40 120 10 0.03
#> 19 40 30 10 0.012
#> 20 40 130 10 0.036
#> 21 40 30 11 0.015
#> 22 40 56 9 0.027
#> 23 40 13 10 0.015
#> 24 40 46 10 0.019
#> 25 40 150 8.7 0.064
#> 26 40 10 9.1 0.018
#> 27 40 160 9.4 0.052
#> 28 40 150 10 0.03
#> 29 40 43 10 0.0085
#> 30 40 110 9.4 0.03
#> 31 40 46 9.6 0.018
#> 32 40 95 10 0.0048
#> 33 40 140 10 0.03
#> 34 40 86 9.4 0.026
#> 35 40 25 9.7 0.0096
#> 36 40 130 10 0.0037
#> 37 40 130 9.5 0.03
#> 38 40 63 10 0.028
#> Collection of simulation particles under PRC completed in 24 seconds...
#> Run finished... #> ... #>
#> Function completed in 180 seconds.
# }