<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://teaching.healthtech.dtu.dk/22115/index.php?action=history&amp;feed=atom&amp;title=Bayesian_phylogenetics%3A_checking_convergence</id>
	<title>Bayesian phylogenetics: checking convergence - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://teaching.healthtech.dtu.dk/22115/index.php?action=history&amp;feed=atom&amp;title=Bayesian_phylogenetics%3A_checking_convergence"/>
	<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk/22115/index.php?title=Bayesian_phylogenetics:_checking_convergence&amp;action=history"/>
	<updated>2026-04-07T12:40:43Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://teaching.healthtech.dtu.dk/22115/index.php?title=Bayesian_phylogenetics:_checking_convergence&amp;diff=109&amp;oldid=prev</id>
		<title>Gorm: /* Check convergence using Tracer */</title>
		<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk/22115/index.php?title=Bayesian_phylogenetics:_checking_convergence&amp;diff=109&amp;oldid=prev"/>
		<updated>2025-04-23T11:19:33Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Check convergence using Tracer&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 13:19, 23 April 2025&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l12&quot;&gt;Line 12:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 12:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  tracer&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  tracer&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;: Now import the two MCMC sample files from the MrBayes run you did in week &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;9 &lt;/del&gt;for the hcvsmall data set:&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;: Now import the two MCMC sample files from the MrBayes run you did in week &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;7 &lt;/ins&gt;for the hcvsmall data set:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;:* File -&amp;gt; Import Trace File (or use the + under the trace file pane)&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;:* File -&amp;gt; Import Trace File (or use the + under the trace file pane)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;:* In the import dialog: find the &amp;quot;bayes&amp;quot; directory and select &amp;quot;All files&amp;quot; under &amp;quot;files of type&amp;quot;. This should give you a list of the output files from the MrBayes run&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;:* In the import dialog: find the &amp;quot;bayes&amp;quot; directory and select &amp;quot;All files&amp;quot; under &amp;quot;files of type&amp;quot;. This should give you a list of the output files from the MrBayes run&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Gorm</name></author>
	</entry>
	<entry>
		<id>https://teaching.healthtech.dtu.dk/22115/index.php?title=Bayesian_phylogenetics:_checking_convergence&amp;diff=108&amp;oldid=prev</id>
		<title>Gorm: /* Check convergence using Tracer */</title>
		<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk/22115/index.php?title=Bayesian_phylogenetics:_checking_convergence&amp;diff=108&amp;oldid=prev"/>
		<updated>2025-04-23T11:18:52Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Check convergence using Tracer&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 13:18, 23 April 2025&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l3&quot;&gt;Line 3:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 3:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Check convergence using Tracer ==&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Check convergence using Tracer ==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;In this exercise you will be briefly introduced to how to check if an MCMC run has converged using the program Tracer from the BEAST2 package. You will do this by re-examining the output from the Bayesian analysis you did in the week &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;9 &lt;/del&gt;exercise.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;In this exercise you will be briefly introduced to how to check if an MCMC run has converged using the program Tracer from the BEAST2 package. You will do this by re-examining the output from the Bayesian analysis you did in the week &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;7 &lt;/ins&gt;exercise.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;----&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;----&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Gorm</name></author>
	</entry>
	<entry>
		<id>https://teaching.healthtech.dtu.dk/22115/index.php?title=Bayesian_phylogenetics:_checking_convergence&amp;diff=35&amp;oldid=prev</id>
		<title>WikiSysop: Created page with &quot;This exercise is part of the course  Computational Molecular Evolution (22115).  == Check convergence using Tracer ==  In this exercise you will be briefly introduced to how to check if an MCMC run has converged using the program Tracer from the BEAST2 package. You will do this by re-examining the output from the Bayesian analysis you did in the week 9 exercise.  ----  &#039;&#039;&#039;Question 1&#039;&#039;&#039;  : Issue this command to start the Trace...&quot;</title>
		<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk/22115/index.php?title=Bayesian_phylogenetics:_checking_convergence&amp;diff=35&amp;oldid=prev"/>
		<updated>2024-03-19T13:44:30Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;This exercise is part of the course  &lt;a href=&quot;/22115/index.php/22115_-_Computational_Molecular_Evolution&quot; title=&quot;22115 - Computational Molecular Evolution&quot;&gt;Computational Molecular Evolution (22115)&lt;/a&gt;.  == Check convergence using Tracer ==  In this exercise you will be briefly introduced to how to check if an MCMC run has converged using the program Tracer from the BEAST2 package. You will do this by re-examining the output from the Bayesian analysis you did in the week 9 exercise.  ----  &amp;#039;&amp;#039;&amp;#039;Question 1&amp;#039;&amp;#039;&amp;#039;  : Issue this command to start the Trace...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;This exercise is part of the course  [[22115_-_Computational_Molecular_Evolution|Computational Molecular Evolution (22115)]].&lt;br /&gt;
&lt;br /&gt;
== Check convergence using Tracer ==&lt;br /&gt;
&lt;br /&gt;
In this exercise you will be briefly introduced to how to check if an MCMC run has converged using the program Tracer from the BEAST2 package. You will do this by re-examining the output from the Bayesian analysis you did in the week 9 exercise.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Question 1&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
: Issue this command to start the Tracer program:&lt;br /&gt;
 tracer&lt;br /&gt;
