Question: Prune Trees To Overlapping Taxa
1
gravatar for rezam
3.8 years ago by
rezam20
US
rezam20 wrote:

I have some phylogenetic trees with partial overlapping taxa. I would like to prune these trees, say 2 of them, to their overlapping taxa in order to be able to compare them. Is there any built in function for this in R, Python, etc (or I need to invent the wheel)?

Thanks!

 

tree prunning phylogenetic • 1.2k views
ADD COMMENTlink modified 3.8 years ago by jhc2.8k • written 3.8 years ago by rezam20
2
gravatar for jhc
3.8 years ago by
jhc2.8k
Spain
jhc2.8k wrote:

A Python approach using ETE:

from ete3 import Tree
newick1 = "((A, B, (C, D)), (E, F));"
newick2 = "((A, B, (C, G)), (E, T));"
t1 = Tree(newick1)
t2 = Tree(newick2)
common_leaves = set(t1.get_leaf_names()) &  set(t2.get_leaf_names())
t1.prune(common_leaves)
t2.prune(common_leaves)
t1.write()
Out[16]: '((A:1,B:1,C:1)1:1,E:1);'
t2.write()
Out[17]: '((A:1,B:1,C:1)1:1,E:1);'
ADD COMMENTlink modified 14 months ago by RamRS25k • written 3.8 years ago by jhc2.8k
1
gravatar for Brice Sarver
3.8 years ago by
Brice Sarver3.2k
United States
Brice Sarver3.2k wrote:

In R: match vectors of names between the two trees, then use drop.tip() inape.

ADD COMMENTlink modified 14 months ago by RamRS25k • written 3.8 years ago by Brice Sarver3.2k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 2256 users visited in the last hour