neherlab / treetime

Maximum likelihood inference of time stamped phylogenies and ancestral reconstruction
MIT License
222 stars 55 forks source link

Underflow issue with large polytomies and state space #39

Closed evogytis closed 6 years ago

evogytis commented 6 years ago

When working on a tree with a lot of polytomies and large number of states in real space the marginal subtree likelihood profile (node.marginal_subtree_LH) underflows mid-loop. Perhaps computations should be in log space to begin with or the tree resolved into strict bifurcations with 0.0 branch lengths prior to running _ml_anc_marginal?

https://github.com/neherlab/treetime/blob/0d3806be12e2fb0e751aaa91767e78897ae01b5e/treetime/treeanc.py#L1099

rneher commented 6 years ago

Thanks, Gytis. Yes, this could be done in logs. The different messages come in linear space after matrix multiplications, but then we could add the logs rather than multiply. Shouldn't affect anything else, I'll change this.

rneher commented 6 years ago

just pushed a branch log_messages that should fix this, commit fbb5d65. not extensively tested though.