Separate Markov Jumps counts for different transition types

1,349 views
Skip to first unread message

Nicola de maio

unread,
Mar 27, 2014, 12:39:47 PM3/27/14
to beast...@googlegroups.com
Hi all,

I have seen that in Beauti it is possible to use the Markov Jumps option to estimate the number of transitions for a discrete trait CTMC, such as number of migration events in a phylogeography model.
In some publications, separate number of state transitions for different transition types have been counted (e.g. migrations from deme 1 to deme 2, and separately migrations from deme 2 to deme 1).
Yet, what I see from my Beast output is only counts for all transitions types together.
Is there an example Beast xml input file that I could use as a template for this type of analyses, or similar help?

Best wishes,
Nicola De Maio

Philippe Lemey

unread,
Mar 28, 2014, 4:25:40 AM3/28/14
to beast...@googlegroups.com
Dear Nicola,
When you select the Markov jump option in BEAuti, you will indeed get a single parameter in the markovJumpsTreeLikelihood that labels all state transitions (the zero's in the count vector will be the diagonals in the transition matrix). To label specific jumps that you are interested in, you would need to create another parameter in the xml following the generic example and put this also in the markovJumpsTreeLikelihood. Let's say we have five states in the generalDataType (A, B, C, D and E), than this would be an example for the labeling the A-to-B jump:

<parameter id="AtoB" value=" 0 1 0 0 0
0 0 0 0 0
0 0 0 0 0 
0 0 0 0 0 
0 0 0 0 0">  

or the reverse B-to-A jump:

<parameter id="AtoB" value=" 0 0 0 0 0
1 0 0 0 0
0 0 0 0 0 
0 0 0 0 0 
0 0 0 0 0">  

or all jumps to D:

<parameter id="toD" value=" 0 0 0 1 0
0 0 0 1 0
0 0 0 1 0 
0 0 0 0 0 
0 0 0 1 0">  

or all jumps from E:

<parameter id="fromE" value=" 0 0 0 0 0
0 0 0 0 0
0 0 0 0 0 
0 0 0 0 0 
1 1 1 1 0">  

etc..

Best,
Philippe


--
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.

Udayan

unread,
Apr 16, 2014, 11:59:23 PM4/16/14
to beast...@googlegroups.com
Hi Philippe,

Do specific jumps (in your example above) need to be logged separately in one of the logfiles?

Thanks,

Udayan

Philippe Lemey

unread,
Apr 17, 2014, 2:09:18 AM4/17/14
to beast...@googlegroups.com
Hi Udayan,
If the markovJumpsTreeLikelihood is included in the log element, all the labelled jump counts should be logged automatically in the log file.
Best,
Philippe

Kirstyn

unread,
Jul 23, 2014, 8:54:15 AM7/23/14
to beast...@googlegroups.com
Hi Philippe

Is there a way to automatically log all the state transitions without having to individually add each one with its own matrix? I have ~30 states so that is a lot of transition matrices!
Thanks
Kirstyn

Philippe Lemey

unread,
Jul 25, 2014, 7:55:30 AM7/25/14
to beast...@googlegroups.com
Hi Kirstyn,
Yes, you can add saveCompleteHistory="true" to your markovJumpsTreeLikelihood, which will track the complete jump history. To log this, add something like
<log id="completeJumpHistory" logEvery="1000" fileName="jumpHistory.log">
<completeHistoryLogger>
<markovJumpsTreeLikelihood idref="ancestralTreeLikelihood"/>
</completeHistoryLogger>
</log>
to the mcmc element. It will write out the jumps with their heights in bracket notation for each sampled state, so some scripting may be needed to get at the information you are interested in.
Best wishes,
Philippe

Kirstyn

unread,
Jul 25, 2014, 9:07:49 AM7/25/14
to beast...@googlegroups.com
Brilliant!

Thank you!

Kirstyn

unread,
Jul 28, 2014, 6:10:29 AM7/28/14
to beast...@googlegroups.com
Hi Philippe

I also had to add useUniformization="true" to the markovJumpsTreeLikelihood to get it to run. What exactly does this do?

Kirstyn

Philippe Lemey

unread,
Jul 28, 2014, 6:24:51 AM7/28/14
to beast...@googlegroups.com
It is a type of stochastic mapping. Vladimir Minin and Marc Suchard have shown that one can efficiently obtain jump count expectations using analytics, and this is what had been originally implemented, but as soon as you want jumps and their times on all branches, than we had to resort to uniformization to do stochastic mapping. Sorry for not pointing this out in the first place.
P.

Minin VN and Suchard MA. Counting labeled transitions in continuous-time Markov models of evolutionJournal of Mathematical Biology, 56:391 – 412.

Justin

unread,
Sep 24, 2014, 11:08:30 AM9/24/14
to beast...@googlegroups.com
Is there any reason why the number of counts logged in the complete history/MCMC step would be different than the total number of counts recorded in the markovjumpTreelikelihood?

J

Justin

unread,
Sep 24, 2014, 4:22:40 PM9/24/14
to beast...@googlegroups.com
I should've read this entire thread. 

I see that the total transition counts observed in the transition map = c_allTransitions in the log file and not the c_Trait.count. The two logged values are very close. Is the difference because of the uniformization?

J

nvgiap

unread,
Mar 23, 2015, 9:26:57 AM3/23/15
to beast...@googlegroups.com
Dear Dr. Lemey,

As you mentioned about the scripts, would you please show me how to draw a transition web?

Thank you very much!
Giap Nguyen

Vào 18:55:30 UTC+7 Thứ Sáu, ngày 25 tháng 7 năm 2014, philippe đã viết:

Philippe Lemey

unread,
Mar 23, 2015, 9:51:15 AM3/23/15
to beast...@googlegroups.com
Dear Giap Nguyen,
If you are referring to the Bayes factor support for transition rates calculated based on BSSVS estimates, than you can use SPREAD to summarise those:
best,
P.

Giap Nguyen

unread,
Mar 23, 2015, 10:00:03 AM3/23/15
to beast...@googlegroups.com
Dear Dr. Lemey,

Thank you for your reply. My interest is how to make a transition web base on markov jump counts between state. I attach a figure that I would like to produce.

Thank you so much!
Giap Nguyen
Picture1.png

Pauline Faure

unread,
Apr 21, 2015, 4:51:06 AM4/21/15
to beast...@googlegroups.com
Dear Dr Lemey,

I don't want to bother anyone, but I tried to add the following suggested script to my xml file. I am bviously not doing it properly. I can't seem to figure out where or how to insert both commands.
If I only write the <log command to my mcmc, it tells me : Fatal exception: Tree 'location.treeLikelihood' does not have a complete history trait at site 1

And if I add this to the xml:
                <!-- START Discrete Traits Model                                             -->
                <markovJumpsTreeLikelihood idref="location.treeLikelihood"/>
                <saveCompleteHistory="true"/>
                <!-- END Discrete Traits Model 

Beast tells me :
Fatal error:
    Line number: 946
    Column number: 25
    Error message: Element type "saveCompleteHistory" must be followed by either attribute specifications, ">" or "/>"
even though I wrote it properly.

I am sure I am doing something wrong or missing something, but I can't figure out what.

Thank you for your help!

Pauline

Philippe Lemey

unread,
Apr 21, 2015, 5:42:34 AM4/21/15
to beast...@googlegroups.com
Dear Pauline,
The saveCompleteHistory=“true” (and logCompleteHistory=“true”) should be added to the markovJumpsTreeLikelihood, e.g.

<!-- Likelihood for tree given discrete trait data                           -->
<markovJumpsTreeLikelihood id="Location.treeLikelihood" stateTagName="Location.states" useUniformization="true" saveCompleteHistory="true" logCompleteHistory="true">
<attributePatterns idref="Location.pattern"/>
<treeModel idref="treeModel"/>
<siteModel idref="Location.siteModel"/>
<generalSubstitutionModel idref="Location.model"/>
<strictClockBranchRates idref="Location.branchRates"/>

<!-- The root state frequencies                                              -->
<frequencyModel id="Location.root.frequencyModel" normalize="true">
<generalDataType idref="Location.dataType"/>
<frequencies>
<parameter id="Location.root.frequencies" dimension="9"/>
</frequencies>
</frequencyModel>

</markovJumpsTreeLikelihood>

Before adding the specific logger at the end of the xml.

Best wishes,
Philippe


Pauline Faure

unread,
Apr 22, 2015, 5:27:03 AM4/22/15
to beast...@googlegroups.com
Dear Dr Lemey,

Thank you so very much for your help: indeed it worked!  

Best wishes!

Pauline

yuhan

unread,
May 25, 2016, 8:50:26 AM5/25/16
to beast-users
Hi Philippe,

I have been studying Markov Jump and facing the same problem,I want to know where insert these command in XML?

Many thanks,

Yuhan

在 2014年7月25日星期五 UTC+8下午7:55:30,philippe写道:

Brandon Stark

unread,
May 11, 2021, 9:54:37 PM5/11/21
to beast-users
@Philippe, do you have the script for extract the markov reward through time, thanks.
Reply all
Reply to author
Forward
0 new messages