reorder
Reorder leaves of phylogenetic tree
Syntax
Tree1Reordered = reorder(Tree1, Order)
[Tree1Reordered, OptimalOrder]
= reorder(Tree1, Order,
'Approximate', ApproximateValue)
[Tree1Reordered, OptimalOrder]
= reorder(Tree1, Tree2)
Input Arguments
| Tree1,Tree2 | Phytree objects. | 
| Order | Vector with position indices for each leaf. | 
| ApproximateValue | Controls the use of the optimal leaf-ordering
calculation to find the closest order possible to the suggested one
without dividing the clades or producing crossing branches. Enter trueto
use the calculation. Default isfalse. | 
Output Arguments
| Tree1Reordered | Phytree object with reordered leaves. | 
| OptimalOrder | Vector of position indices for each leaf in Tree1Reordered,
determined by the optimal leaf-ordering calculation. | 
Description
Tree1Reordered = reorder(Tree1, Order)Tree1,
without modifying its structure and distances, creating a new phylogenetic
tree, Tree1Reordered. Order is
a vector of position indices for each leaf. If Order is
invalid, that is, if it divides the clades (or produces crossing branches),
then reorder returns an error message.
[ controls
the use of the optimal leaf-ordering calculation, which finds the
best approximate order closest to the suggested one, without dividing
the clades or producing crossing branches. Enter Tree1Reordered, OptimalOrder]
= reorder(Tree1, Order,
'Approximate', ApproximateValue)true to
use the calculation and return Tree1Reordered,
the reordered tree, and OptimalOrder, a
vector of position indices for each leaf in Tree1Reordered,
determined by the optimal leaf-ordering calculation. Default is false. 
[ uses
the optimal leaf-ordering calculation to reorder the leaves in Tree1Reordered, OptimalOrder]
= reorder(Tree1, Tree2)Tree1 such
that it matches the order of leaves in Tree2 as
closely as possible, without dividing the clades or producing crossing
branches. Tree1Reordered is the reordered
tree, and OptimalOrder is a vector of position
indices for each leaf in Tree1Reordered,
determined by the optimal leaf-ordering calculation
Examples
- Create and view a phylogenetic tree. - b = [1 2; 3 4; 5 6; 7 8; 9 10]; tree = phytree(b) Phylogenetic tree object with 6 leaves (5 branches) view(tree) 
- Reorder the leaves on the phylogenetic tree, and then view the reordered tree. - treeReordered = reorder(tree, [5, 6, 3, 4, 1, 2]) view(treeReordered) 
- Create a phylogenetic tree by reading a Newick-formatted tree file (ASCII text file). - tree = phytreeread('pf00002.tree') Phylogenetic tree object with 33 leaves (32 branches)
- Create a row vector of the leaf names in alphabetical order. - [dummy,order] = sort(get(tree,'LeafNames')); 
- Reorder the phylogenetic tree to match as closely as possible the row vector of alphabetically ordered leaf names, without dividing the clades or having crossing branches. - treeReordered = reorder(tree,order,'approximate',true) Phylogenetic tree object with 33 leaves (32 branches)
- View the original and the reordered phylogenetic trees. - view(tree) view(treeReordered) 
- Create a phylogenetic tree by reading sequence data from a FASTA file, calculating the pairwise distances between sequences, and then using the neighbor-joining method. - seqs = fastaread('pf00002.fa') seqs = 33x1 struct array with fields: Header Sequence dist = seqpdist(seqs,'method','jukes-cantor','indels','pair'); NJtree = seqneighjoin(dist,'equivar',seqs) Phylogenetic tree object with 33 leaves (32 branches)
- Create another phylogenetic tree from the same sequence data and pairwise distances between sequences, using the single linkage method. - HCtree = seqlinkage(dist,'single',seqs) Phylogenetic tree object with 33 leaves (32 branches)
- Use the optimal leaf-ordering calculation to reorder the leaves in - HCtreesuch that it matches the order of leaves in- NJtreeas closely as possible, without dividing the clades or having crossing branches.- HCtree_reordered = reorder(HCtree,NJtree) Phylogenetic tree object with 33 leaves (32 branches)
- View the reordered phylogenetic tree and the tree used to reorder it. - view(HCtree_reordered) view(NJtree) 
Version History
Introduced in R2007a