BEASTv2.1.1 fails to initialise with discrete trait added

928 views
Skip to first unread message

Leendert Cloete

unread,
Feb 18, 2014, 6:40:38 AM2/18/14
to beast...@googlegroups.com
Hi,

I recently decided to give BEASTv2.1.1 a try (coming from v1.8.0), since the ability of continuing an interrupted run would make my life increasingly more enjoyable. After my initial shock to the change in the BEAUti interface, I eventually got BEAST running. My analysis of the Divergence time and Rate estimations completed without any errors and the results were appropriate and as expected.

AND here is where my problem starts... When I added a discrete trait (e.g. location) to the same xml (by using BEAUti) that previously ran without any errors, I suddenly got this message:



Start likelihood: -Infinity after 11 initialisation attempts
P(posterior) = -Infinity (was NaN)
    P(prior) = -Infinity (was NaN)
        P(CoalescentConstant.t:H5N1) = -46.08974243073076 (was NaN)
        P(GammaShapePrior.s:H5N1) = -1.0 (was NaN)
        P(KappaPrior.s:H5N1) = -1.8653600339742873 (was NaN)
        P(nonZeroRatePrior.s:location) = -Infinity (was NaN)
        P(PopSizePrior.t:H5N1) = 2.4079456086518722 (was NaN)
        P(relativeGeoRatesPrior.s:location) = -9.999999999999998 (was NaN)
        P(geoclockPrior.c:location) = -13.83017328132567 (was NaN)
    P(likelihood) = NaN (was NaN)
        P(treeLikelihood.H5N1) = NaN (was NaN)
        P(traitedtreeLikelihood.location) = NaN (was NaN)
