Likelihood of single continuous trait in Beast2?

265 views
Skip to first unread message

Nick Matzke

unread,
Dec 13, 2014, 4:08:48 PM12/13/14
to beast...@googlegroups.com
Hi all,

I have successfully gotten continuous phylogeography to work in Beast2.1.3 (after installing the BEAST_CLASSIC and BEASTlabs packages).  This is two continuous traits evolving under a Brownian random walk/diffusion process, or relaxed random walk (RRW), depending on the clock model.

However, I can't seem to figure out a way to make Beast2 do something similar with a single continuous trait, e.g. bodyszie.  This seems surprising, since it should be easier, and I believe it existed in Beast1.

My best guess was to take a working continuous phylogeography analysis and reduce it down to a single trait, with a 1x1 precisionMatrix, and reduce the other parameter dimensions accordingly.  However, whatever I do, this seems to produce a divide-by-zero error: "validate and intialize error: / by zero". Perhaps this means there is something about the SampledMultivariateTraitLikelihood function which means that it cannot be reduced down to a single trait.

So, questions:

1. Is there a simple way to edit the XML to calculate the likelihood of one continuous trait on a tree, e.g. under Brownian motion?

...or...

2. An alternative strategy would be to just run the 2 traits under the continuous phylogeography model, but force them to be uncorrelated, and just take the likelihood of one of them (or run the same trait twice and divide by 2 or whatever).  Is forcing no correlation as simple as fixing the precision matrix to "1 0 0 1" or some such?

Below I put the error message below for the 1-trait analysis. Here are links to the XML files for the broken 1-trait analysis and a functional 2-trait phylogeography analysis.


Cheers, and thanks VERY MUCH for any help / hints!
Cheers,
Nick


Error message: "validate and intialize error: / by zero"
===============

34 taxa

645 sites

77 patterns

TreeLikelihood uses beast.evolution.likelihood.BeerLikelihoodCore4

34 taxa

645 sites

78 patterns

TreeLikelihood uses beast.evolution.likelihood.BeerLikelihoodCore4

java.lang.ArithmeticException: / by zero

at beast.continuous.AbstractMultivariateTraitLikelihood.initAndValidate(Unknown Source)

at beast.continuous.SampledMultivariateTraitLikelihood.initAndValidate(Unknown Source)

at beast.util.XMLParser.initPlugins(Unknown Source)

at beast.util.XMLParser.parse(Unknown Source)

at beast.util.XMLParser.parseFile(Unknown Source)

at beast.app.BeastMCMC.parseArgs(Unknown Source)

at beast.app.beastapp.BeastMain.main(Unknown Source)


Error 110 parsing the xml input file


validate and intialize error: / by zero


Error detected about here:

  <beast>

      <run id='mcmc' spec='MCMC'>

          <distribution id='posterior' spec='util.CompoundDistribution'>

              <distribution id='likelihood' spec='util.CompoundDistribution'>

                  <distribution id='locationtreeLikelihood.location' spec='beast.continuous.SampledMultivariateTraitLikelihood'>

===============

Remco Bouckaert

unread,
Dec 14, 2014, 11:46:20 PM12/14/14
to beast...@googlegroups.com
Hi Nick,

It sounds like the way you set up the XML is correct, but I think what is happening according to the error message you posted is that the datatype (ContinuousDataType) returns a dimension of zero instead of 1, causing the division by zero error.

I updated the BEAST_CLASSIC package so it returns 1 now, so if you update to BEAST_CLASSIC version 1.1.7 (for BEAST v2.1.3) it should work. 

Let me know if you are running into any problems.

Cheers,

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.

Nick Matzke

unread,
Dec 15, 2014, 12:08:24 PM12/15/14
to beast...@googlegroups.com
Hi Remco!

I did the BEAST_CLASSIC update and now the 1-trait analysis works fine.  Thanks SO MUCH!! (as always!)

Cheers,
Nick

Remco Bouckaert

unread,
Dec 16, 2014, 7:06:53 PM12/16/14
to beast...@googlegroups.com
Hi Nick,

If you are using the TraitGibssOperator, I recommend upgrading to BEAST_CLASSIC 1.1.8 — some older versions essentially do not work and make the MCMC much slower.

Cheers,

Remco

Nick Matzke

unread,
Dec 17, 2014, 2:43:08 PM12/17/14
to beast...@googlegroups.com
Hi Remco,

Thanks for the upgrade! I have just done the update to 1.1.8 and can confirm it works (at least, it runs).

Can I ask a few simple questions just to make sure I understand what's happening?

1. When I do a screenLog on the likelihood of the continuous trait, I get e.g.:

==================
locatio_.joint locatio_n.data
-2.028548330E7 -1.937356187E7
-583.3830      -290.0381
-519.1078      -257.7901
-501.3945      -241.7478
==================

Is it correct to say that 

locatio_n.data = log-likelihood of the continuous trait data given the tree & model
locatio_.joint = log-likelihood of the continuous trait data given the tree & model & sampled ancestral states at nodes


2. Which of these gets used in the calculation of the posterior?  (probably they scale very similarly so it might not matter)


3. If one were only interested in estimating the phylogeny, and not the ancestral states, I guess one would really only need to calculate locatio_n.data for each trait.  Is there a way to do that?  (Perhaps the speed difference is minimal compared to e.g. thousands of nucleotide characters but might as well check)

Cheers!
Nick




Remco Bouckaert

unread,
Dec 17, 2014, 11:36:09 PM12/17/14
to beast...@googlegroups.com
Hi Nick,

The joint is used for the posterior and is the product over all branches of the likelihood of going from a location A at the top of a branch to a location B at the bottom of a branch, given the length (and branch rate) of the branch. 

The data likelihood is the product of branches ending in a tips only.

Hope this makes sense,

Remco

Nick Matzke

unread,
Dec 18, 2014, 11:44:53 AM12/18/14
to beast...@googlegroups.com
Thanks Remco!  Cheers!
Nick
Reply all
Reply to author
Forward
0 new messages