mpd.query: Computes the (standardized) value of the Mean Pairwise...

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

View source: R/PhyloMeasures.R

Description

Calculates the Mean Pairwise Distance (MPD) 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 Net Relatedness Index, NRI).

Usage

1
2
mpd.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 MPD for variation in species richness. For each tip set S, the observed MPD is standardized by subtracting the mean MPD 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) MPD values. The i-th entry in this vector stores the (standardized) MPD value of the i-th row in the input matrix.

Author(s)

Constantinos Tsirogiannis (tsirogiannis.c@gmail.com)

References

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.

Webb, C.O. 2000. Exploring the phylogenetic structure of ecological communities: An example for rain forest trees. The American Naturalist 156: 145-155.

See Also

mpd.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

#Calculate mpd values for each community
mpd.query(bird.families,comm)

#Calculate standardized versions under the uniform model
mpd.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
mpd.query(bird.families,comm,TRUE,null.model="sequential",
          abundance.weights=weights, reps=1000)

Example output

  [1] 44.75396 45.87298 46.00980 46.11592 44.92865 46.17159 45.56882 47.19918
  [9] 46.64620 47.41486 46.81894 44.64588 45.93747 45.78808 46.64049 47.04229
 [17] 45.46776 45.48359 46.12604 44.42661 47.30743 45.84506 46.43004 45.98106
 [25] 45.79853 46.00261 43.53976 46.63559 47.62612 44.44833 45.26857 45.34465
 [33] 46.33616 45.99967 46.85747 45.25159 45.72882 47.35069 46.69273 46.17633
 [41] 46.98139 46.01616 46.17371 45.32310 47.22498 48.15657 44.21143 44.45176
 [49] 47.68800 44.59069 45.47722 45.48865 45.72196 47.19755 46.20800 46.44343
 [57] 43.69469 46.52196 46.91559 45.85698 44.89437 47.07624 46.69894 46.33584
 [65] 46.27788 45.65910 46.84980 45.16261 46.21616 47.90727 46.06400 46.23820
 [73] 46.11706 46.58841 45.89535 46.54220 45.95673 45.79086 46.97665 46.93404
 [81] 47.19918 46.82498 46.76392 48.35869 45.82988 45.08098 44.88522 45.53012
 [89] 47.28996 47.46465 46.92147 47.23804 47.00473 45.79461 46.71788 45.99445
 [97] 46.46743 46.75069 46.71869 43.92898
  [1] -1.39854063 -0.28124492 -0.14463946 -0.03868058 -1.22411600  0.01690709
  [7] -0.58493939  1.04291514  0.49078783  1.25825620  0.66325630 -1.50645569
 [13] -0.21685452 -0.36601203  0.48508235  0.88625900 -0.68584486 -0.67003253
 [19] -0.02857373 -1.72538305  1.15099321 -0.30912026  0.27495773 -0.17332987
 [25] -0.35557916 -0.15181206 -2.61087332  0.48019194  1.46919590 -1.70370223
 [31] -0.88472154 -0.80875717  0.18122487 -0.15474631  0.70172753 -0.90167496
 [37] -0.42518599  1.19419183  0.53724673  0.02163448  0.82545490 -0.13828193
 [43]  0.01902626 -0.83027497  1.06867130  1.99882732 -1.94023507 -1.70027894
 [49]  1.53097808 -1.56155431 -0.67639006 -0.66497911 -0.43203257  1.04128501
 [55]  0.05325914  0.28832485 -2.45617334  0.36673443  0.75976039 -0.29722026
 [61] -1.25834888  0.92016585  0.54344125  0.18089884  0.12302899 -0.49479283
 [67]  0.69406588 -0.99051741  0.06140982  1.74990544 -0.09051892  0.08341667
 [73] -0.03753948  0.43308099 -0.25891205  0.38694812 -0.19761891 -0.36324080
 [79]  0.82072751  0.77818094  1.04291514  0.66928781  0.60832069  2.20063825
 [85] -0.32428053 -1.07202425 -1.26747764 -0.62357363  1.13355075  1.30797538
 [91]  0.76562889  1.08171240  0.84876586 -0.35949148  0.56235084 -0.15996275
 [97]  0.31228786  0.59511658  0.56316590 -2.22224872
  [1] -1.40856642 -0.17726406 -0.02671966  0.09005107 -1.21634385  0.15131078
  [7] -0.51194692  1.28201067  0.67354538  1.51932471  0.86361219 -1.52749291
 [13] -0.10630339 -0.27068064  0.66725773  1.10936965 -0.62314858 -0.60572279
 [19]  0.10118920 -1.76875919  1.40111681 -0.20798375  0.43569240 -0.05833757
 [25] -0.25918322 -0.03462414 -2.74460313  0.66186831  1.75178827 -1.74486610
 [31] -0.84231824 -0.75860261  0.33239523 -0.03785779  0.90600894 -0.86100156
 [37] -0.33589260  1.44872333  0.72474485  0.15652055  1.04236122 -0.01971341
 [43]  0.15364620 -0.78231605  1.31039494  2.33546223 -2.00553428 -1.74109351
 [49]  1.81987458 -1.58821368 -0.61272904 -0.60015373 -0.34343778  1.28021420
 [55]  0.19137212  0.45042348 -2.57411788  0.53683381  0.96996337 -0.19486950
 [61] -1.25406977  1.14673628  0.73157145  0.33203593  0.26826115 -0.41260198
 [67]  0.89756552 -0.95890931  0.20035449  2.06114086  0.03292324  0.22460687
 [73]  0.09130860  0.60995025 -0.15265239  0.55911008 -0.08510502 -0.26762664
 [79]  1.03715145  0.99026351  1.28201067  0.87025914  0.80307106  2.55786555
 [85] -0.22469094 -1.04873295 -1.26413002 -0.55452332  1.38189455  1.57411712
 [91]  0.97643067  1.32476672  1.06805078 -0.26349475  0.75241053 -0.04360650
 [97]  0.47683163  0.78851963  0.75330877 -2.31632405

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