&lt;br /&gt;
: Now import the two MCMC sample files from the MrBayes run you did in week 9 for the hcvsmall data set:&lt;br /&gt;
:* File -&amp;gt; Import Trace File (or use the + under the trace file pane)&lt;br /&gt;
:* In the import dialog: find the &amp;quot;bayes&amp;quot; directory and select &amp;quot;All files&amp;quot; under &amp;quot;files of type&amp;quot;. This should give you a list of the output files from the MrBayes run&lt;br /&gt;
:* Select the file &amp;quot;hcvsmall.nexus.run1.p&amp;quot; and open it.&lt;br /&gt;
:* Repeat process for second log file (suffix &amp;quot;.run2.p&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
:::::[[File:Tracer fileload2.png |800px]]&lt;br /&gt;
&lt;br /&gt;
: You can now use Tracer to explore the results of the Bayesian analysis. The first thing you want to check is that the two independent runs have resulted in similar posteriors for the different parameters. This is investigated as follows:&lt;br /&gt;
:* Select both trace files by shift-clicking on their names in the &amp;quot;Trace files&amp;quot; pane (upper left of the Tracer window)&lt;br /&gt;
:* Select the &amp;quot;Marginal Density&amp;quot; tab in the window on the right.&lt;br /&gt;
:* Check different parameters by choosing them in the &amp;quot;Traces&amp;quot; pane on the left (while making sure you still have both trace files selected). This will show the two posteriors for the chosen parameter (see example below). If a run has converged then the two posteriors should mostly be placed right on top of each other. &lt;br /&gt;
:* Note that Tracer by default uses a burnin of 10% of the total number of generations. You can change that by double-clicking in the Burn-in field of the trace file pane (you need to change it separately for each file). Typically we would use a burn-in of 25% or 50%.&lt;br /&gt;
&lt;br /&gt;
:::::[[File:Tracer marginals overlap.png|800px]]&lt;br /&gt;
&lt;br /&gt;
:* The plot below shows an example where convergence has not occurred yet:&lt;br /&gt;
&lt;br /&gt;
:::::[[File:Tracer lousy convergence.png|800px]]&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Question: &amp;#039;&amp;#039;&amp;#039;Take screen dumps of the marginal posterior plots for the following parameters and include them in your report: m{1} and piA{all}&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Question 2&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
:* Another thing to check is how the trace looks as a function of the iteration number: Optimally you would want a trace that looks like a &amp;quot;hairy caterpillar&amp;quot;, with random jumps up and down on a mostly constant level (see example below). &lt;br /&gt;
:* Select the &amp;quot;Trace&amp;quot; tab in the window on the right to see trace plots (still with one or both trace files selected in the Trace File pane).&lt;br /&gt;
:* Related to this: The ESS column gives the &amp;quot;Effective Sample Size&amp;quot; for each parameter. As a rule of thumb we want this to be at least 200 (and Tracer flags smaller values by colouring the ESS values). &lt;br /&gt;
:** Briefly, the problem here is that consecutive samples from MCMC are correlated (they are not independent). This is due to the use of a Markov chain for sampling: the new position in parameter space depends on the previous location (and the proposal distribution). &lt;br /&gt;
:** The degree of non-indepence can be quantified by the auto-correlation for different lags: The autocorrelation for lag k is found by computing the Pearson correlation between all samples, and the samples k generations later. &lt;br /&gt;
:** Based on computation of auto-correlation at different lags (&amp;lt;math&amp;gt;k = [1, 2, 3, ...]&amp;lt;/math&amp;gt;) Tracer determines the Auto-Correlation Time (ACT), which is the number of generations in the MCMC chain that two samples have to be separated by for them to be uncorrelated. The ACT for a parameter can be seen in the Estimates tab in Tracer.&lt;br /&gt;
:** Tracer also estimates the Effective Sample Size (ESS), which is the number of independent samples that the trace is equivalent to. This is essentially the chain length (excluding the burn-in) divided by the ACT.&lt;br /&gt;
:* Note how the highlighted parameter corresponding to the hairy caterpillar trace also has a high ESS in the example below.&lt;br /&gt;
&lt;br /&gt;
:::::[[File:Tracer hairy caterpillar.png|800px]]&lt;br /&gt;
&lt;br /&gt;
:* Trace plots where there are clearly visible dips and rises (see example below) indicates that there is auto correlation among the samples we have included - the samples are not independent of each other (and therefore provide less information about the posterior). This is referred to as &amp;quot;poor mixing&amp;quot;. One solution to such a problem is to increase the number of iterations (and perhaps write samples less frequently). It might also be an indication that the model fits poorly, and that you could get a better convergence by changing the substitution model, or setting more informative priors.&lt;br /&gt;
:* Note how the poorly mixing parameter in the example below also has a low ESS.&lt;br /&gt;
&lt;br /&gt;
:::::[[File:Tracer ugly caterpillar.png|800px]]&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Question: &amp;#039;&amp;#039;&amp;#039;Take screen dumps of the trace plots for the following parameters and include them in your report: m{1} and piA{all}. What is the ESS for these parameters?&lt;/div&gt;</summary>
		<author><name>WikiSysop</name></author>
	</entry>
</feed>