Main Content

phytree

Data structure containing phylogenetic tree

    Description

    A phytree object is a data structure containing a phylogenetic tree. Phylogenetic trees are binary rooted trees, which means that each branch is the parent of two other branches, two leaves, or one branch and one leaf. A phytree object can be ultrametric or nonultrametric.

    Creation

    Description

    tree = phytree(B) creates an ultrametric phylogenetic tree object. In an ultrametric phylogenetic tree object, all leaves are the same distance from the root.

    example

    tree = phytree(B,D) creates an additive (ultrametric or nonultrametric) phylogenetic tree object with branch distances defined by D.

    example

    tree = phytree(B,C) creates an ultrametric phylogenetic tree object with distances between branches and leaves defined by C.

    example

    tree = phytree(BC) creates an ultrametric phylogenetic binary tree object with branch pointers in BC(:,[1 2]) and branch coordinates in BC(:,3). Same as phytree(B,C).

    tree = phytree(___,N) specifies the names for the leaves, the branches, or both. Use this syntax with any of the previous arguments.

    tree = phytree creates an empty phylogenetic tree object.

    Input Arguments

    expand all

    Branches of the tree, specified as a numeric array of size [NUMBRANCHES X 2]. Each row represents a branch of the tree. It contains two pointers to the branch or leaf nodes, which are its children.

    Leaf nodes are numbered from 1 to NUMLEAVES and branch nodes are numbered from NUMLEAVES + 1 to NUMLEAVES + NUMBRANCHES. Note that because only binary trees are allowed, NUMLEAVES = NUMBRANCHES + 1.

    Branches are defined in chronological order (for example, B(i,:) > NUMLEAVES + i). As a consequence, the first row can only have pointers to leaves, and the last row must represent the root branch. Parent-child distances are set to 1, unless the child is a leaf and to satisfy the ultrametric condition of the tree its distance is increased.

    Data Types: double

    Distances from every node to their parent branch, specified as a numeric array of size [NUMNODES X 1] with the distances of every child node (leaf or branch) to its parent branch equal to NUMNODES = NUMLEAVES + NUMBRANCHES. The last distance in D is the distance of the root node and is meaningless.

    Data Types: double

    Distances for every branch to the leaves, specified as a numeric array of size [NUMBRANCHES X 1]. In ultrametric trees, all of the leaves are at the same location (same distance to the root).

    Data Types: double

    Pointers to branches or leaves and distances of branches, specified as a combined matrix. The branch pointers are in BC(:,[1 2]) and branch coordinates are in BC(:,3).

    The syntax phytree(BC) is the same as phytree(B,C).

    Data Types: double

    Names of leaves and branches, specified as a string vector or cell array of character vectors. If NUMEL(N)==NUMLEAVES, then the names are assigned chronologically to the leaves. If NUMEL(N)==NUMBRANCHES, the names are assigned to the branch nodes. If NUMEL(N)==NUMLEAVES + NUMBRANCHES, all the nodes are named. Unassigned names default to 'Leaf #' and/or 'Branch #' as required.

    Data Types: string | cell

    Properties

    expand all

    Note

    You can access these properties using the get method.

    This property is read-only.

    Number of leaves, stored as a positive integer.

    This property is read-only.

    Number of branches, stored as a positive integer.

    This property is read-only.

    Number of nodes (NumLeaves + NumBranches), stored as a positive integer.

    This property is read-only.

    Branch to leaf or branch connectivity list, stored as a matrix.

    This property is read-only.

    Edge length for every leaf or branch, stored as a numeric array of size [NUMNODES X 1]. Here, NUMNODES = NUMLEAVES + NUMBRANCHES.

    This property is read-only.

    Names of the leaves, stored as a cell array of character vectors.

    This property is read-only.

    Names of the branches, stored as a cell array of character vectors.

    This property is read-only.

    Names of all the nodes, stored as a cell array of character vectors.

    Object Functions

    clusterValidate clusters in phylogenetic tree
    getRetrieve information about phylogenetic tree object
    getbynameBranches and leaves from phytree object
    getcanonicalCalculate canonical form of phylogenetic tree
    getmatrixConvert phytree object into relationship matrix
    getnewickstrCreate Newick-formatted character vector
    pdistCalculate pairwise patristic distances in phytree object
    plotDraw phylogenetic tree
    pruneRemove branch nodes from phylogenetic tree
    reorderReorder leaves of phylogenetic tree
    rerootChange root of phylogenetic tree
    selectSelect tree branches and leaves in phytree object
    subtreeExtract phylogenetic subtree
    viewView phylogenetic tree
    weightsCalculate weights for phylogenetic tree

    Examples

    collapse all

    Create a tree with three leaves and two branches.

    B = [1 2;3 4];
    tree = phytree(B)
        Phylogenetic tree object with 3 leaves (2 branches)
    
    view(tree)

    Figure Phylogenetic Tree 1 contains an axes object. The axes object contains 12 objects of type line. One or more of the lines displays its values using only markers

    Create an additive (ultrametric or nonultrametric) phylogenetic tree object with branch distances specified as a column vector.

    B = [1 2;3 4];
    D = [1 2 1.5 1 0]';
    tree = phytree(B,D);
    view(tree)

    Figure Phylogenetic Tree 1 contains an axes object. The axes object contains 12 objects of type line. One or more of the lines displays its values using only markers

    Create an ultrametric phylogenetic tree object with distances between branches and leaves defined by a vector.

    B = [1 2;3 4];
    C = [1 4]';
    tree = phytree(B,C)
        Phylogenetic tree object with 3 leaves (2 branches)
    
    view (tree)

    Figure Phylogenetic Tree 1 contains an axes object. The axes object contains 12 objects of type line. One or more of the lines displays its values using only markers

    Create a phylogenetic tree from a multiple sequence alignment file.

    Read a multiple sequence alignment file.

    Sequences = multialignread('aagag.aln');

    Calculate the distance between each pair of sequences.

    distances = seqpdist(Sequences);

    Construct a phylogenetic tree object from the pairwise distances calculated previously.

    tree = seqlinkage(distances);

    View the phylogenetic tree.

    phytreeviewer(tree)

    Figure Phylogenetic Tree 1 contains an axes object. The axes object contains 38 objects of type line. One or more of the lines displays its values using only markers

    Version History

    Introduced in R2006b