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

Root lengths in the unrooted layout? #374

Closed
fedarko opened this issue Sep 8, 2020 · 2 comments · Fixed by #398
Closed

Root lengths in the unrooted layout? #374

fedarko opened this issue Sep 8, 2020 · 2 comments · Fixed by #398
Labels

Comments

@fedarko
Copy link
Collaborator

fedarko commented Sep 8, 2020

Following up on a point raised in #363.

There is some code in the unrooted layout that accesses the length of the root node:

var n = tree.postorderselect(tree.size);
var x1 = 0,
y1 = 0,
a = 0,
da = angle;
// NOTE: x2 will always be 0, since sin(0) = 0.
var rootLen = ignoreLengths ? 1 : tree.length(n);
var x2 = x1 + rootLen * Math.sin(a);
var y2 = y1 + rootLen * Math.cos(a);

As far as I can tell, the root node's length is actually used in the layout: if you replace tree.length(n) with 1000 on this line for the moving pictures dataset, the unrooted layout looks like:

rooot

We currently do not do any sort of validation (in validate_tree()) that the root node's length is valid (e.g. the length is specified and is a nonnegative number). Even in the moving pictures dataset, the root length is unspecified, so it looks like it defaults to 0:

image

I think it would be best to just ignore the root branch length in the unrooted layout (and maybe just set it to 0 or something), but I am not sure what you all think.

One of the reasons for bringing this up is that as of last week Empress' UI says the following:

image

...so we should try to be precise about when / if the root length is used :)

@wasade
Copy link
Member

wasade commented Sep 14, 2020

The edge associated with a node in the BP or TreeNode model is from that node to its parent. The root by definition does not have a parent. If a length value is associated with the root, it should be ignored.

@fedarko
Copy link
Collaborator Author

fedarko commented Sep 14, 2020

Cool, thanks. It sounds like just setting the root length to 0 in the python code, and adjusting the unrooted layout to always keep the root length as 0 (even if "ignore lengths" is set to true), would be the way to go here.

fedarko added a commit to fedarko/empress that referenced this issue Sep 27, 2020
ElDeveloper pushed a commit that referenced this issue Sep 30, 2020
* ENH: Show node lengths in selection menu #179

Also computes min/max/avg node lengths; gotta show that somewhere...

* DOC: note abt root len

* STY: prettify

* ENH: show tree stats! Closes #179.

* STY: prettify

* DOC: clarify & upd8 bptree stat code

* TST: unbreak tests

* ENH: hide the root node's "length" in the menu

since it's not even validated

* DOC: buff disclaimer

* DOC: separate stats disclaimers

splits up ugly paragraph, and allows us to selectively hide part
of it if tree-plot done

* DOC: simplify tree stats header txt

* BUG: Ignore root len in unrooted layout: fix #374

* TST: hide stats table in test html

* TST/BUG/MNT: Make getLengthStats own func&fix/test

(Found a bug where the min was getting set to 0 even if real min
was > 0; due to setting min to 0 by default. Now it's +inf and max
starts as -inf, so we should be solid

* STY/TST: test error len stats case; prettify

* TST: test Empress.getNodeLength

* TST/MNT: mv code to spanel;refact/tst getTreeStats

* DOC: clarify ambiguous language in ignore len secn

* MNT: rename a few things from tree props->settings

* MNT: rm extraneous unrooted layout op

* ENH: round node length stats to 4 decimal pts

addresses @ElDeveloper comment

* PERF: only compute tree stats when requested

addresses @ElDeveloper comment

* PERF: only compute tree stats once

* STY: tidy some old html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants