setting up a custom rate matrix in BEAST 1.8?

153 views
Skip to first unread message

Jonathan Chang

unread,
Jan 17, 2017, 6:32:58 PM1/17/17
to beast-users
Hi all,

I'm looking to set up a custom rate matrix for discrete geographic analyses. Basically, I would like to create a three-state model where A<->B and A<->C are allowed, but B<->C is forbidden. However, there isn't much guidance on how to use the <generalSubsitutionModel>, and reading the source was unenlightening. Is there anyone who has successfully used a generalSubstitutionModel with a custom rate matrix, or would it be easier to simply use a GTR model and set certain transitions to 0?


Jonathan

Andrew Rambaut

unread,
Jan 18, 2017, 4:03:16 AM1/18/17
to beast...@googlegroups.com
You can do this by using masked parameters to mask out certain elements. 

I am going to assume you are using BSSVS and a reversible model (but it is also possible if you aren’t).

Firstly look for:

<generalSubstitutionModel id="location.model" randomizeIndicator="false">
.
.
<rates>
<parameter id="location.rates" dimension=“6" value="1.0" lower="0.0"/>
</rates>
<rateIndicator>
<parameter id="location.indicators" dimension=“6" value="1"/>
</rateIndicator>

This is creating a rate indicator parameter of dimension 6 (there are 3 locations) all with a value 1 (a 1 says the rate is ‘on’, 0 ‘off). You need to expand the initial values to explicitly set the pattern you want:

<parameter id="location.indicators" dimension=“6" value=“1 1 1 1 0 1"/>

This turns the 5th rate off.

Now, after </generalSubstitutionModel> create a new masked parameter:


<maskedParameter id="maskedIndicators">
<parameter idref="location.indicators"/>
<mask>
<parameter value="1 1 1 1 0 1"/>
</mask>
</maskedParameter>

Note the mask is the same as the initial indicator value. This creates a new parameter, compressed to only those elements that have 1s in the mask (i.e. 5 elements).

In the operators change the ones that work on “location.indicators” to work on the masked parameter:

<bitFlipOperator weight="10" usesPriorOnSum="false">
<parameter idref="maskedIndicators"/>
</bitFlipOperator>

<bitMoveOperator weight="40" numBitsToMove="1" usesPriorOnSum="false">
<bits>
<parameter idref="maskedIndicators"/>
</bits>
</bitMoveOperator>

This means only the elements in the masked parameter will change.

Notes:

If you turn off too many rates such that the matrix is not fully connected then it won’t work.

If you are not using BSSVS then set up the starting location.rates with 1.0 and 0.0 accordingly and then create a masked parameter for these instead.

Andrew
Reply all
Reply to author
Forward
0 new messages