-
I have a large number of degree-1 tree sequences (with a single tree), all of which have the same (unlabelled) topology, but where the labelled topologies might differ. E.g.
I want to renumber the sample nodes so that they all conform to a "canonical" labelling. I can get a canonical ordering using @daniel-goldstein 's nice "rank" method. Here's an example:
So I need to find out that e.g. sample node 5 in the first tree should be changed to a 0, and samples 0 and 1 in the first tree should be mapped to 1 and 2 (or 2 and 1, it doesn't matter which). How can I get this mapping? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
I think I can do this by using the order of labels returned by standard traversal though a RankTree. But there's no function that does this. Here's one of my own that I rolled (name updated to
Used as follows (note that the internal node numbers are not the same between tree 1 and tree 3, which is to be expected)
Which gives the correct node renumbering in this case:
But I'm not 100% sure the logic is correct. I wondered if @daniel-goldstein had any thoughts? |
Beta Was this translation helpful? Give feedback.
I think I can do this by using the order of labels returned by standard traversal though a RankTree. But there's no function that does this. Here's one of my own that I rolled (name updated to
leaves
as an equivalent to Tree.leaves() after discussion with @daniel-goldstein ) (edit: this method now PRed in #1292)Used as follows (note that the internal node numbers are not the same between tree 1 and tree 3, which is to be expected)