Closed harryrichman closed 8 months ago
I'm closing this now that we merged https://github.com/etetoolkit/ete/pull/714 and added this functionality to ete4 too with commit https://github.com/etetoolkit/ete/commit/1fff0621ae332d40e01d034c4de69370675e62d8 . Thanks @harryrichman !
There are many situations in phylogenetics research where it would be useful to have a quick and easy way to generate a uniformly random bifurcating tree. There does not seem to be a way to do so using currently implemented methods in
ete
.To generate a random tree on
n
leaves, the current documentation suggests runningHowever, the resulting tree is not uniformly random among all possible rooted, bifurcating trees on
n
leaves. For example, there are 105 rooted, bifurcating trees on 5 leaves, but thepopulate.()
method only generates 4 of them. (It seems that the documentation for thepopulate()
method is not so clear about explaining what sort of tree is generated, from the user's perspective.)As another approach, to generate a random tree on
n
leaves using existing methods, one could constructstar_tree
as a multifurcating tree withn
children and then runHowever, this approach is not practical for moderately large
n
because the number of bifurcating trees grows super-exponentially, as warned in the documentation for this method.