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

New upper bound for inter1d objects #205

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

anna-parker
Copy link
Contributor

@anna-parker anna-parker commented Aug 29, 2022

After reproducing nextstrain/augur#1032 @corneliusroemer and I found that the issue was during _ml_t_joint. An internal node was suggested time points that were out of bounds of pre-calculated interpolation objects (integral_merger_rate, total_merger_rate). These time points were obtained from msgs_to_multiply and were outside of the x -axis upper bound for the interpolation objects. The upper bound of the interpolation objects integral_merger_rate and total_merger_rate was predefined using ttconf.BIG_NUMBER.

To avoid further out of bounds errors we introduced a new constant value BIGGEST_NUMBER = sys.float_info.max to use as an upper bound for the interpolation objects. We don't think that altering this range will have any numerical impact but please let us know if we have overlooked something @rneher.

Resolves nextstrain/augur#1032

@anna-parker anna-parker requested a review from rneher August 29, 2022 15:01
@rneher
Copy link
Member

rneher commented Sep 7, 2022

@anna-parker we decided that this wasn't actually the problem that needed fixing, right?

@anna-parker
Copy link
Contributor Author

anna-parker commented Sep 7, 2022

Yes - we discovered it was actually due to not enough error handling in the clock_tree module. Due to too little data the calculation of the slope self.clock_model['slope'] was inaccurate (in this case negative), this was using during calc_rate_susceptibility and caused an error. We would need to add error handling for this case. However, you thought it might still make sense to raise this upper bound. But I can close this and make a new PR for that specific case if you no longer think raising the upper bound would be needed.

@michaeljon
Copy link

I have a case where this is 100% reproducible and it may be completely my fault. This is a small sample of sequences within a small time window (jan - may 2020).

The error looks like

6.67    ###TreeTime.run: ITERATION 2 out of 2 iterations
Traceback (most recent call last):
  File "/home/michaeljon/.local/lib/python3.10/site-packages/treetime/treetime.py", line 57, in run
    return self._run(**kwargs)
  File "/home/michaeljon/.local/lib/python3.10/site-packages/treetime/treetime.py", line 332, in _run
    self.calc_rate_susceptibility(params=tt_kwargs)
  File "/home/michaeljon/.local/lib/python3.10/site-packages/treetime/clock_tree.py", line 874, in calc_rate_susceptibility
    self.make_time_tree(**params)
  File "/home/michaeljon/.local/lib/python3.10/site-packages/treetime/clock_tree.py", line 376, in make_time_tree
    self._ml_t_joint()
  File "/home/michaeljon/.local/lib/python3.10/site-packages/treetime/clock_tree.py", line 448, in _ml_t_joint
    msgs_to_multiply.append(self.merger_model.node_contribution(node, time_points))
  File "/home/michaeljon/.local/lib/python3.10/site-packages/treetime/merger_models.py", line 239, in node_contribution
    y = (self.integral_merger_rate(t) - np.log(self.total_merger_rate(t)))*multiplicity
  File "/home/michaeljon/.local/lib/python3.10/site-packages/scipy/interpolate/_polyint.py", line 80, in __call__
    y = self._evaluate(x)
  File "/home/michaeljon/.local/lib/python3.10/site-packages/scipy/interpolate/_interpolate.py", line 752, in _evaluate
    below_bounds, above_bounds = self._check_bounds(x_new)
  File "/home/michaeljon/.local/lib/python3.10/site-packages/scipy/interpolate/_interpolate.py", line 786, in _check_bounds
    raise ValueError("A value ({}) in x_new is above "
ValueError: A value (10034530945.479671) in x_new is above the interpolation range's maximum value (10000000000.0).

ERROR: A value (10034530945.479671) in x_new is above the interpolation range's maximum value (10000000000.0). 
 
ERROR in TreeTime.run: An error occurred which was not properly handled in TreeTime. If this error persists, please let us know by filing a new issue including the original command and the error above at: https://github.com/neherlab/treetime/issues 

ERROR from TreeTime: An error occurred in TreeTime (see above). This may be due to an issue with TreeTime or Augur.
Please report you are calling TreeTime via Augur.

This is the command and the files are attached.

    augur refine \
        --tree ${VIRUS}/${VIRUS}-raw.nwk \
        --alignment ${VIRUS}/${VIRUS}-aligned.fasta \
        --metadata ${VIRUS}-metadata.tsv \
        --output-tree ${VIRUS}/${VIRUS}.nwk \
        --output-node-data ${VIRUS}/${VIRUS}-branch_lengths.json \
        --timetree \
        --coalescent opt \
        --date-confidence \
        --date-inference marginal \
        --clock-filter-iqd 4

With these inputs
hcov-229e.zip

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.

BUG: Refine fails with A value in x_new is above the interpolation range.
3 participants