pd.query: Computes the (standardized) value of the unrooted...

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

View source: R/PhyloMeasures.R

Description

Calculates the unrooted phylogenetic diversity (PD) measure for sets of tips on a phylogeny. The same function can also calculate the standardized value of this measure under three different null models which maintain species richness (this is equal to the Phylogenetic Diversity Index, PDI).

Usage

1
2
pd.query(tree, matrix, standardize = FALSE, 
         null.model="uniform", abundance.weights, reps=1000, seed)

Arguments

tree

A phylo tree object

matrix

A matrix with binary (0/1) values, where each row represents a tip set. Each column name in the matrix must match a tip label on the input tree. If not all values in the matrix are binary, we consider two cases; if the matrix contains only non-negative values, all values are coerced to binary ones and a warning message is printed. If the matrix contains at least one negative value, the function throws an error.

standardize

Specifies whether the function should standardize the PD for variation in species richness. For each tip set S, the observed PD is standardized by subtracting the mean PD and dividing by the standard deviation of this measure. The mean and standard deviation are calculated among all tip sets that have the same number of elements as set S, the tip set whose value we want to standardize (default = FALSE).

null.model

A character vector (string) that defines which null model is used for computing the standardized values of the measure. There are three possible null models that can be used for computing the standardized values: these are "uniform", "frequency.by.richness", and "sequential". All these 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.

  • "frequency.by.richness" is an abundance-weighted model where species samples are chosen in a manner similar to the following process; first, each species is selected independently with probability proportional to its abundance. If the resulting sample consists of exactly the same number of elements as the input assemblage then it is used by the null model, otherwise it is tossed and the whole process is repeated.

  • "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 two models (which are computed analytically), this model uses Monte-Carlo randomization.

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

abundance.weights

A vector of positive numeric values. These are the abundance weights that will be used if either of the options "frequency.by.richness" or "sequential" are 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 any of the other two null models 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 any of the other two null models is selected.

Value

A vector which stores the computed (standardized) PD values. The i-th entry in this vector stores the (standardized) PD value of the i-th row in the input matrix.

Author(s)

Constantinos Tsirogiannis (tsirogiannis.c@gmail.com)

References

Faith, D.P. 1992. Conservation evaluation and phylogenetic diversity. Biological Conservation 61: 1-10.

Tsirogiannis, C. and B. Sandel. 2015. PhyloMeasures: A package for computing phylogenetic biodiversity measures and their statistical moments. Ecography, doi: 10.1111/ecog.01814, 2015.

Tsirogiannis, C., B. Sandel and D. Cheliotis. 2012. Efficient computation of popular phylogenetic tree measures. Algorithms in Bioinformatics, LNCS 7534: 30-43.

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

See Also

pd.moments

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
#Load phylogenetic tree of bird families from package "ape"
data(bird.families, package = "ape")

#Create 100 random communities with 50 families each
comm = matrix(0,nrow = 100,ncol = length(bird.families$tip.label))
for(i in 1:nrow(comm)) {comm[i,sample(1:ncol(comm),50)] = 1}
colnames(comm) = bird.families$tip.label

#Use query function to calculate pd values for each community
pd.query(bird.families,comm)

#Use query function to calculate standardized versions under the uniform model
pd.query(bird.families,comm,TRUE)

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

#Use query function to calculate standardized versions under the sequential model
pd.query(bird.families,comm,TRUE,null.model="sequential",
         abundance.weights=weights, reps=1000)

