Extract phylogenetic pairs from a phylogeny, i.e. mutually closest pairs from a distance matrix.

extractPP(tree = NULL, tipDists = NULL, vcvMat = NULL, z = NULL)

Arguments

tree

a phylo object; Can be left NULL, in which case the tipDists matrix should be specified;

tipDists

a N by N numeric matrix containing the tip-distances in the tree; can be NULL, in which case it is going to be calculated; if specified, the tree-parameter will only be used for calculation of vcvMat and no validation of tip-distances in the tree with the tipDists matrix will be done.

vcvMat

a N by N matrix where N is the number of tips in the tree. The diagonal elements of this matrix represent the root-tip distances; the off-diagonal elements represent the distance from the root to the most recent common ancestor of each couple of tips. This matrix is calculated by the vcv function from the ape package. If tree is specified, the matrix can be specified only for the sake of saving calculation time when a call to vcv has already been executed on the tree; If the tree is not specified (i.e. a tipDists-matrix is given), then it is assumed that the tree is ultrametric with length equal to t=max(tipDists)/2 and vcvMat[i,j] is calculated as vcvMat[i,j]=t-tipDists[i,j]/2.

z

(optional, defaults to NULL) a numeric vector with phenotypes corresponding to the tips in tree or the row numbers in tipDists.

Value

a data.table with five columns: i, j : integers - the members of each phylogenetic pair. For each entry (i,j) a symmetric entry (j,i) is present; to obtain the corresponding tip labels in the tree use tree$tip.label[i] and tree$tip.label[j] respectively. tau: the phylogenetic distance between i and j t: the root-tip distance of the mrca of i and j idPair: the unique identifier of each pair z: the value corresponding to each i (this column doesn't exist if no parameter z is specified) deltaz: the absolute phenotypic distance between members of a pair (this column doesn't exist if no parameter z is specified)

Details

Phylogenetic pairs represent pairs of tips each of which is the other's nearest neighbor-tip in the phylogenty according to patristic (phylogenetic distance)