2
$\begingroup$

I need help to add information in my phylogenetic tree on each branch.

I have two pieces of information at my disposal:

  1. A phylogenetic tree in newick format :

(mammal:0.14,turtle:0.02,(rayfinfish:0.25,(frog:0.01,salamander:0.01)50:0.12)95:0.09);

  1. A matrix with the edge number and information in the Information column:
Edge    Inf
7        0
6        0
5        2
4        1
3        2
2        2
1        2

Does someone have an idea in order to add these informations by creating a NHX format in python (with ete3 for instance) or with an R package ?

Here is the tree : enter image description here

$\endgroup$
0

2 Answers 2

1
$\begingroup$

Brief answer Firstly this is not a final solution. The simple answer is to use TreeNode.add_feature() in ETE3 which would enable NHX format to be inserted into the tree. There are two possible ways to implement the solution, but I'm not aware of a 'reader'. I'll return to this later under the section 'Question (again)'.

Note I assume that the OP made a typo with 'witg ETE3' and probably means 'with ETE3'?

Interest However as an approach to molecular phylogeny it is interesting theory and has clear application. Not in a simple tree, but when the volume of data overwhelms optical analysis. I am not aware of this being deployed in phylogeny - not done a literature search though, but would readily automate processing of complex trees.

Theory The OP uses the term 'edge' rather than branch, so this is referring to depth first search (DFS) type style calculations. In Phylogenetics there are 'branches' and 'nodes' and these are distinct, in this line of theory, I think, 'edges' can be nodes ... possibly, it is possible an 'edge' connects two nodes, in which an 'edge' is synonymous with a 'branch'.

The difficult I have with the information is that edge 0 is not defined. In Phylogenetics edge 0 would probably be the root. It is possibly the 'missing branch' in the trifurcation at the base of the tree. In this line of theory however 0 may simply be a null category, because an edge is not necessarily the same thing as a branch.

Data structure The information present is paired. thus ... salamander is 7,0 ... frog is 6,0 ... turtle is 4, 2... We can work this out because the data structure is 7,6,5,4,3,2,1 for odd numbers.

7->0, 6->0, 5->2 and so on ...

Moreover, 7 is at the top of the tree whilst, 1 is at the bottom and the 'edge' is an arbitrary designation. Phylogenetics wouldn't label nodes in this format, labelling would usually be with respect to the base of the tree (root). If I look at this from my world-view there's no 0-> ... but 5 the ancestor of 7 and 6 goes to turtles.

Thus far the information isn't the DFS, its presented as the input, for example to calculate DFS, and can be used calculate all sorts of things in this style of graph theory.

Question (again) Back to the question, I am not aware of DFS style theory being used in trees, therefore I would not be aware of an interpreter that would read it. If the OP was just wanting to stash the data into a tree via NHX it could be stacked onto the root lineage. There isn't a root lineage in this tree so I've just added a root at '1:0.01', i.e. a nominal distance to provide the OP with a place to stash the data there. This will read as a tree and the additional 1:0.01 doesn't affect the integrity of the tree - especially in this given phylogeny where the location of the root is not in dispute.

Idea 1

As described above the Edge data gets stored in the 1:0.01 inserted as an additional bracket at the end of the tree.

((mammal:0.14,turtle:0.02,(rayfinfish:0.25,(frog:0.01,salamander:0.01)50:0.12)95:0.09)1:0.01);

Idea 2

This is pairwise data and NXH format could insert the pairwise data for each edge (via TreeNode.add_feature()) for each 'edge' thus salamander would have 7-0 or 7,0 inserted using NHX. That is absolutely technically where the data belongs, but how this read later is more challenging.

If I get chance I'll update the question later with specific NHX output and possibly code to achieve it.


OP upvoted. Its a good question with interesting application.

$\endgroup$
0
$\begingroup$

The treedata book has a section on tree annotations that should work for you.

$\endgroup$

This site is temporarily in read-only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .