Path Sampling divide by zero error - workaround

100 views
Skip to first unread message

Brian Dorsey

unread,
Jul 11, 2024, 8:25:57 PM7/11/24
to beast-users
Hi all,

Beast 2.7.7
snapper 1.1.4
Mac Studio M1 Ultra

I'm trying to set up a snapper path sampling analysis but I am getting an error. When executing the path sampling xml file, program quits with the dividing by zero error pasted below. I think I've traced it to this line in the beast.xml files created in each step folder:

 <logger id="Logger" spec="Logger" fileName="likelihood.log" logEvery="0">
            <log idref="likelihood"/>
        </logger>

If I modify this element to logEvery="10" and then run the run0.sh script in the folder containing the step folders, the error is gone. So I guess the Path Sampler module is writing the likelihood log element incorrectly. I can edit each beast.xml file and go from there but maybe there is a better fix. In any case, I thought folks would want to know about this in case they get the same error. Happy to provide more info if it would be helpful.

Thanks,
Brian D.


Start likelihood: -3519.4399537669206
Writing file alignment.1720737038787.log
         Sample      posterior ESS(posterior)     likelihood          prior
Writing file alignment.1720737038787.trees
Writing file likelihood.log
              0     -1815.6024              N     -1818.7203         3.1178 --
java.lang.ArithmeticException: / by zero
at beast.base.inference.Logger.log(Unknown Source)
at beast.base.inference.MCMC.log(Unknown Source)
at modelselection.inference.PathSamplingStep.doLoop(Unknown Source)
at modelselection.inference.PathSamplingStep.run(Unknown Source)
at beastfx.app.beast.BeastMCMC.run(Unknown Source)
at beastfx.app.beast.BeastMain.main(Unknown Source)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
at beast.pkgmgmt.launcher.BeastLauncher.run(Unknown Source)
at beast.pkgmgmt.launcher.BeastLauncher.main(Unknown Source)
java.io.FileNotFoundException: /Volumes/CatDisk/Dioon_RADseq_analysis/Dtom/phylo/analyses/snapper/bfd/example/step0/beast.xml.state (No such file or directory)
at java.base/java.io.FileInputStream.open0(Native Method)
at java.base/java.io.FileInputStream.open(Unknown Source)
at java.base/java.io.FileInputStream.<init>(Unknown Source)
at modelselection.inference.PathSampler.copyStateFile(Unknown Source)
at modelselection.inference.PathSampler.doRuns(Unknown Source)
at modelselection.inference.PathSampler.run(Unknown Source)
at beastfx.app.beast.BeastMCMC.run(Unknown Source)
at beastfx.app.beast.BeastMain.main(Unknown Source)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
at beast.pkgmgmt.launcher.BeastLauncher.run(Unknown Source)
at beast.pkgmgmt.launcher.BeastLauncher.main(Unknown Source)

komkiew pinpimai

unread,
Jul 31, 2024, 3:37:43 PM7/31/24
to beast-users
I have the same problem

higg...@gmail.com

unread,
Jul 31, 2024, 3:45:44 PM7/31/24
to beast-users
Hi Brian,

Just to explain why this is happening: the likelihood log files are expected to contain 1000 MCMC samples. The log frequency is calculated as the chain length divided by 1000, so if you set the chain length shorter than that it is rounded down to zero.
Running the MCMC for shorter than a 1000 samples for each steps potentially does not leave enough time to get a good sample, so can result in inaccurate marginal likelihood estimates.

By the way, if you are doing path sampling to do a species delimitation  you might want to consider the SpeeDemon method (https://github.com/rbouckaert/speedemon/blob/master/README.md), which is much faster and only requires one MCMC run.

Cheers, Remco
Reply all
Reply to author
Forward
0 new messages