This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Extract Sub_Tree From Big Phylogeny

Hi There,

Does anyone know how to extract a subtree from a big phylogeny? Also, is it possible to keep the branch length information when doing extraction?

Many thanks in advance.

Lhl

phylogeny

3 answers

You could use the python package ETE for this. They have an example for taking a phylogentic tree, and pruning parts of it off here: http://packages.python.org/ete2/tutorial/tutorial_trees.html#pruning-trees. I think the input is a newick style tree, and I am pretty sure ETE will not change the branch lengths that you put on your tree when you prune parts of it away.

Many thanks for your suggestion John.

By the way, if i want to sample species across clades. Do you think ETE would automatically adjust branch lengths?

I will explore ETE in more detail.

Cheers

Lhl

ETE (v2.1) will delete branches when pruning. Only branch lengths of the kept nodes will be maintained (never changed). The currently development version of ETE, includes a new option to preserve branch length information by summing up the lengths of all deleted nodes. This is: distances between nodes will be the same in the original and the pruned tree, which means that some of the remaining branches will be changed to account for the cumulative length that has been removed.

See prune method here: https://github.com/jhcepas/ete/blob/master/ete_dev/coretype/tree.py

sounds this is the functionality i need.

Thanks a lot.

Cheers

Huanle

If you want a visual way of pruning a subtree, I would recommend Archaeopteryx, it is easy to cut and paste subtrees and prune subtrees, even large trees. I am pretty sure it preserves the branch lengths.

Use the TreeTools package in R. Example code:

tree <- BalancedTree(8)
plot(tree)
tip <- c('t1','t5','t7','t8')
subtree <- KeepTip(tree, tip, preorder = TRUE)
plot(subtree)

Log in to answer this question.