Question: Get closest taxa of a target species in a phylogeny
gravatar for mchimich
11 weeks ago by
United States
mchimich20 wrote:

Dear users, Since many days I'm struggling with a technical problem for which I was not able to find any clear answer given that I'm not familiar with the automatic manipulation of phylogenetic trees. let's consider the following phylogeny tree :

enter image description here

It there any automatic way (R package or any other langue) to get the closest taxa names of a particular target taxa. For example the closest species of t3 will be : t14 and t13. for t7 it will be : t12,t17,t18 and for t10 this will be t11. It is also possible to add a threshold using bootstrap values ?

Thank you so much for your help !


phylogeny • 155 views
ADD COMMENTlink modified 11 weeks ago by a.zielezinski9.6k • written 11 weeks ago by mchimich20
gravatar for a.zielezinski
11 weeks ago by
a.zielezinski9.6k wrote:

In Python you can use ete3 package.

UPDATED: The following code finds a sister group to your query taxon and prints all leaves of that sister group (if bootstrap value is equal or greater than threshold)

import ete3

YOUR_TREE = '((raccoon:19.19959,bear:6.80041)50:0.84600,((sea_lion:11.99700, seal:12.00300)100:7.52973,((monkey:100.85930,cat:47.14069)80:20.59201, weasel:18.87953)75:2.09460)50:3.87382,dog:25.46154);'
YOUR_QUERY = 'weasel'

t = ete3.Tree(YOUR_TREE)
node = t.search_nodes(name=YOUR_QUERY)[0]

for sister_group in node.get_sisters():
    if >= MIN_BOOTSTRAP:
        for leaf in sister_group.get_leaves():

You will get the names of leaves that are present in the sister group (cat and monkey) to weasel. Of note, the tree is unrooted (so there is no outgroup here). If you look at the QUERY_TREE you can see that weasel is next to monkey and cat: [..] ((monkey:100.85930,cat:47.14069)80:20.59201, weasel:18.87953) [..].

ADD COMMENTlink modified 11 weeks ago • written 11 weeks ago by a.zielezinski9.6k

Dear a.zielezinski , thanks for your answer. I tried your code and it works ! however the closest leaves to weasel in your example is cat and monkey. However what I wanted to get based on your example is the sister clade that contain dog, bear, raccoon, seal and sea_lion not the outgroups (cat and monkey) enter image description here

Do you know if it is possible to consider sister group only if the bootstrap value is bigger than a threshold

Thanks again for your help !

ADD REPLYlink modified 11 weeks ago • written 11 weeks ago by mchimich20

Hi mchimich, I just updated my answer. Hope it helps.

ADD REPLYlink written 11 weeks ago by a.zielezinski9.6k

Thank you so much !! now everything is working perfectly ! appreciated

ADD REPLYlink written 11 weeks ago by mchimich20
Please log in to add an answer.


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