주요 콘텐츠

pdist

Calculate pairwise patristic distances in phytree object

Description

D = pdist(Tree) returns D, a vector containing the patristic distances between every possible pair of leaf nodes of Tree, a phylogenetic tree object. The patristic distances are computed by following paths through the branches of the tree and adding the patristic branch distances originally created with the seqlinkage function.

example

D = pdist(___,Name=Value) specifies additional parameters using one or more name-value arguments for calculating pairwise patristic distances in a phytree object.

example

[D,C] = pdist(___) also returns C, the index of the closest common parent nodes for every possible pair of query nodes for any of the previous syntaxes.

Examples

collapse all

Create a phytree object from a phylogenetic tree file.

tr = phytreeread('pf00002.tree')
    Phylogenetic tree object with 33 leaves (32 branches)

Calculate the patristic distances between pairs of leaves in the tree, and format the output as a square matrix.

dist = pdist(tr,Nodes="leaves",Squareform=true)
dist = 33×33

         0    0.2179    0.2834    0.3755    0.3775    0.4111    0.4374    0.5082    0.5337    0.5337    0.5532    0.5532    0.5532    0.5532    0.6776    0.6776    0.6776    0.6776    0.6776    0.6776    0.7113    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.8384
    0.2179         0    0.2834    0.3755    0.3775    0.4111    0.4374    0.5082    0.5337    0.5337    0.5532    0.5532    0.5532    0.5532    0.6776    0.6776    0.6776    0.6776    0.6776    0.6776    0.7113    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.8384
    0.2834    0.2834         0    0.3755    0.3775    0.4111    0.4374    0.5082    0.5337    0.5337    0.5532    0.5532    0.5532    0.5532    0.6776    0.6776    0.6776    0.6776    0.6776    0.6776    0.7113    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.8384
    0.3755    0.3755    0.3755         0    0.3775    0.4111    0.4374    0.5082    0.5337    0.5337    0.5532    0.5532    0.5532    0.5532    0.6776    0.6776    0.6776    0.6776    0.6776    0.6776    0.7113    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.8384
    0.3775    0.3775    0.3775    0.3775         0    0.4111    0.4374    0.5082    0.5337    0.5337    0.5532    0.5532    0.5532    0.5532    0.6776    0.6776    0.6776    0.6776    0.6776    0.6776    0.7113    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.8384
    0.4111    0.4111    0.4111    0.4111    0.4111         0    0.4374    0.5082    0.5337    0.5337    0.5532    0.5532    0.5532    0.5532    0.6776    0.6776    0.6776    0.6776    0.6776    0.6776    0.7113    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.8384
    0.4374    0.4374    0.4374    0.4374    0.4374    0.4374         0    0.5082    0.5337    0.5337    0.5532    0.5532    0.5532    0.5532    0.6776    0.6776    0.6776    0.6776    0.6776    0.6776    0.7113    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.8384
    0.5082    0.5082    0.5082    0.5082    0.5082    0.5082    0.5082         0    0.5337    0.5337    0.5532    0.5532    0.5532    0.5532    0.6776    0.6776    0.6776    0.6776    0.6776    0.6776    0.7113    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.8384
    0.5337    0.5337    0.5337    0.5337    0.5337    0.5337    0.5337    0.5337         0    0.3620    0.5532    0.5532    0.5532    0.5532    0.6776    0.6776    0.6776    0.6776    0.6776    0.6776    0.7113    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.8384
    0.5337    0.5337    0.5337    0.5337    0.5337    0.5337    0.5337    0.5337    0.3620         0    0.5532    0.5532    0.5532    0.5532    0.6776    0.6776    0.6776    0.6776    0.6776    0.6776    0.7113    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.8384
    0.5532    0.5532    0.5532    0.5532    0.5532    0.5532    0.5532    0.5532    0.5532    0.5532         0    0.5071    0.5071    0.5071    0.6776    0.6776    0.6776    0.6776    0.6776    0.6776    0.7113    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.8384
    0.5532    0.5532    0.5532    0.5532    0.5532    0.5532    0.5532    0.5532    0.5532    0.5532    0.5071         0    0.4135    0.4570    0.6776    0.6776    0.6776    0.6776    0.6776    0.6776    0.7113    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.8384
    0.5532    0.5532    0.5532    0.5532    0.5532    0.5532    0.5532    0.5532    0.5532    0.5532    0.5071    0.4135         0    0.4570    0.6776    0.6776    0.6776    0.6776    0.6776    0.6776    0.7113    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.8384
    0.5532    0.5532    0.5532    0.5532    0.5532    0.5532    0.5532    0.5532    0.5532    0.5532    0.5071    0.4570    0.4570         0    0.6776    0.6776    0.6776    0.6776    0.6776    0.6776    0.7113    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.8384
    0.6776    0.6776    0.6776    0.6776    0.6776    0.6776    0.6776    0.6776    0.6776    0.6776    0.6776    0.6776    0.6776    0.6776         0    0.4545    0.5810    0.5810    0.6431    0.6431    0.7113    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.7832    0.8384
      ⋮

Input Arguments

collapse all

Phylogenetic tree, specified as a phytree object.

Name-Value Arguments

collapse all

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Example: D = pdist(tree,Nodes="leaves",SquareForm=true)

Tree nodes included in the computation, specified as "leaves" or "all".

By default, the value is "leaves" and the function computes the distances between leaves only. The corresponding size of the squared output matrix is M-by-M, where M is the number of leaves.

If the value is "all", the function computes the distances between leaves and internal nodes (branches), that is, the sum of the number of leaves and number of branches. M is NumLeaves+NumBranches. Use this option if you need distances among internal nodes and leaf nodes.

Example: pdist(tr,Nodes="leaves")

Flag to return the output as a square matrix, specified as false or true. If the value is true, pdist converts the output into a square-formatted matrix, so that D(I,J) denotes the distance between the Ith and the Jth nodes. The output matrix is symmetric and has a zero diagonal.

Example: pdist(tr,Squareform=true)

Criteria used to relate pairs in computing distances, specified as "distance" or "levels".

By default, the value is "distance", and the function returns the patristic distances in the output argument D.

If the value is "levels", the function treats each branch as having a unit length and returns count levels instead of computed patristic distances in the output argument D.

Example: pdist(tr,CriteriaValue="levels")

Output Arguments

collapse all

Pairwise patristic distances, returned as a numeric vector or matrix. It contains the patristic distances between every possible pair of leaf nodes of Tree. The numeric vector is arranged in the order ((2,1), (3,1), ..., (M,1), (3,2), ..., (M,2), ..., (M,M-1)) (the lower-left triangle of the full M-by-M distance matrix). To get the distance between the Ith and Jth nodes (I > J), use the formula D((J-1)*(M-J/2)+I-J). M is the number of leaves.

Closest common parent node, returned as a numeric vector. It contains the indices of the closest common parent nodes for every possible pair of query nodes.

Version History

Introduced before R2006a