-
Notifications
You must be signed in to change notification settings - Fork 84
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
Conflict of Optimized Relaxed Clock and Sampled Ancestors #984
Comments
In my local BEAST sources, I have changed |
I have made a commit in Anaphory@9f10bc5 – I can make a pull request, but as it is, I have committed on top of #953 and some other small changes and somehow that PR is still in limbo. |
Running that patched version of BEAST on my data a while longer, I get IndexErrors in
because
ends up with a wrong cached NodeCount somehow. |
This in turn seems to happen because the SA-Operators (I found it in SAWilsonBalding, at least) first assign a new node as the root and only then add the remaining nodes as children to that new root:
I suggest the true solution is to modify the SampledAncestor operators, and I will link this issue from there; but to make it work for all analyses that do not have sampled ancestors and variable number of nodes in the tree by adding nodes during the analysis, it should be enough to change beast2/src/beast/evolution/tree/Tree.java Line 310 in 4d95f00
to
and thus defer the re-calculation fo nodeCount to the next time it is needed. I checked the Tree class, and the only way to sidestep this and run into issues seems to be if that changed line 310 and beast2/src/beast/evolution/tree/Tree.java Lines 1000 to 1006 in 4d95f00
and beast2/src/beast/evolution/tree/Tree.java Lines 251 to 252 in 4d95f00
get called in that order, so it's already much safer than permitting SA operators to mess with a very general assumption (root is always the last node). |
They are both required, but they aren't enough yet: I also ran into
which is somewhat understandable: If for some reason the SAWilsonBalding sets the beast2/src/beast/evolution/tree/Tree.java Lines 803 to 804 in 6859490
with
should fix that problem. However, that whole
|
This should fix one of the symptoms of CompEvol/beast2#984 and also CompEvol#16
I have put a pull request through to the SampledAncestor repository, as well. |
What if |
The issue with the SAWilsonBalding operator is that it constructs a partial tree, set that as the root, and only then glues in the other part of the tree, so getNodeCount will generate the wrong result. The |
So, if the SAWilsonBalding operator would call |
So, if the SAWilsonBalding operator would call `setRoot` with
the correct root at the end of the proposal, that would do the
trick, right?
It should. I have put it, and two other things that I found
useful, into [PR#19 over there](CompEvol/sampled-ancestors#19).
Perhaps adding some comments to `setRootOnly` to that effect
might be useful.
I would (and that's part of my PR) mark `setRootOnly` as
deprecated and an alias of `setRoot`.
I see references to the ‘news’ that sampled ancestor nodes are
tips with branch length zero, and I suspect that many of these
corner cases are due to workarounds from a time when they were not
like generic nodes yet? If that's the case, then getting rid of
these hacks should be fine.
I see how using the `-1` flag works, but it does not feel
particularly robust.
Oh, it really is not. I already ran into it being a problem
somewhere else: In rare cases, a Tree.store() was called
immediately after `setRoot` (I don't know why there was no
likelihood calculation in beetween which would have re-computed
the `nodeCount`, but it happened) and that creates an array with
negative length in [the old line
800](Anaphory@8526c99)
of that method. And I'm sure there are other issues.
Getting rid of `setRootOnly` as much as possible and
re-calculating `nodeCount` inside `setRoot` sounds like the much
better solution.
|
Like, as I just noticed, resuming. 😞 Which is really important. So I'll undo that change and end with |
A sudden IndexError in an analysis had me stumped for some time. I have now figured out why it happens, but not how to fix it.
Symptoms:
For the analysis that permits sampled ancestors, the Relaxed Clock dies with an index error somewhere in the branch-rates-aware narrow exchange (MetaNER) operator.
What happens is the following:
For a moment I thought I might have started with a sampled ancestor and then a Jump added an internal node which would put the total number of nodes, and therefore branches, and therefore rates needed, up by one without adjusting the dimension of the rates parameter. But that's not the case, sampled ancestors are not degree-2 nodes, but tips with a branch length of 0.
Investigating closer, I was greatly confused, because I know that node D in the MetaNER is a child, and that node 98 is always the root. Except:
beast2/src/beast/evolution/tree/Tree.java
Lines 322 to 333 in 4d95f00
This method messes with that invariant, and makes Sampled Ancestors and Optimized Relaxed Clocks incompatible.
Why is it there? Why can Sampled Ancestors not just use the same
setRoot()
as everyone else?Is there a way to get SA to work with an ORC (I'm willing to modify and test code and supply patches, as you know), or am I stuck with the generic Relaxed Clock with its convergence issues?
Should I cross-link this issue to the SA and ORC repositories?
The text was updated successfully, but these errors were encountered: