emmanuelparadis / ape

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

is.binary function with 0 branch lengths #83

Closed Lars-B closed 1 year ago

Lars-B commented 1 year ago

Running

t <- read.newick(text = "(((A:1, B:1):0, C:1):1, D:1);")
is.binary(t)

returns True.

I understand why it would but also there are arguments why it shouldn't, maybe it would be a good idea to explicitly state this in the documentation or add the option to consider branch lengths?

emmanuelparadis commented 1 year ago

You may process your tree with di2multi. I can add a note in the help page. Note also that zero-lengthed branches may have different interpretations in different contexts. For instance, they can lead to infinite likelihoods with substitution models.

Lars-B commented 1 year ago

I added a check where any branch lengths == 0 will return False in my case. Zero or negative branch lengths (same thing happens when using negatives instead of 0) almost certainly lead to trouble later on if not detected, so it may be a good approach to notify the user when reading a tree containing such :)

emmanuelparadis commented 1 year ago

I added this in the help page:

  The test ignores branch lengths. Consider using \code{\link{di2multi}}
  if you want to treat zero-branch lengths as resulting from
  multichotomies.