cac.moments: Computes the statistical moments of the Core Ancestor Cost...

Description Usage Arguments Value Author(s) References See Also Examples

View source: R/PhyloMeasures.R

Description

Calculates the mean and standard deviation of the Core Ancestor Cost (CAC) for a tree and a vector of tip set sizes. The means and deviations can be calculated under two different null models which maintain species richness. When the "uniform" null model is used, the function can calculate the first k statistical moments of this measure. The CAC is calculated by identifying the node in the tree that is the most recent common ancestor of at least chi proportion of the tips in the set, where chi is an input parameter larger than 0.5. The CAC is the distance of this node from the root of the tree.

Usage

1
2
cac.moments(tree, chi, sample.sizes, k=2,  
            null.model="uniform", abundance.weights, reps=1000, seed)

Arguments

tree

A phylo tree object

chi

A number in the interval (0.5,1]

sample.sizes

A vector of non-negative integers specifying the tip set sizes for which to calculate moments

k

A positive integer specifying the number of moments to compute (default = 2). If the "sequential" model is selected, the only values that can be used for this argument are either one or two.

null.model

A character vector (string) that defines which null model is used for computing the moments of the measure. There are two possible null models that can be used for computing the moments: these are "uniform" and "sequential". Both models maintain species richness. More specifically, the available models are defined as follows:

  • "uniform" considers samples with equal (uniform) probability among all possible tip samples of the same richness.

  • "sequential" is an abundance-weighted null model where species samples are chosen based on the same method as R's sample function. Unlike the other model (which is computed analytically), this model uses Monte-Carlo randomization.

This argument is optional, and its default value is "uniform".

abundance.weights

A vector of positive numeric values. These are the abundance weights that will be used if option "sequential" is selected. The names stored at the vector must match the names of the tips in the tree. This argument is redundant if the "uniform" model is selected.

reps

An integer that defines the number of Monte-Carlo random repetitions that will be performed when using the "sequential" model. This argument is redundant if the "uniform" model is selected.

seed

A positive integer that defines the random seed used in the Monte-Carlo randomizations of the "sequential" model. This argument is optional, and becomes redundant if the "uniform" model is selected.

Value

A k-column matrix with length(sample.sizes) rows. Entry [i,j] in the matrix gives the j-th moment for the i-th sample size in sample.sizes . The first moment in each row is the mean, and for j larger than one, the j-th returned moment is the raw statistical moment of order j. Given a phylogenetic tree T, a sample size r and a value chi, the raw statistical moment of order j for the CAC is defined as:

E_{R in Sub(T,r)}[CAC_{chi}(T,R)^k],

where E_{R \in Sub(T,r)} denotes the expectation of a random variable for all tip sets in T that consist of r tips each.

Author(s)

Constantinos Tsirogiannis (tsirogiannis.c@gmail.com)

References

Tsirogiannis, C., B. Sandel and A. Kalvisa. 2014. New algorithms for computing phylogenetic biodiversity. Algorithms in Bioinformatics, LNCS 8701: 187-203.

See Also

cac.query

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
#Load phylogenetic tree of bird families from package "ape"
data(bird.families, package = "ape")

# Calculate first four raw moments under the uniform model
cac.moments(bird.families,0.75,1:100,k=4)

# Create random abundance weights
weights = runif(length(bird.families$tip.label))
names(weights) = bird.families$tip.label

# Calculate mean and variance under the sequential model
cac.moments(bird.families,0.75,1:100,k=2,
            null.model="sequential", abundance.weights=weights, reps=1000)

