Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add UPGMA, Neighbor-Joining, and Robinson-Foulds metric #470

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

RagnarGrootKoerkamp
Copy link
Contributor

This depends on #468 and #469.

It adds implementations of the UPGMA and Neighbor-Joining phylogeny reconstruction algorithms, and of the Robinson-Foulds metric used as a distance between two trees.

This adds the `to_string`, `to_file`, and `write` methods to
`newick.rs`, mirroring the existing `from_string`, `from_file` and
`read` methods.

A slight annoyance is that petgraph iterates outgoing edges in reverse
order of adding them. To keep input and output consistent, I manually
reverse that order back to the natural order in which they were added.
Another option would be to actually add them in the reverse order, but
that would change the representation which may not be desirable.

I'm also changing the `"N/A"` value for nodes without a name to just the
empty string as this heavily pollutes the `to_string` representation,
and `""` is more naturaly IMO.

Also fixed one unused variable warning.
This mirrors `newick.rs` and adds string/file IO for the
`bio_types::distancematrix::DistanceMatrix` type, in the Phylip distance
matrix format.

It supports square and (upper/lower) triangular matrices. Triangular
matrices must not contain the diagonal.

Also fix a broken doctest.
Instead, loop over all vertices to find it, and return an error if the
root is not unique.
This adds implementations of phylogeny reconstruction algorithms and the
Robinson-Foulds metric to compute distances between two phylogenetic trees.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant