neherlab / treetime

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

`AttributeError: 'function' object has no attribute 'x'` (maybe stochastic) #170

Closed corneliusroemer closed 2 years ago

corneliusroemer commented 2 years ago

Sometimes, when running augur refine as part of https://github.com/corneliusroemer/ncov-simplest I get the following error. Weirdly, without changing any of the sequences and rerunning, the error often goes away. Rerunning means rerunning iqTree, so it could be that this error only occurs for certain .nwk input trees.

72.11   ###TreeTime.run: FINAL ROUND - confidence estimation via marginal
        reconstruction
THIS SHOULDN'T BE CALLED ON A DELTA FUNCTION
Traceback (most recent call last):
  File "/usr/local/Caskroom/mambaforge/base/envs/nextstrain/bin/augur", line 10, in <module>
    sys.exit(main())
  File "/usr/local/Caskroom/mambaforge/base/envs/nextstrain/lib/python3.8/site-packages/augur/__main__.py", line 10, in main
    return augur.run( argv[1:] )
  File "/usr/local/Caskroom/mambaforge/base/envs/nextstrain/lib/python3.8/site-packages/augur/__init__.py", line 75, in run
    return args.__command__.run(args)
  File "/usr/local/Caskroom/mambaforge/base/envs/nextstrain/lib/python3.8/site-packages/augur/refine.py", line 206, in run
    tt = refine(tree=T, aln=aln, ref=ref, dates=dates, confidence=args.date_confidence,
  File "/usr/local/Caskroom/mambaforge/base/envs/nextstrain/lib/python3.8/site-packages/augur/refine.py", line 67, in refine
    tt.run(infer_gtr=infer_gtr, root=reroot, Tc=Tc, time_marginal=marginal,
  File "/usr/local/Caskroom/mambaforge/base/envs/nextstrain/lib/python3.8/site-packages/treetime/treetime.py", line 271, in run
    self.make_time_tree(**tt_kwargs)
  File "/usr/local/Caskroom/mambaforge/base/envs/nextstrain/lib/python3.8/site-packages/treetime/clock_tree.py", line 343, in make_time_tree
    self._ml_t_marginal(assign_dates = time_marginal=="assign")
  File "/usr/local/Caskroom/mambaforge/base/envs/nextstrain/lib/python3.8/site-packages/treetime/clock_tree.py", line 558, in _ml_t_marginal
    node.subtree_distribution._adjust_grid(rel_tol=self.rel_tol_prune)
  File "/usr/local/Caskroom/mambaforge/base/envs/nextstrain/lib/python3.8/site-packages/treetime/distribution.py", line 269, in _adjust_grid
    self._peak_idx = self.__call__(self._func.x).argmin()
AttributeError: 'function' object has no attribute 'x'
corneliusroemer commented 2 years ago

Exact command used:

augur refine  --tree builds/21K/tree_raw.nwk   --root MN908947  \
  --alignment builds/21K/masked.fasta    --divergence-units mutations  \
   --output-tree builds/21K/tree.nwk    --metadata data/metadata.tsv   \
   --output-node-data builds/21K/branch_lengths.json    --timetree   \
  --keep-polytomies     --clock-rate 0.0006    --clock-std-dev 0.003 \   --coalescent opt \
   --date-inference marginal             --date-confidence             --no-covariance
rneher commented 2 years ago

hopefully fixed in 0.9.0