Example output

            [,1]       [,2]          [,3]         [,4]
  [1,] 28.000000  0.0000000  0.0000000000    0.0000000
  [2,]  4.922671 17.4958300 86.4318640603 1345.1334078
  [3,]  3.287615  8.4753525 26.8145279255  404.3689659
  [4,]  5.522785  9.6585328 38.4933240146  580.6604115
  [5,]  4.481193  5.9940757 10.8022266495  231.6064183
  [6,]  3.847867  4.8027689  2.0077503201   97.7444715
  [7,]  3.372381  4.3171549  0.3515315856   52.9406359
  [8,]  4.544204  3.4525238 -0.0468445006   60.9429892
  [9,]  4.144528  3.2829382 -1.3434645119   35.8178270
 [10,]  3.796442  3.1955407 -1.2015414384   27.5829547
 [11,]  3.485927  3.0980594 -0.7597289926   24.5888459
 [12,]  4.322764  2.5205736 -1.2883745819   17.5446075
 [13,]  4.044579  2.5024402 -0.9110520168   16.3565711
 [14,]  3.787997  2.4503004 -0.5636389032   16.0987607
 [15,]  3.552009  2.3740287 -0.3309690016   15.9257944
 [16,]  4.201884  2.0741412 -0.5007399413   10.3530690
 [17,]  3.981654  2.0287195 -0.1971049895   10.5283358
 [18,]  3.776673  1.9605808  0.0006847293   10.6847838
 [19,]  3.586724  1.8807316  0.0919499149   10.7377542
 [20,]  4.113662  1.7575827  0.0271964222    7.1151663
 [21,]  3.930828  1.6932910  0.2306487872    7.2372215
 [22,]  3.760297  1.6159716  0.3474719282    7.3293925
 [23,]  3.601867  1.5332746  0.3829615974    7.3661438
 [24,]  4.042531  1.5195875  0.3189355578    5.1415896
 [25,]  3.886144  1.4472645  0.4638171115    5.1746337
 [26,]  3.740166  1.3667652  0.5415221938    5.1947934
 [27,]  3.604428  1.2835478  0.5567154792    5.1870559
 [28,]  3.982188  1.3371410  0.4722355697    3.8792436
 [29,]  3.845335  1.2625510  0.5818092601    3.8592943
 [30,]  3.717544  1.1822004  0.6383516096    3.8327245
 [31,]  3.598706  1.1002245  0.6456145305    3.7889299
 [32,]  3.929278  1.1944552  0.5473802583    3.0537316
 [33,]  3.807290  1.1203963  0.6332605253    3.0076921
 [34,]  3.693366  1.0418894  0.6760384059    2.9555678
 [35,]  3.587456  0.9622431  0.6788944945    2.8894372
 [36,]  3.881770  1.0802299  0.5787885421    2.4995784
 [37,]  3.771371  1.0079728  0.6469921017    2.4426230
 [38,]  3.668278  0.9320944  0.6791809564    2.3780917
 [39,]  3.572493  0.8553578  0.6782547636    2.3001632
 [40,]  3.838337  0.9864159  0.5856632092    2.1145353
 [41,]  3.737168  0.9164773  0.6396033123    2.0535759
 [42,]  3.642718  0.8435360  0.6628260652    1.9833029
 [43,]  3.555026  0.7699691  0.6581170367    1.8997607
 [44,]  3.798072  0.9073176  0.5783731866    1.8352201
 [45,]  3.704397  0.8398748  0.6202631443    1.7724200
 [46,]  3.616978  0.7699603  0.6356485127    1.6990906
 [47,]  3.535880  0.6996552  0.6272687503    1.6129490
 [48,]  3.760339  0.8389230  0.5623038874    1.6222252
 [49,]  3.672860  0.7740315  0.5938127763    1.5576048
 [50,]  3.591262  0.7071587  0.6023763290    1.4820398
 [51,]  3.515629  0.6401399  0.5906906647    1.3946740
 [52,]  3.724692  0.7784154  0.5402028150    1.4508379
 [53,]  3.642423  0.7161123  0.5627670204    1.3838997
 [54,]  3.565725  0.6522896  0.5655277080    1.3064410
 [55,]  3.494689  0.5885666  0.5511020188    1.2187297
 [56,]  3.690819  0.7238266  0.5135725361    1.3053616
 [57,]  3.613002  0.6641667  0.5285472496    1.2359249
 [58,]  3.540490  0.6034160  0.5265522175    1.1571435
 [59,]  3.473374  0.5429977  0.5100711257    1.0700763
 [60,]  3.658506  0.6737977  0.4834406872    1.1757772
 [61,]  3.584549  0.6168528  0.4921697736    1.1042781
 [62,]  3.515661  0.5592019  0.4864895908    1.0251954
 [63,]  3.451932  0.5020878  0.4686914450    0.9400484
 [64,]  3.627599  0.6274164  0.4507304191    1.0558634
 [65,]  3.557032  0.5732587  0.4545655417    0.9833463
 [66,]  3.491320  0.5187211  0.4462746508    0.9053793
 [67,]  3.430550  0.4648831  0.4279039096    0.8236392
 [68,]  3.597982  0.5841044  0.4163948411    0.9421311
 [69,]  3.530421  0.5327852  0.4166775747    0.8701000
 [70,]  3.467519  0.4813402  0.4068201854    0.7948927
 [71,]  3.409359  0.4307040  0.3885844815    0.7180854
 [72,]  3.569548  0.5435312  0.3814329614    0.8331329
 [73,]  3.504670  0.4950624  0.3794508219    0.7633584
 [74,]  3.444269  0.4466394  0.3689934289    0.6925957
 [75,]  3.388429  0.3990733  0.3515170543    0.6221167
 [76,]  3.542189  0.5055402  0.3468608038    0.7289055
 [77,]  3.479705  0.4598797  0.3437891529    0.6632314
 [78,]  3.421534  0.4143487  0.3335657104    0.5984725
 [79,]  3.367761  0.3696589  0.3173401542    0.5354521
 [80,]  3.515778  0.4700798  0.3136724227    0.6304641
 [81,]  3.455419  0.4271198  0.3105132063    0.5706262
 [82,]  3.399226  0.3842859  0.3011707979    0.5131623
 [83,]  3.347293  0.3422172  0.2865078886    0.4583641
 [84,]  3.490166  0.4371382  0.2827996958    0.5393509
 [85,]  3.431668  0.3966954  0.2803243282    0.4868124
 [86,]  3.377209  0.3562943  0.2722751719    0.4375473
 [87,]  3.326901  0.3165330  0.2592680759    0.3912916
 [88,]  3.465171  0.4066843  0.2550686856    0.4572556
 [89,]  3.408263  0.3684883  0.2537685940    0.4130593
 [90,]  3.355296  0.3301829  0.2471516512    0.3724064
 [91,]  3.306406  0.2923595  0.2356475832    0.3345111
 [92,]  3.440569  0.3786145  0.2311456313    0.3857102
 [93,]  3.384969  0.3422975  0.2311908635    0.3503490
 [94,]  3.333249  0.3056734  0.2258441672    0.3181461
 [95,]  3.285579  0.2693670  0.2154312958    0.2878842
 [96,]  3.416072  0.3527065  0.2114657443    0.3258477
 [97,]  3.361487  0.3177940  0.2126702626    0.2991570
 [98,]  3.310771  0.2823605  0.2081138894    0.2746051
 [99,]  3.264137  0.2471083  0.1981239884    0.2506893
