This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Count number of monophyletic groups within pylogeny

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 :)

phylogeny monophyletic

1 answer

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).

Thank you ! it works like a charme :)

Log in to answer this question.