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

Fix branch length annotation #908

Merged
merged 1 commit into from
Apr 28, 2022
Merged

Conversation

huddlej
Copy link
Contributor

@huddlej huddlej commented Apr 27, 2022

Description of proposed changes

Sets branch length to the difference in divergence between each node and its parent instead of setting the cumulative branch length from the root of the tree. Auspice JSONs store the cumulative branch length for easier plotting in Auspice, but when we import the JSON into Python as a tree, the branch length should not be cumulative. Since this cumulative branch length is useful on its own and also required for calculating the actual branch length (in the current recursive implementation of json_to_tree, at least), this commit adds a cumulative_branch_length attribute to each node of the tree produced by json_to_tree and passes this value as a new optional argument to recursive calls.

We should really reimplement this function as a non-recursive function, though. See the cartography script for annotating Auspice JSONs, for an example of this kind of non-cursive implementation.

Related issue(s)

Fixes #714

Testing

  • Updated doctests to include expected values for cumulative and standard branch lengths
  • Tested by CI

Sets branch length to the difference in divergence between each node and
its parent instead of setting the cumulative branch length from the root
of the tree. Auspice JSONs store the cumulative branch length for easier
plotting in Auspice, but when we import the JSON into Python as a tree,
the branch length should not be cumulative. Since this cumulative branch
length is useful on its own and also required for calculating the actual
branch length (in the current recursive implementation of
`json_to_tree`, at least), this commit adds a `cumulative_branch_length`
attribute to each node of the tree produced by `json_to_tree` and passes
this value as a new optional argument to recursive calls.

We should really reimplement this function as a non-recursive function,
though. See the cartography script for annotating Auspice JSONs [1], for
an example of this kind of non-cursive implementation.

Fixes #714

[1] https://github.com/blab/cartography/blob/master/notebooks/scripts/annotate_tree.py
@codecov
Copy link

codecov bot commented Apr 27, 2022

Codecov Report

Merging #908 (83dd060) into master (4b71e7d) will increase coverage by 0.03%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #908      +/-   ##
==========================================
+ Coverage   34.63%   34.66%   +0.03%     
==========================================
  Files          42       42              
  Lines        6006     6009       +3     
  Branches     1538     1539       +1     
==========================================
+ Hits         2080     2083       +3     
  Misses       3853     3853              
  Partials       73       73              
Impacted Files Coverage Δ
augur/utils.py 44.31% <100.00%> (+0.47%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4b71e7d...83dd060. Read the comment docs.

@huddlej huddlej requested a review from rneher April 27, 2022 19:12
@huddlej huddlej force-pushed the fix-branch-length-annotation branch from 483336d to 83dd060 Compare April 28, 2022 21:39
@huddlej huddlej merged commit e918e5c into master Apr 28, 2022
@huddlej huddlej deleted the fix-branch-length-annotation branch April 28, 2022 21:58
@huddlej huddlej added this to the Next release X.X.X milestone Apr 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

incorrect json -> Bio.Phylo conversion
2 participants