neherlab / treetime

Maximum likelihood inference of time stamped phylogenies and ancestral reconstruction
MIT License
229 stars 56 forks source link

TypeError: 'interp1d' object is not iterable #122

Closed xinkwu closed 4 years ago

xinkwu commented 4 years ago

Hi, thank you very much for providing such a useful tool.

Here are two problems I encountered when running treetime:

  1. The following error occurs when I run treetime using a tree built by Raxml. code show as below:

    treetime --tree ./raxml_test.nwk \
    --aln full_genome.fasta \
    --dates metainfo.csv \
    --clock-filter 4 \
    --keep-root \
    --covariation \
    --confidence \
    --max-iter 2 \
    --coalescent skyline \
    --branch-length-mode joint

    The error is reported as follows:

    Traceback (most recent call last):
    File "/software/anaconda3/bin/treetime", line 12, in <module>
    return_code = params.func(params)
    File "/software/anaconda3/lib/python3.6/site-packages/treetime/argument_parser.py", line 213, in toplevel
    timetree(params)
    File "/software/anaconda3/lib/python3.6/site-packages/treetime/wrappers.py", line 591, in timetree
    print_save_plot_skyline(myTree, plot=basename+'skyline.pdf', save=basename+'skyline.tsv', screen=True)
    File "/software/anaconda3/lib/python3.6/site-packages/treetime/wrappers.py", line 244, in print_save_plot_skyline
    skyline, conf = tt.merger_model.skyline_inferred(gen=50, confidence=n_std)
    TypeError: 'interp1d' object is not iterable

    Is it because I provide a unrooted tree then cause a error? Because when I change the parameter (--reroot least-squares) it works very well. By the way, I wonder if I provide a unrooted tree and I choose the keep-root mode, how will treetime determine the root node?

  2. When I want to run treetime with an tree generated using a large region and a MSA file of a gene in this region, and select the least-squares option, I encountered the following error.

    4442.09 ###TreeTime.run: ITERATION 1 out of 2 iterations
    THIS SHOULDN'T BE CALLED ON A DELTA FUNCTION
    Traceback (most recent call last):
    File "/software/anaconda3/bin/treetime", line 12, in <module>
    return_code = params.func(params)
    File "/software/anaconda3/lib/python3.6/site-packages/treetime/argument_parser.py", line 213, in toplevel
    timetree(params)
    File "/software/anaconda3/lib/python3.6/site-packages/treetime/wrappers.py", line 566, in timetree
    use_covariation = params.covariation, n_points=params.n_skyline)
    File "/software/anaconda3/lib/python3.6/site-packages/treetime/treetime.py", line 222, in run
    self.make_time_tree(**tt_kwargs)
    File "/software/anaconda3/lib/python3.6/site-packages/treetime/clock_tree.py", line 345, in make_time_tree
    self._ml_t_joint()
    File "/software/anaconda3/lib/python3.6/site-packages/treetime/clock_tree.py", line 412, in _ml_t_joint
    subtree_distribution._adjust_grid(rel_tol=self.rel_tol_prune)
    File "/software/anaconda3/lib/python3.6/site-packages/treetime/distribution.py", line 268, in _adjust_grid
    self._peak_idx = self.__call__(self._func.x).argmin()
    AttributeError: 'function' object has no attribute 'x'

    When running treetime, is it necessary to require multiple sequence alignment files to match the tree exactly (the evolutionary tree is generated by this multiple sequence alignment)?

Thanks, kai

rneher commented 4 years ago

Your first issue should have been fixed in: https://github.com/neherlab/treetime/commit/9e2491ff559997bba58249acfe0e6c1fce1ba460 but this isn't released yet. It has to do with skyline optimization failing when the tree is too weird (like rooted the wrong way).

your second error is more mysterious. Am I correct that you are running this on a tree generated with a long sequence but only provide a short fragment of that sequence as alignment? This should in principle work, but you should run with the flag --branch-length-mode input. (The error shouldn't happen either way though). I'll look into it.