emmanuelparadis / ape

analysis of phylogenetics and evolution
http://ape-package.ird.fr/
GNU General Public License v2.0
52 stars 11 forks source link

Handle zero-leaf trees #93

Closed ms609 closed 1 year ago

ms609 commented 1 year ago

Some operations can produce zero-leaf trees: for example, reducing a pair of trees by retaining only the leaves they hold in common.

Such zero-leaf trees throw errors in certain ape functions, where it would be appropriate to silently return the zero-leaf tree that was input.

I have proposed modifications to the two functions that have been causing issues where they are called in downstream functions in TreeTools and TreeDist – though there may be mileage in handling this case safely in other functions too.

ms609 commented 1 year ago

For testing purposes, here is the zero-length tree object that brought my attention to the issue:

noLeafTree <- structure(list(edge = structure(numeric(0), dim = c(0L, 2L)), 
    tip.label = character(0), Nnode = 0), class = "phylo")
emmanuelparadis commented 1 year ago

This is great! I'm opening an issue to follow-up on this. Many thanks.