Example output

  [1] 856.7 836.8 859.2 821.4 803.1 822.2 829.8 836.8 811.5 780.3 860.4 850.6
 [13] 807.3 828.5 848.6 846.4 852.2 849.9 858.6 858.4 847.2 849.0 841.6 817.1
 [25] 849.0 826.0 831.2 857.6 853.9 802.0 878.3 833.1 830.4 820.4 853.3 871.3
 [37] 859.7 843.3 852.5 795.2 859.9 882.1 852.2 840.5 871.9 864.3 847.2 821.1
 [49] 824.1 865.0 861.3 874.9 867.0 796.6 843.0 845.6 802.0 806.1 887.2 882.1
 [61] 860.1 836.3 822.3 863.0 827.0 864.0 863.0 837.2 854.7 838.5 847.2 829.1
 [73] 866.8 790.1 818.7 809.7 815.0 832.6 875.8 858.7 851.6 812.7 862.2 823.9
 [85] 821.1 824.6 872.7 790.3 836.7 829.3 874.6 850.8 841.4 853.2 819.3 840.2
 [97] 798.2 844.6 826.1 853.6
  [1]  0.79115491 -0.05253239  0.89714577 -0.70543613 -1.48128927 -0.67151905
  [7] -0.34930682 -0.05253239 -1.12515996 -2.44792597  0.94802139  0.53253719
 [13] -1.30322461 -0.40442207  0.44774450  0.35447254  0.60037135  0.50285975
 [19]  0.87170797  0.86322870  0.38838961  0.46470304  0.15097007 -0.88774042
 [25]  0.46470304 -0.51041293 -0.28995193  0.82931162  0.67244514 -1.52792525
 [31]  1.70691599 -0.20939887 -0.32386901 -0.74783247  0.64700733  1.41014157
 [37]  0.91834395  0.22304386  0.61309025 -1.81622041  0.92682322  1.86802211
 [43]  0.60037135  0.10433409  1.43557938  1.11336714  0.38838961 -0.71815503
 [49] -0.59096599  1.14304458  0.98617810  1.56276841  1.22783728 -1.75686552
 [55]  0.21032496  0.32055546 -1.52792525 -1.35410023  2.08424348  1.86802211
 [61]  0.93530249 -0.07373056 -0.66727942  1.05825189 -0.46801659  1.10064824
 [67]  1.05825189 -0.03557385  0.70636221  0.01954140  0.38838961 -0.37898426
 [73]  1.21935801 -2.03244178 -0.81990626 -1.20147338 -0.97677275 -0.23059705
 [79]  1.60092513  0.87594760  0.57493354 -1.07428434  1.02433481 -0.59944526
 [85] -0.71815503 -0.56976782  1.46949645 -2.02396251 -0.05677202 -0.37050499
 [91]  1.55004951  0.54101646  0.14249080  0.64276769 -0.79446846  0.09161519
 [97] -1.68903137  0.27815911 -0.50617330  0.65972623
  [1]  0.91357159  0.05431454  1.02151846 -0.61063815 -1.40080920 -0.57609515
  [7] -0.24793668  0.05431454 -1.03810773 -2.38528461  1.07333295  0.65018124
 [13] -1.21945847 -0.30406905  0.56382375  0.46883051  0.71926724  0.61995612
 [19]  0.99561121  0.98697546  0.50337350  0.58109525  0.26157253 -0.79630675
 [25]  0.58109525 -0.41201591 -0.18748643  0.95243246  0.79267110 -1.44830582
 [31]  1.84623251 -0.10544682 -0.22202943 -0.65381689  0.76676386  1.54398129
 [37]  1.04310783  0.33497639  0.73222086 -1.74192129  1.05174358  2.01031174
 [43]  0.71926724  0.21407591  1.56988853  1.24173006  0.50337350 -0.62359177
 [49] -0.49405553  1.27195519  1.11219383  1.69942477  1.35831268 -1.68147105
 [55]  0.32202277  0.43428751 -1.44830582 -1.27127296  2.23052335  2.01031174
 [61]  1.06037933  0.03272517 -0.57177727  1.18559769 -0.36883717  1.22877644
 [67]  1.18559769  0.07158604  0.82721410  0.12771841  0.50337350 -0.27816180
 [73]  1.34967693 -1.96213290 -0.72722076 -1.11582948 -0.88698212 -0.12703619
 [79]  1.73828564  0.99992909  0.69335999 -0.98629324  1.15105470 -0.50269128
 [85] -0.62359177 -0.47246616  1.60443153 -1.95349715  0.04999667 -0.26952605
 [91]  1.68647115  0.65881699  0.25293678  0.76244598 -0.70131351  0.20112228
 [97] -1.61238506  0.39110876 -0.40769804  0.77971748

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