Adding uncertainty to tip dates in Beauti2

999 views
Skip to first unread message

Kevin Daly

unread,
Jun 17, 2016, 3:21:31 AM6/17/16
to beast-users
Hi. I'm trying to calibrate a mitogenome tree using a variety of  modern, ancient dated, and ancient non-dated sequences. The vast majority of my sequences are undated, but could be linked with a cultural context with (at worst) a margin of error ~1,000 years or 1,500 years. I've been using Beast2, so I could go along with the tutorials on your website. Is there a way to include uncertainty of dates into Beauti2 or the xml files directly?

Thanks for your time,

Kevin

Remco Bouckaert

unread,
Jun 19, 2016, 4:12:49 PM6/19/16
to beast...@googlegroups.com
Hi Kevin,

BEAUti support for tip dates sampling is limited to the selection you can do at the bottom of the tip dates tab, which seems to be broken.

To make tip sampling work, you need to
1. add a prior on a tip distribution
2. add an operator on the tip
3. log the tip date.

The most convenient way to import distributions on tips is to specify a assumptions block in the nexus file containing the alignment. This looks a bit like this:

begin assumptions;
calibrate Ancient_Greek = normal(2.45,0.1)
calibrate Balto-Slavic = uniform(2.0,3.4)
calibrate Iranian = offsetlognormal(2.6,0.4,0.8)
eend;

Note the punctuation: no semicolon other than at first line and at the end. Also, all taxa referred to in the calibration should be defined in the alignment (though you can define taxon sets in a ‘sets’ block, and then the name of the taxon set can be used to define calibrations on clades). When you import this, a prior is created that you still can edit in the priors tab, an operator is added to sample the tips. You can use the following distributions:

normal(mean, sigma)
uniform(lower, upper)
offsetlognormal(offset, M, S)
lognormal(M, S)
offsetexponential(offset, mean)
gamma(alpha, beta)
offsetgamma(offset, alpha, beta)

Alternatively, you can specify the prior on a taxon set in the prior tab where the set contains a single node. The tip dates operator then still needs to be added, which can be done by editing the XML and add an operator inside the run element (just after where the other operators are would be a good place). Say, we added a taxonset with name oldnorse.leaf, then you can add an operator like so:

    <operator id="TipDatesRandomWalker.oldnorse" spec="TipDatesRandomWalker" taxonset=“@oldnorse.leaf" tree="@Tree.t:ringe" weight="1.0" windowSize="1.0"/>

Just make sure that the id of the tree contains the one of the tree you want to sample the tips from.

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 https://groups.google.com/group/beast-users.
For more options, visit https://groups.google.com/d/optout.

Kevin Daly

unread,
Jun 22, 2016, 6:02:57 AM6/22/16
to beast-users
Thank you, this was extremely helpful!

Kevin Daly

unread,
Feb 22, 2017, 6:24:42 AM2/22/17
to beast-users
Do you still give tip date information in the Beauti GUI when doing this? Or do you leave it and only add the tip information directly to the xml? Thanks

Remco Bouckaert

unread,
Feb 22, 2017, 1:52:21 PM2/22/17
to beast...@googlegroups.com
HI Kevin,

The alternative to specify the calibrations in the nexus file (as explained here:), is to add tip calibrations in BEAUti by ensuring the Tipsonly checkbox is checked in the MRCAPrior. When you have many tips to sample, it is probably easier to specify them in the nexus file, but if there are only a few it can be done in BEAUti as follows (make sure you have BEAST v2.4.5):

1. in the priors panel, add an MRCAPrior by clicking the + button at the bottom of the screen (in case you have packages installed that provide extra priors a dialog may pop up where you select MRCAPrior).

2. create a taxonset with a single taxon, the taxon that you want to sample, give it a unique name eg. “taxon-tip” and click OK.

3. in the priors panel, a new entry appeared with the label “taxon-tip.prior”, select a distribution from the drop-down menu next to it.

4. click the small triangle on the left side of the “taxon-tip.prior” button and specify the parameters of your distribution in the window that opens.

5. make sure to click the “Tipsonly” checkbox. This ensures a TipDatesRandomWalker operator is added to the XML so the taxon tip is samples.

Cheers,

Remco





Kevin Daly

unread,
Feb 24, 2017, 11:13:11 AM2/24/17
to beast-users
Hi Remco, thanks  for your reply. Just to be clear, once you have specified calibrations by either methods and have loaded the nexus / xml file in beati, you leave the "Tip Dates" tab alone i.e. you do not click the "Use tip dates" box? The calibrations already defined will be used, and samples without a calibration point will be assumed to be sampled at 0 years ago?

Remco Bouckaert

unread,
Feb 26, 2017, 3:09:18 PM2/26/17
to beast...@googlegroups.com
Hi Kevin,

The "Tip dates” panel is used to specify starting values for tips, so if you have a calibration with hard bounds (like a log normal or uniform) that does not support the tip age BEAST will not find a suitable starting state unless you specify tip dates in the tip dates panel that have support in the tip distributions.

Cheers,

Remco


On 25/02/2017, at 5:13 AM, Kevin Daly <dal...@tcd.ie> wrote:

Hi Remco, thanks  for your reply. Just to be clear, once you have specified calibrations by either methods and have loaded the nexus / xml file in beati, you leave the "Tip Dates" tab alone i.e. you do not click the "Use tip dates" box? The calibrations already defined will be used, and samples without a calibration point will be assumed to be sampled at 0 years ago?

Kevin Daly

unread,
Feb 27, 2017, 6:19:04 AM2/27/17
to beast-users
Thanks.

babarlelephant

unread,
Jul 11, 2021, 2:04:40 PM7/11/21
to beast-users
Hi, I did what you said using a nexus file instead of fasta and adding 

BEGIN ASSUMPTIONS;
   calibrate Wuhan/SequenceWithUncertainDate_2020-01-15 = uniform(2020,2020.0849) 
END;

in the nexus file, which is supposed to mean a uniform range in January 2020.

But it seems BEAST2 is now converting 2020-01-01 to 2020.0 and interpreting 2020.0 as years before t=0 so that the "root" of my tree (the oldest tip) is now the youngest:

tree.png
Also apparently in BEAST2 2020-01 isn't allowed.

babarlelephant

unread,
Jul 11, 2021, 2:04:57 PM7/11/21
to beast-users
Ok I figured it myself, when the dates are in the nexus Beauty is replacing traitname="date" by traitname="date-backward"

So if your dates are in 2020-01-01 format then search for -backward in the .xml and remove it.

The uncertainty range indicated in the nexus seems to work fine:

BEGIN ASSUMPTIONS;
calibrate Bloom/Wuhan/WU-A4/2020_2020-01-15 = uniform(2020,2020.0849)
END;


Le lundi 27 février 2017 à 12:19:04 UTC+1, dal...@tcd.ie a écrit :
Reply all
Reply to author
Forward
0 new messages