Question: Count number of monophyletic groups within pylogeny
0
gravatar for Darill
7 months ago by
Darill30
Darill30 wrote:

Hello, I wondered if it whas possible within a newick tree to count the number of monophyletic groups even if intruders are splitting this group.

Here is an exemple

Let say you have the following three :

((A,A),((B,B),((A,A),A)))); here in that case A are species belonging to the Genus A for instance and B species from the Genus B.

And here if I use your package I should have a result that shows a monophyletic group for species B but not for species A because there is the two B species between them. But what I wanted to know if there were a way to count the number of groups where species A are grouped together, here a such result should be:

Number of groupes shared by A species = 2 Number of groupes shared by B species= 1 Is there any option in order to do that?

Thank you for your help :)

monophyletic phylogeny • 307 views
ADD COMMENTlink modified 7 months ago by Joe15k • written 7 months ago by Darill30
3
gravatar for Joe
7 months ago by
Joe15k
United Kingdom
Joe15k wrote:

Here's a fairly simple 'brute force' approach inspired by my previous answer here: Detect trees (newick) with specific topology

#!/bin/bash

for g in A B ; do
   count=$(grep -o "(\($g[,\)$g]*$g\))" $1 | tee /dev/tty | wc -l)
   echo "${g} monophyletic groups = $count"
done

Change A B in the loop declaration to suit.

This seems to work on your input data, as I get:

$ bash monophyly.sh monophyly.tree
(A,A)
(A,A),A)
A monophyletic groups = 2
(B,B)
B monophyletic groups = 1

If you dont want to see the matches themselves, but just the count, delete the tee /dev/tty/ | part.

I haven't tested it on anything more complicated (and this won't work (in it's current form) if you have node support values or branch lengths, but could be made to).

ADD COMMENTlink modified 7 months ago • written 7 months ago by Joe15k
1

Thank you ! it works like a charme :)

ADD REPLYlink written 7 months ago by Darill30
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: 775 users visited in the last hour