Main Content

prune

Remove branch nodes from phylogenetic tree

Syntax

T2 = prune(T1, Nodes)
T2 = prune(T1, Nodes, 'Mode','Exclusive')

Arguments

T1Phylogenetic object created with the phytree constructor function.
Nodes

Nodes to remove from tree.

Mode

Property to control the method of pruning. Enter either 'Inclusive' or 'Exclusive'. The default value is 'Inclusive'.

Description

T2 = prune(T1, Nodes)removes the nodes listed in the vector Nodes from the tree T1. prune removes any branch or leaf nodes listed in Nodes and all their descendants from the tree T1, and returns the modified tree T2. The parent nodes are connected to the 'brothers' as required. Nodes in the tree are labeled as [1:numLeaves] for the leaves and as [numLeaves+1:numLeaves+numBranches] for the branches. Nodes can also be a logical array of size [numLeaves+numBranches x 1] indicating the nodes to be removed.

T2 = prune(T1, Nodes, 'Mode','Exclusive') changes the Mode property for pruning to 'Exclusive' and removes only the descendants of the nodes listed in the vector Nodes. Nodes that do not have a predecessor become leaves in the list Nodes. In this case, pruning is the process of reducing a tree by turning some branch nodes into leaf nodes, and removing the leaf nodes under the original branch.

Examples

Load a phylogenetic tree created from a protein family

tr = phytreeread('pf00002.tree');
view(tr)    

Remove all the 'mouse' proteins

ind = getbyname(tr,'mouse');
tr = prune(tr,ind);
view(tr)

Remove potential outliers in the tree

[sel,sel_leaves] = select(tr,'criteria','distance',...
                             'threshold',.3,...
                             'reference','leaves',...
                             'exclude','leaves',...
                             'propagate','toleaves');
tr = prune(tr,~sel_leaves)
view(tr)

Version History

Introduced before R2006a