tsdate icon indicating copy to clipboard operation
tsdate copied to clipboard

What is a solution to the dangling nodes error?

Open stsmall opened this issue 4 years ago • 1 comments

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 main() File "run_tsdate.py", line 48, in main num_threads=args.threads) File "tsdate/date.py", line 1000, in date **kwargs File "tsdate/date.py", line 1095, in get_dates dynamic_prog.inside_pass(cache_inside=False) File "tsdate/date.py", line 676, in inside_pass "The input tree sequence includes " ValueError: The input tree sequence includes dangling nodes: please simplify it

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)

stsmall avatar May 26 '21 23:05 stsmall

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.

awohns avatar May 27 '21 19:05 awohns

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

hyanwong avatar Mar 29 '25 21:03 hyanwong