Skip to content

Commit 27ed570

Browse files
authored
Merge pull request #3 from jugne/master
Updated TtB tutorial to work with BEAUti template upgrade
2 parents a99e9fd + 7b8dac3 commit 27ed570

20 files changed

Lines changed: 13424 additions & 13429 deletions

README.md

Lines changed: 57 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
22
author: "Nicola F. Müller,Tim Vaughan"
3-
beastversion: 2.4.2
4-
tracerversion: 1.6.0
5-
figtreeversion: 1.4.2
3+
beastversion: 2.7.x
4+
tracerversion: 1.7.3
5+
figtreeversion: 1.4.x
66
level: Professional
77
subtitle: Population structure using MultiTypeTree
88
title: Structured coalescent
@@ -81,19 +81,41 @@ We will use BEAUti to generate the input XML for BEAST2 from the sequence alignm
8181

8282
### Install BEAST 2 Plug-Ins
8383

84-
The packages MultiTypeTree is not implemented in the core of BEAST, but has to be installed (Figure [1](#fig:install_mtt)).
84+
The packages MultiTypeTree is not implemented in the core of BEAST, but has to be installed.
85+
86+
> Launch **BEAUTi**
87+
> At the top menu, select **File > Manage** packages.
88+
> Select MultiTypeTree in the package list.
89+
> Select **INstall/Upgrade** from the botom menu Figure [1](#fig:install_mtt).
90+
> Restart BEAUTi
8591
8692
<figure>
8793
<a id="fig:install_mtt"></a>
88-
<img style="width:50.0%;" src="figures/install_mtt.png" alt="">
94+
<img src="figures/install_mtt.png" alt="">
8995
<figcaption>Figure 1: Install MultiTypeTree.</figcaption>
9096
</figure>
9197
<br>
9298

9399

94-
To be able to make `.xml`'s for MultiTypeTree, we have to load the MultiTypeTree template `File > Template > MultiTypeTree`. This template allows to specify additional things, such as sampling location, which one can not specify using the standard interface, as well as parameters such as the migration rates.
95-
After setting the template, we can load the alignment of the H3N2 data `File > Add Alignment`.
96-
Since the sequences were sampled through time, we have to specify the sampling dates. These are included in the sequence names. To set the sampling dates, go to **Tip Dates**, guess them by splitting after the "_" and then choose the last group. There are two different ways in how BEAST can interpret sampling dates. They are labeled as **Since some time in the past** and **Before the present**. The easiest way to check if you have used the correct one is by checking `Height`. If the setup is correct, the sequences sampled the most recently (i.e. 2005.66) should have a Height of 0 while all other tips should be larger then 0 (Figure [2](#fig:sampling_dates)).
100+
To be able to make `.xml`'s for MultiTypeTree, we have to load the MultiTypeTree template.
101+
102+
> At the top menu in BEAUTi select **File > Template > MultiTypeTree**.
103+
104+
This template allows to specify additional things, such as sampling location, which one can not specify using the standard interface, as well as parameters such as the migration rates.
105+
After setting the template, we can load the alignment of the H3N2 data.
106+
107+
> At the top menu in BEAUti select **File > Add Alignment**.
108+
> Navigate to the location where you have saved the file **h3n2_2deme.fna**.
109+
> Select the file and click **OK**.
110+
111+
Since the sequences were sampled through time, we have to specify the sampling dates. These are included in the sequence names.
112+
113+
> Switch to **Tip Dates** tab.
114+
> Check the **Use tip dates** checkbox.
115+
> Click **Auto-configure**.
116+
> Select **use everything > after last** and leave symbol as **"_"**.
117+
118+
There are two different ways in how BEAST can interpret sampling dates. They are labeled as **Since some time in the past** and **Before the present**. The easiest way to check if you have used the correct one is by checking `Height`. If the setup is correct, the sequences sampled the most recently (i.e. 2005.66) should have a Height of 0 while all other tips should be larger then 0 (Figure [2](#fig:sampling_dates)).
97119

98120
<figure>
99121
<a id="fig:sampling_dates"></a>
@@ -103,7 +125,13 @@ Since the sequences were sampled through time, we have to specify the sampling d
103125
<br>
104126

105127

106-
The main contrast in the setup to previous analyses is that we include additional information about the sampling location of sequences. Sequences were taken from patients in Hong Kong and New Zealand. We can specify these sampling locations by going to **Tip Locations** in BEAUti and guessing the locations. Use here the second group after splitting the names on the character "_". After guessing the tip locations, the column **Location** should contain the entries Hong Kong and New Zealand (Figure [3](#fig:sampling_locations)).
128+
Since out population structure is defined geographically, we include additional information about the sampling location of sequences. Sequences were taken from patients in Hong Kong and New Zealand. We can specify these sampling locations:
129+
130+
> Switch to **Tip Locations** tab in BEAUti
131+
> Select **Guess**
132+
> Select **split on character", leave the character as "_" and take group 2
133+
134+
After guessing the tip locations, the column **Location** should contain the entries Hong Kong and New Zealand (Figure [3](#fig:sampling_locations)).
107135

108136
<figure>
109137
<a id="fig:sampling_locations"></a>
@@ -115,7 +143,12 @@ The main contrast in the setup to previous analyses is that we include additiona
115143

116144
For this analysis, we will be using the HKY model. The HKY model infers different rates for transversion and transition. Transition being the change within purines (**A** and **G**) and pyrimidines (**T** and **C**) and transversion being the change among those groups.
117145

118-
We also want to allow for heterogeneity between sites, which we can do by setting the **Gamma Category Count** to a value greater than 0 (normally between 4 and 6) and ticking the **estimate** box for the shape parameter (Figure [4](#fig:hky)).
146+
We also want to allow for heterogeneity between sites, which we can do by setting the **Gamma Category Count** to a value greater than 0 (normally between 4 and 6) and estimating the shape parameter (Figure [4](#fig:hky)).
147+
148+
> Switch to **Site Model** tab in BEAUTi.
149+
> Set **Gamma Category Count** to 4, leave **Shape** as 1.0 and **estimate** checkbox selected.
150+
> Select **HKY** as **Subst Model**, make sure **estimate** checkbox is selected.
151+
119152

120153
<figure>
121154
<a id="fig:hky"></a>
@@ -128,11 +161,17 @@ We also want to allow for heterogeneity between sites, which we can do by settin
128161

129162
To speed up convergence, we leave the branch model on the Strict Clock model and set a different value for the clock rate (default is 1). A value of 0.005 substitutions * site^(-1) * year^(-1) is closer to the truth.
130163

164+
> Switch to **Clock Model** tab in BEAUTi
165+
> set value as 0.005
166+
131167

132168
Since we have more than one deme (Hong Kong and New Zealand), we can estimate the effective population size of those two demes separately. Additionally, these demes are connected, so we can (or need to) allow for migration between them.
133-
By default, the migration rates and population sizes are not estimated. To change this, we have to go to the Priors setting. There, we have to check the two **estimate** boxes for the population sizes and the migration rates.
169+
By default, the migration rates and population sizes are not estimated, we will change this.
134170

135-
171+
> Switch to **Priors** tab in BEAUTi
172+
> Expand **structuredCoalescent** line.
173+
> Check the two boxes for the **estimate pop. sizes** and **estimate mig. rates**.
174+
> Now two more parameter priors appear. For **rateMatrix** select **Exponential** prior.
136175
137176

138177
After checking those two boxes, there will be two new fields appearing, where we can set the priors for the population sizes and the migration rates.
@@ -149,7 +188,10 @@ Figure [5](#fig:est_migrates) shows the final setup for the priors.
149188

150189

151190

152-
The rest of the settings we can leave as they are.
191+
The rest of the settings we can leave as they are. Save your XML in order to run in BEAST2.
192+
193+
> In BEAUTi top menu, select **File > save** and choose your preferred location.
194+
> Launch BEAST2 and use the saved XML to start the run.
153195
154196
After saving, we get an `*.xml`, which we can use in BEAST2. The run will take a bit of time. If the MultiTypeTree run consumes too much CPU power, you can just close it and then use the "pre-cooked" `*.log` and `*.trees` files later instead.
155197

@@ -163,7 +205,7 @@ Next, we can have a look at the estimates of the effective population sizes (Fig
163205

164206
<figure>
165207
<a id="fig:estimated_peff"></a>
166-
<img style="width:60.0%;" src="figures/effectivePsize_tracer.png" alt="">
208+
<img src="figures/effectivePsize_tracer.png" alt="">
167209
<figcaption>Figure 6: Estimated effective population sizes.</figcaption>
168210
</figure>
169211
<br>
@@ -174,7 +216,7 @@ Hong Kong ({% eqinline \sim %}7 Mio Inhabitants) is inferred to have the larger
174216

175217
<figure>
176218
<a id="fig:etimated_mig"></a>
177-
<img style="width:60.0%;" src="figures/migrationrates_tracer.png" alt="">
219+
<img src="figures/migrationrates_tracer.png" alt="">
178220
<figcaption>Figure 7: Estimated migration rates.</figcaption>
179221
</figure>
180222
<br>

figures/choose_hky.png

485 KB
Loading

figures/dates.png

730 KB
Loading

figures/effectivePsize_tracer.png

763 KB
Loading

figures/estimate_migration.png

681 KB
Loading

figures/figtree_color.png

514 KB
Loading

figures/figtree_nodeheights.png

512 KB
Loading

figures/install_mtt.png

680 KB
Loading

figures/locations.png

581 KB
Loading

figures/migrationrates_tracer.png

755 KB
Loading

0 commit comments

Comments
 (0)