What is a solution to the dangling nodes error?
Hi @awohns, I am getting an error stating that there are dangling nodes present when running tsdate. I attempted to simplify the tree before preprocessing and running tsdate, but that didnt seem to fix the error. What steps can I take to remove dangling nodes and complete the dating? thanks, @stsmall
Specific error:
python run_tsdate.py chr3.nosingle.trees chr3.nosingle.date200k.trees 200000 --mutation_rate 3e-9 -v --threads 20 --preprocess
Precalculating Likelihoods: 100%|███████████████████████████████████████████████████████████████████████████████████| 159469/159469 [00:41<00:00, 3881.85it/s]
Inside: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████▊| 2994991/2998855 [1:55:34<00:08, 431.92it/s]
Traceback (most recent call last):
File "run_tsdate.py", line 53, in
COMMAND as Ran:
proc_ts = tsdate.preprocess_ts(input_ts, remove_telomeres=False)
priors = tsdate.build_prior_grid(proc_ts, approximate_priors=True)
priors.grid_data[:] = np.ones_like(priors.grid_data[:])
ts = proc_ts.simplify()
dated = tsdate.date(ts, args.Ne,
mutation_rate=args.mutation_rate,
priors=priors, progress=True, ignore_oldest_root=True,
num_threads=args.threads)
Hi Scott, thanks for this.
The fact that the inside pass almost finished running makes me think this error is due to a numerical error in the likelihood function that was fixed by #171. This isn't released yet, but we'll have a bugfix release of tsdate soon with this change.
Can you try running the code again after installing the github version of tsdate like so:
pip install git+https://github.com/tskit-dev/tsdate.git? I see that it took awhile for you to run this, so to save time it might be helpful to simplify your tree sequence down to a smaller version that still fails (i.e. to simplify down to the first 100 samples you could do proc_ts.simplify(np.arange(0, 100))) and then check that you still get this error and that the github installed version fixes it.
Let me know if this fixes the issue! I have other thoughts if not.
I think this is no longer an issue with the default variational_gamma method. Please feel free to reopen if it is still causing issues @stsmall