[100,]  3.391309  0.3285723  0.1961438539    0.2781901
          [,1]      [,2]
  [1,] 28.0000 0.0000000
  [2,]  4.8543 4.1669779
  [3,]  3.3058 2.9520740
  [4,]  5.5395 3.0235429
  [5,]  4.5231 2.4658379
  [6,]  3.8768 2.2507571
  [7,]  3.4256 2.0934343
  [8,]  4.6375 1.8598233
  [9,]  4.1797 1.8255274
 [10,]  3.8358 1.8601232
 [11,]  3.5179 1.8173146
 [12,]  4.4603 1.5954872
 [13,]  4.1649 1.5993799
 [14,]  3.8963 1.6110841
 [15,]  3.6570 1.6070138
 [16,]  4.3470 1.4805550
 [17,]  4.0971 1.4663874
 [18,]  3.8796 1.4599093
 [19,]  3.6564 1.4235046
 [20,]  4.2462 1.3334330
 [21,]  4.0799 1.3286502
 [22,]  3.8965 1.3135079
 [23,]  3.7117 1.2837995
 [24,]  4.2283 1.2627683
 [25,]  4.0630 1.2447411
 [26,]  3.9334 1.2314467
 [27,]  3.7742 1.2002562
 [28,]  4.2096 1.2006371
 [29,]  4.0278 1.1724597
 [30,]  3.8748 1.1623752
 [31,]  3.7477 1.1297571
 [32,]  4.1308 1.1587381
 [33,]  4.0169 1.1457387
 [34,]  3.8750 1.1141438
 [35,]  3.7410 1.0742313
 [36,]  4.1051 1.0985312
 [37,]  3.9684 1.0716202
 [38,]  3.8462 1.0315181
 [39,]  3.7223 0.9908655
 [40,]  4.0645 1.0688556
 [41,]  3.9325 1.0438599
 [42,]  3.8154 1.0108930
 [43,]  3.7031 0.9743047
 [44,]  4.0169 1.0392904
 [45,]  3.8889 1.0162478
 [46,]  3.7906 0.9819144
 [47,]  3.6882 0.9360860
 [48,]  4.0072 0.9961327
 [49,]  3.8967 0.9660188
 [50,]  3.7904 0.9404745
 [51,]  3.6839 0.8984420
 [52,]  3.9578 0.9728132
 [53,]  3.8459 0.9397906
 [54,]  3.7331 0.8927662
 [55,]  3.6419 0.8558779
 [56,]  3.9143 0.9244892
 [57,]  3.8135 0.8986297
 [58,]  3.7181 0.8704597
 [59,]  3.6480 0.8397507
 [60,]  3.8893 0.9152996
 [61,]  3.7788 0.8769148
 [62,]  3.6888 0.8444333
 [63,]  3.6188 0.8124818
 [64,]  3.8452 0.8835596
 [65,]  3.7444 0.8477071
 [66,]  3.6720 0.8253952
 [67,]  3.5888 0.7839318
 [68,]  3.8401 0.8608502
 [69,]  3.7467 0.8310835
 [70,]  3.6626 0.7989490
 [71,]  3.5931 0.7720353
 [72,]  3.7930 0.8240935
 [73,]  3.7204 0.8021267
 [74,]  3.6443 0.7726607
 [75,]  3.5667 0.7419512
 [76,]  3.7924 0.8012642
 [77,]  3.7136 0.7802332
 [78,]  3.6215 0.7438555
 [79,]  3.5408 0.7014752
 [80,]  3.7682 0.7807806
 [81,]  3.6758 0.7466806
 [82,]  3.5997 0.7196581
 [83,]  3.5354 0.6949171
 [84,]  3.7234 0.7498631
 [85,]  3.6413 0.7186103
 [86,]  3.5616 0.6835296
 [87,]  3.5025 0.6584963
 [88,]  3.7096 0.7240802
 [89,]  3.6314 0.7047203
 [90,]  3.5693 0.6717431
 [91,]  3.4969 0.6312835
 [92,]  3.6856 0.7042362
 [93,]  3.6069 0.6692161
 [94,]  3.5296 0.6185681
 [95,]  3.4756 0.5999371
 [96,]  3.6555 0.6456056
 [97,]  3.5927 0.6344440
 [98,]  3.5285 0.6151879
 [99,]  3.4725 0.5914589
[100,]  3.6379 0.6196592

PhyloMeasures documentation built on May 2, 2019, 6:17 a.m.