# Add segregating sites to branches of a tree

I'm trying to figure out how I would plot a tree with number of segregating sites on display on the branches

I'm using acctran from phangorn to plot a parsimony tree (using phydat object from fasta files)

I have been trying to use seg.sites from the ape package to somehow merge these objects together but there has to be some easy way to plot a tree with the information that it was made from

• The question is fine. Are you fixed on using R or would you use external packages to do this analysis? Do you use Macs?
– M__
Sep 22 '20 at 14:23
• Fixed on Linux, checked out Beast but had problems installing. Semifixed on using R but open for suggestions (maybe py(thon)curious)
– AWE
Sep 22 '20 at 14:29
• Okay thanks ... really this is an R coding issue. Biopython is a whole new script.
– M__
Sep 22 '20 at 14:32
• In the end I will say "whatever works", but I feel like I'm looking for my glasses that are on my nose
– AWE
Sep 22 '20 at 14:38

The segregating sites in parsimony are formally called steps. Any number of programs will do this but I don't really use R, particularly for phylogeny, You can of course simply look at the raw treefile, all the data is there (described in the last paragraph). If look at the options for genetic distance, in parsimony this will be an integer and again the technical name is steps and is the segreating sites you want.

Python's ETE3 package will work (but you'd need to pipe it through Biopython), as well as specific standalone packages Figtree, the steps or 'genetic distance' on the branches on the branches option is in the check box. The heavy weight program for tracking step associated phylogeny using parsimony is Mesquite and its famous grandparent is called MacClade.

I suspect its a nomenclature thing, the options probably talk about genetic distance because few people do parsimony phylogeny now. Thats the option you want and you will know because it will be >>1, whilst distance and model-based methods will be between 0 to 1. From a tree viewing it doesn't matter if the genetic distance is 0 to 1 or 1 and beyond because its all proportional. Its just an option thing you are missing. Thus if there is an option, e.g. to include bootstrap support on the tree, there'll be an option for genetic distance.

Just make sure you don't confuse the number of steps per branch with a consensus statistic, because there're completely different but might give similar looking outputs. Again its easily checked against the raw treefile because the "steps" will be immediately adajacent to the taxa name for the "twigs" (terminal branches) in the tree.

• I went away for some days. You may be right, but now I'm having problems using both ETE and Mesquite. I will try some more and hopefully figure something out. Manuals and cookbooks look promising though.
– AWE
Sep 28 '20 at 0:05
• It is really easy to do what you want to do. ETE3 needs Biopython to import the tree. I could post code but you should be able to do this via R easily. As a last resort simply export your R tree and open it in Figtree and just click the option to 'view branch lengths'. I presume you want to automate the process so at a guess 'ape' will have the option. Mesquite is for identifying each individual alignment position that contributes to a given branch, my understanding is you just want number of sites not alignment positions.
– M__
Sep 28 '20 at 1:05
• Great. ETE had bugs, Mesquite did not like my xml format. Figtree smiled, patted me on my back, took my nexus file from R and showed me the branch length.
– AWE
Sep 29 '20 at 10:06
• Great! I am very happy for you! Congratulations to FigTree. ETE3 is just complicated, I like it because I'm use to it (as a Python coder I'm a bit protective). I do use ETE3 to print bootstraps, so it should just another option therein, but admittedly unless your performing a ''big data' operation its not worth it.
– M__
Sep 29 '20 at 15:27