cdnt.averaged.query: Computes the value of the averaged Community Distance Nearest...

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

View source: R/PhyloMeasures.R

Description

Calculates the averaged Community Distance Nearest Taxon (aCDNT) given paired sets of tips on a phylogeny. The aCDNT is a beta diversity version of MNTD. It is computed based on the values of the directed CDNT (dCDNT); let A and B be two tip sets in the input tree. Let dCDNT(A,B) be the directed CDNT from A to B, and let dCDNT(B,A) be the directed CDNT from B to A. Let also |A| denote the number of elements in A, and |B| the number of elements in B. The aCDNT between these two tip sets is equal to:

(|A| dCDNT(A,B)+|B| dCDNT(B,A))/(|A|+|B|)

The version of this function that computes the standardised value of aCDNT is not yet available.

Usage

1
2
cdnt.averaged.query(tree, matrix.a, matrix.b = NULL, 
                    query.matrix = NULL)

Arguments

tree

A phylo tree object

matrix.a

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

matrix.b

Optional, a second matrix with a similar format as matrix.a

query.matrix

Optional, a two-column matrix specifying the pairs of rows (tip sets) for which the function computes the aCDNT values. Each row in query.matrix indicates a pair of tip sets for which we want to compute the aCDNT value. Let k and r be the values that are stored in the i-th row of query.matrix, where k is the value stored in the first column and r is the value stored in the second column. If matrix.b is given, the aCDNT value is computed between the k-th row of matrix.a and the r-th row of matrix.b. If matrix.b is not given, the aCDNT value is computed between the k-th and r-th row of matrix.a (default = NULL)

Details

Queries can be given in four ways. If neither matrix.b nor query.matrix are given, the function computes the aCDNT values for all pairs of rows (tip sets) in matrix.a . If matrix.b is given but not query.matrix, the function computes the aCDNT values for all combinations of a row in matrix.a with rows in matrix.b. If query.matrix is given and matrix.b is not, the function returns the aCDNT values for the pairs of rows in matrix.a specified by query.matrix. If query.matrix and matrix.b are both given, aCDNT values are computed for the rows in matrix.a specified by the first column of query.matrix against the rows in matrix.b specified in the second column of query.matrix

Value

The aCDNT values for the requested pairs of tip sets. If query.matrix is provided, then the values are returned in an one-dimensional vector. The i-th element of this vector is the aCDNT value for the pair of tip sets indicated in the i-th row of query.matrix. If query.matrix is not provided, the aCDNT values are returned in a matrix object; entry [i,j] in the output matrix stores the aCDNT value between the tip sets specified on the i-th and j-th row of matrix.a (if matrix.b is not specified), or the aCDNT value between the i-th row of matrix.a and the j-th row of matrix.b (if matrix.b is specified)

Author(s)

Constantinos Tsirogiannis (tsirogiannis.c@gmail.com)

References

Graham, C.H. and P.V.A. Fine. 2008. Phylogenetic beta diversity: linking ecological and evolutionary processes across space and time. Ecology Letters 11: 1265:1277.

Swenson, N.G. 2011. Phylogenetic beta diversity metrics, trait evolution and inferring functional beta diversity of communities. PLoS ONE: 6: e21264.

See Also

cdnt.directed.query, cdnt.query

Examples

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

#Create 10 random communities with 50 families each
comm = matrix(0,nrow = 10,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 all pairwise aCDNT values for communities in comm
cdnt.averaged.query(bird.families,comm)

#Calculate pairwise distances from 
#the first two rows of comm to all rows
cdnt.averaged.query(bird.families, comm[1:2,],comm)

#Calculate the distances from the first two rows 
#to all rows using the query matrix
qm = expand.grid(1:2,1:10)
cdnt.averaged.query(bird.families,comm,query.matrix = qm)

Example output

        [,1]   [,2]   [,3]   [,4]   [,5]   [,6]   [,7]   [,8]   [,9]  [,10]
 [1,]  0.000 19.426 20.800 18.430 19.072 17.604 17.582 16.398 20.278 19.982
 [2,] 19.426  0.000 19.512 18.842 17.744 15.078 18.242 16.596 17.454 17.532
 [3,] 20.800 19.512  0.000 16.998 19.082 20.416 19.536 15.854 19.278 16.204
 [4,] 18.430 18.842 16.998  0.000 16.304 19.080 17.874 17.856 19.206 18.104
 [5,] 19.072 17.744 19.082 16.304  0.000 19.458 19.234 16.342 16.272 16.996
 [6,] 17.604 15.078 20.416 19.080 19.458  0.000 17.882 19.482 17.750 18.614
 [7,] 17.582 18.242 19.536 17.874 19.234 17.882  0.000 18.860 16.820 16.726
 [8,] 16.398 16.596 15.854 17.856 16.342 19.482 18.860  0.000 17.728 18.170
 [9,] 20.278 17.454 19.278 19.206 16.272 17.750 16.820 17.728  0.000 18.898
[10,] 19.982 17.532 16.204 18.104 16.996 18.614 16.726 18.170 18.898  0.000
       [,1]   [,2]   [,3]   [,4]   [,5]   [,6]   [,7]   [,8]   [,9]  [,10]
[1,]  0.000 19.426 20.800 18.430 19.072 17.604 17.582 16.398 20.278 19.982
[2,] 19.426  0.000 19.512 18.842 17.744 15.078 18.242 16.596 17.454 17.532
 [1]  0.000 19.426 19.426  0.000 20.800 19.512 18.430 18.842 19.072 17.744
[11] 17.604 15.078 17.582 18.242 16.398 16.596 20.278 17.454 19.982 17.532

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