java.lang.Exception: Could not find a proper state to initialise. Perhaps try another seed.
    at beast.core.MCMC.run(Unknown Source)
    at beast.app.BeastMCMC.run(Unknown Source)
    at beast.app.beastapp.BeastMain.<init>(Unknown Source)
    at beast.app.beastapp.BeastMain.main(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at apple.launcher.LaunchRunner.run(LaunchRunner.java:116)
    at apple.launcher.LaunchRunner.callMain(LaunchRunner.java:51)
    at apple.launcher.JavaApplicationLauncher.launch(JavaApplicationLauncher.java:52)




What I understand from other posts is that this error occurs when the posterior probability is zero/negative, and that this happens when the initial value of the prior probability does not fall within the range of its distribution. What I don't understand is what I did wrong. I subsequently made sure that they are indeed contained with the range and still the error message. I also let the distribution be bound to a lower limit of 0, as well as let it range from +/- infinity. Still the same thing.

This was very strange to me seeing that this error is coming from analysis of the tutorial "Ancestral Reconstruction/Discrete Phylogeography with BEAST 2.0". I thought I might be doing something wrong or that something has been left out of the tutorial which I should be doing, so I set up my own dataset and reran the analysis. And to my amazement I got the message:



Start likelihood: -Infinity after 11 initialisation attempts
P(posterior) = -Infinity (was NaN)
    P(prior) = -Infinity (was NaN)
        P(CoalescentConstant.t:beast2_discrete_phylogeo_TEST) = -168.89728643800154 (was NaN)
        P(GammaShapePrior.s:beast2_discrete_phylogeo_TEST) = -0.6137056388801093 (was NaN)
        P(MutationRatePrior.s:beast2_discrete_phylogeo_TEST) = -2.0 (was NaN)
        P(nonZeroRatePrior.s:location) = -Infinity (was NaN)
        P(PopSizePrior.t:beast2_discrete_phylogeo_TEST) = -12.507657623150946 (was NaN)
        P(RateAGPrior.s:beast2_discrete_phylogeo_TEST) = -1.8653600339742873 (was NaN)
        P(RateCTPrior.s:beast2_discrete_phylogeo_TEST) = -1.8653600339742873 (was NaN)
        P(relativeGeoRatesPrior.s:location) = -77.99999999999999 (was NaN)
        P(geoclockPrior.c:location) = -2.0 (was NaN)
        P(MeanRatePrior.c:beast2_discrete_phylogeo_TEST) = -0.3740393215519906 (was NaN)
        P(ucldStdevPrior.c:beast2_discrete_phylogeo_TEST) = -0.8027754226647804 (was NaN)
    P(likelihood) = NaN (was NaN)
        P(treeLikelihood.beast2_discrete_phylogeo_TEST) = NaN (was NaN)
        P(traitedtreeLikelihood.location) = NaN (was NaN)
java.lang.Exception: Could not find a proper state to initialise. Perhaps try another seed.
    at beast.core.MCMC.run(Unknown Source)
    at beast.app.BeastMCMC.run(Unknown Source)
    at beast.app.beastapp.BeastMain.<init>(Unknown Source)
    at beast.app.beastapp.BeastMain.main(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at apple.launcher.LaunchRunner.run(LaunchRunner.java:116)
    at apple.launcher.LaunchRunner.callMain(LaunchRunner.java:51)
    at apple.launcher.JavaApplicationLauncher.launch(JavaApplicationLauncher.java:52)




Same error. Could someone please help me as to what the problem might be and how to fix it? I've attached the xml's from the tutorial as well as the dataset I put together. Thank you in advance.

Leendert


beast2_discrete_phylogeo_TEST.xml
H5N1.xml

Remco Bouckaert

unread,
Feb 23, 2014, 9:15:29 PM2/23/14
to beast...@googlegroups.com
Hi Leendert,

It appears the indicators are all set to false, and therefore the sum-of-indicators is zero and the prior requires it to be at least some positive number. I traced the problem back to the BEAUti template, and put in a fix.

If you re-install the BEAST-classic package -- it should state version 1.1.2 for BEAST-classic-- things should run more smoothly.

Cheers,

Remco


Leendert Cloete

unread,
Feb 25, 2014, 8:40:29 AM2/25/14
to beast...@googlegroups.com
That seemed to have fixed the problem. All is running smooth now. Thank you very much for the help.

Kind regards
Leendert Cloete

Heather Rose Kates

unread,
Jul 12, 2014, 2:38:31 PM7/12/14
to beast...@googlegroups.com
Hi Remco,

hopefully replying in this thread is ok even though it's a bit old- I believe I am having a slightly similar problem to Leendert.  The error message I get when I try to run my xml file in beast v 2.1.3 is:

P(likelihood) = NaN (was NaN)
P(treeLikelihood.CUTC00098_with_outgroups) = NaN (was NaN)
P(treeLikelihood.CUTC047634_with_outgroups) = NaN (was NaN)
P(treeLikelihood.CUTCC013285_with_outgroups) = NaN (was NaN)
P(treeLikelihood.CUTC045659_with_outgroups (modified)) = NaN (was NaN)
P(treeLikelihood.CUTC045912_with_outgroups) = NaN (was NaN)
P(treeLikelihood.CUTC044924_with_outgroups) = NaN (was NaN)
P(treeLikelihood.CUTC045173_with_outgroups) = NaN (was NaN)
P(treeLikelihood.CUTC036640_with_outgroups (modified)) = NaN (was NaN)
P(treeLikelihood.CUTC037082_with_outgroups) = NaN (was NaN)
P(treeLikelihood.CUTC036469_with_outgroups) = NaN (was NaN)
P(treeLikelihood.CUTC035594_23034_with_outgroups) = NaN (was NaN)
P(treeLikelihood.CUTC034729_PARALOG1_with_outgroups) = NaN (was NaN)
P(treeLikelihood.CUTC034809_with_outgroups) = NaN (was NaN)
P(treeLikelihood.CUTC033182_13653_with_outgroups) = NaN (was NaN)
P(treeLikelihood.CUTC034728_PARALOG_2_with_outgroups) = NaN (was NaN)
P(treeLikelihood.CUTC030563_with_outgroups) = NaN (was NaN)
P(treeLikelihood.CUTC031350_with_outgroups) = NaN (was NaN)
P(treeLikelihood.CUTC029194_with_outgroups) = NaN (was NaN)
P(treeLikelihood.CUTC028777_with_outgroups) = NaN (was NaN)
P(treeLikelihood.CUTC028370_with_outgroups) = NaN (was NaN)
P(treeLikelihood.CUTC028067_with_outgroups) = NaN (was NaN)
P(treeLikelihood.CUTC025497_with_outgroups) = NaN (was NaN)
P(treeLikelihood.CUTC023408_with_outgroups) = NaN (was NaN)
P(treeLikelihood.CUTC022794CUTC00964_with_outgroups) = NaN (was NaN)
P(treeLikelihood.CUTC020890_with_outgroups) = NaN (was NaN)
P(treeLikelihood.CUTC020170_with_outgroups) = NaN (was NaN)
P(treeLikelihood.CUTC019250_with_outgroups) = NaN (was NaN)
P(treeLikelihood.CUTC017739_with_outgroups) = NaN (was NaN)
P(treeLikelihood.CUTC014907_with_outgroups (modified)) = NaN (was NaN)
P(treeLikelihood.CUTC013578_with_outgroups) = NaN (was NaN)
P(treeLikelihood.CUTC013530_with_outgroups) = NaN (was NaN)
P(treeLikelihood.CUTC012412_with_outgroups) = NaN (was NaN)
P(treeLikelihood.CUTC011783_with_outgroups) = NaN (was NaN)
P(treeLikelihood.CUTC010843_with_outgroups) = NaN (was NaN)
P(treeLikelihood.CUTC008905_03774_with_outgroups) = NaN (was NaN)
P(treeLikelihood.CUTC007154_B_with_outgroups) = NaN (was NaN)
P(treeLikelihood.CUTC007154_A_with_outgroups) = NaN (was NaN)
P(treeLikelihood.CUTC006961_with_outgroups (modified)) = NaN (was NaN)
P(treeLikelihood.CUTC005867_with_outgroups) = NaN (was NaN)
P(treeLikelihood.CUTC005742_with_outgroups) = NaN (was NaN)
P(treeLikelihood.CUTC004036_with_outgroups) = NaN (was NaN)
P(treeLikelihood.CUTC003408_with_outgroups) = NaN (was NaN)
P(treeLikelihood.CUTC002236_with_outgroups) = NaN (was NaN)
P(treeLikelihood.CUTC003400_with_outgroups) = NaN (was NaN)
java.lang.Exception: Could not find a proper state to initialise. Perhaps try another seed.
at beast.core.MCMC.run(Unknown Source)
at beast.app.BeastMCMC.run(Unknown Source)
at beast.app.beastapp.BeastMain.<init>(Unknown Source)
at beast.app.beastapp.BeastMain.main(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at apple.launcher.LaunchRunner.run(LaunchRunner.java:116)
at apple.launcher.LaunchRunner.callMain(LaunchRunner.java:51)
at apple.launcher.JavaApplicationLauncher.launch(JavaApplicationLauncher.java:52)

I am attaching the xml file created in beauti using the starbeast template.  

You advised Leendert to re-install the BEAST-classic package, and while I don't know whether or not that would solve my problem (I may actually have made an error in beauti, I just don't know what it is), I could not find the download you're referring to - version 1.1.2 for BEAST-classic.  Could you direct me to that download?  Or does it not exist anymore and I should try something else to solve this problem? XML attached.

Thank you,
Heather-Rose
prgmatic_data_for_beast.xml

Heather Rose Kates

unread,
Jul 12, 2014, 10:31:33 PM7/12/14
to beast...@googlegroups.com
Hi again,

I have spent the last few hours trying to troubleshoot this problem, after I found additional advise on another site.  I added empty taxa to several of my alignments, since the alignments loaded in my initial beauti template did not all have sequences from every species in the taxon set.  That did not solve my problem (though that was probably also an issue).  I tried loading subsets of my total 44 alignments to try to isolate the problem.  While I may have found one problematic alignment, it seems more to correlate to the number of alignments. For example, when I include alignments x y and z as the last 3 alignments in a set of 30, when the other 27 already worked (as a full set of 27), the xml file fails in beast.  However, if I include alignments x y and z in a different xml file with fewer alignments, there is no error.

I am now attaching several examples of xml files that did work as well as some of the log output and several examples of xml files that did not work.  I am also attaching all of my 44 nexus files.

I would really appreciate any advice,
Thanks!
Heather-Rose
BEAST_problems.zip

Remco Bouckaert

unread,
Jul 13, 2014, 5:20:41 PM7/13/14
to beast...@googlegroups.com
Hi Heather,

The latest version for BEAST_CLASSIC is not 1.1.3 -- when you open the package manager in BEAUti (using the File/Manage packages menu) it should show the version you have installed and the latest one.

I'll have a closer look at your XML files to see what causes the starting problem.

Cheers,

Remco

Heather Rose Kates

unread,
Jul 13, 2014, 6:54:14 PM7/13/14
to beast...@googlegroups.com
Hi Remco,

thanks for your response.  I do have the most recent version of BEAST_CLASSIC installed.  

Thanks in advance for your time,
Heather-Rose

Remco Bouckaert

unread,
Jul 13, 2014, 8:26:47 PM7/13/14
to beast...@googlegroups.com
Hi Heather,

I am afraid there are still genes that have taxa missing for some species. For example in error_xml.xml I found that the gene for CUTC037082 has no sequence for arygrosperma. I am not quite sure whether adding empty sequences is the right thing to do -- it certainly will affect the number of coalescent events, and thus population size estimates. So you want to take that in account when adding empty sequences.

Cheers,

Remco

Heather Rose Kates

unread,
Jul 13, 2014, 10:58:21 PM7/13/14
to beast...@googlegroups.com
Hi Remco,

Thanks for looking at this.  While I understand and take your advice seriously, I would still like to manage to run beast on my dataset and see what the results are.  In my nexus files there is a sequence for argyrosperma in CUTC037082.  I checked these 44 alignments multiple times by eye and using a perl one liner (perl -0777 -nlwE 'say $ARGV if !/"speceies_name"/i' *.nex) and I do not believe any of the nexus files have any of the 22 species missing.  Is there any way I could have created that problem in beauti?

I don't know whether it's relevant, but could you explain where the information in the alignment data in the error output comes from?

For example, in
 <sequence id="seq_C_argyrosperma_11" taxon="C_argyrosperma_1" 

In the nexus file, the sequence name was C_argyrosperma_1.  Why does it add a 1 for the sequence id?  This seems kind of normal, but something like:
 <sequence id="seq_C_okeech_126" taxon="C_okeech_1" 
when the sequence name was C_okeech_1, I don't understand where the "26" comes from.

Thank you again,
Heather-Rose

Remco Bouckaert

unread,
Jul 13, 2014, 11:15:50 PM7/13/14
to beast...@googlegroups.com
Hi Heather-Rose,

I think there is a spelling mistake: arygrosperma is not argyrosperma, but both appear in the XML.

Hope this helps,

Remco

Frederik Van den Broeck

unread,
Aug 2, 2014, 6:10:51 AM8/2/14
to beast...@googlegroups.com
Dear all,

I'm having a similar problem as the ones reported here. I installed the latest classic package into beast, so that is not the problem I assume. I'm trying to run a discrete diffusion model for 50 strains and about 10000 SNPs, and for this I follow step-by-step the tutorial on the Beast website. In attachment you can find the reduced xml file (I omitted most of the data) and here below the error I get when running Beast:

Start likelihood: -Infinity after 11 initialisation attempts
P(posterior) = -Infinity (was NaN)
P(prior) = -Infinity (was NaN)
P(CoalescentConstant.t:chr1) = -224.91126226515757 (was NaN)
P(GammaShapePrior.s:chr1) = -1.0 (was NaN)
P(KappaPrior.s:chr1) = -1.8653600339742873 (was NaN)
P(nonZeroRatePrior.s:location) = -Infinity (was NaN)
P(PopSizePrior.t:chr1) = 1.2039728043259361 (was NaN)
P(relativeGeoRatesPrior.s:location) = -350.99999999999994 (was NaN)
P(geoclockPrior.c:location) = -6.915086640662835 (was NaN)
P(likelihood) = NaN (was NaN)
P(treeLikelihood.chr1) = NaN (was NaN)
P(traitedtreeLikelihood.location) = NaN (was NaN)
java.lang.Exception: Could not find a proper state to initialise. Perhaps try another seed.
at beast.core.MCMC.run(Unknown Source)
at beast.app.BeastMCMC.run(Unknown Source)
at beast.app.beastapp.BeastMain.<init>(Unknown Source)
at beast.app.beastapp.BeastMain.main(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at apple.launcher.LaunchRunner.run(LaunchRunner.java:116)
at apple.launcher.LaunchRunner.callMain(LaunchRunner.java:51)
at apple.launcher.JavaApplicationLauncher.launch(JavaApplicationLauncher.java:52)

Does anyone has a clue what the problem is? I really don't know what went wrong...

Thanks a lot for your reactions
Frederik


Op maandag 14 juli 2014 05:15:50 UTC+2 schreef Remco Bouckaert:

Remco Bouckaert

unread,
Aug 2, 2014, 4:11:26 PM8/2/14
to beast...@googlegroups.com
Hi Fredrick,

The error message suggests that the nonZeroRatePrior.s:location-prior is zero (so the log is -Infinity). This usually happens when there are many states for the discrete trait model. The prior on the number of rates that is non-zero is rather tight, and initially all rates are non-zero, so there are n(n-1)/2 non-zero rates (for n discrete states), which can result in the probability of that many rates become zero due to numeric issues. To fix this, increase the mean of the prior so the analysis starts. If you really want to keep the prior as is, you can start with a more relaxed, run the chain for a little while till many rates become zero (which usually happens quite quickly), then stop the chain,  change the prior back and resume.

Cheers,

Remco

mbrood

unread,
Jan 2, 2015, 12:46:02 PM1/2/15
to beast...@googlegroups.com
Hi,

I am having a similar issue with an analysis I am trying to run. Here is the error message I receive:

======================================================
Start likelihood: -Infinity after 11 initialisation attempts
P(posterior) = -Infinity (was NaN)
        P(prior) = -Infinity (was NaN)
                P(BayesianSkyline.t:150102_Mtb_origin_snps) = -1194.5337299304804 (was NaN)
                P(MarkovChainedPopSizes.t:150102_Mtb_origin_snps) = -33.700856263602155 (was NaN)
                P(GammaShapePrior.s:150102_Mtb_origin_snps) = -1.0 (was NaN)
                P(nonZeroRatePrior.s:origin) = -Infinity (was NaN)
                P(RateACPrior.s:150102_Mtb_origin_snps) = -3.184008455701433 (was NaN)
                P(RateAGPrior.s:150102_Mtb_origin_snps) = -3.1686658147294304 (was NaN)
                P(RateATPrior.s:150102_Mtb_origin_snps) = -3.184008455701433 (was NaN)
                P(RateCGPrior.s:150102_Mtb_origin_snps) = -3.184008455701433 (was NaN)
                P(RateGTPrior.s:150102_Mtb_origin_snps) = -3.184008455701433 (was NaN)
                P(relativeGeoRatesPrior.s:origin) = -629.9999999999999 (was NaN)
                P(geoclockPrior.c:origin) = -6.915086640662835 (was NaN)
        P(likelihood) = NaN (was NaN)
                P(treeLikelihood.150102_Mtb_origin_snps) = NaN (was NaN)
                P(traitedtreeLikelihood.origin) = NaN (was NaN)
java.lang.Exception: Could not find a proper state to initialise. Perhaps try another seed.
        at beast.core.MCMC.run(Unknown Source)
        at beast.app.BeastMCMC.run(Unknown Source)
        at beast.app.beastapp.BeastMain.<init>(Unknown Source)
        at beast.app.beastapp.BeastMain.main(Unknown Source)

Based on the response from Remco above I tried to find where I can adjust the mean of the prior in Beauti, but had no success. Within the xml file I find the following, but am unsure as to what I should edit.

            <prior id="nonZeroRatePrior.s:origin" name="distribution">
                <x arg="@rateIndicator.s:origin" id="nonZeroRates.s:origin" spec="util.Sum"/>
                <distr id="Poisson.0" offset="35.0" spec="beast.math.distributions.Poisson">
                    <parameter id="RealParameter.01" lower="0.0" name="lambda" upper="0.0">0.693</parameter>
                </distr>
            </prior>

Do you have any suggestions? I will send the entire xml file privately if that would be helpful.

Thank you,



Mary

Remco Bouckaert

unread,
Jan 4, 2015, 2:27:38 PM1/4/15
to beast...@googlegroups.com
Hi Marry,

The number 0.693 in the XML fragment represents the mean for the Poisson distribution so that is the number you want to increase.

Hope this helps,

Remco

--
You received this message because you are subscribed to the Google Groups "beast-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beast-users...@googlegroups.com.
To post to this group, send email to beast...@googlegroups.com.
Visit this group at http://groups.google.com/group/beast-users.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages