Skip to content

Commit 5d82a5e

Browse files
committed
second draft sheet 10
1 parent c15ec5a commit 5d82a5e

File tree

11 files changed

+198
-19
lines changed

11 files changed

+198
-19
lines changed

bioinf-style.css

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,3 +211,17 @@ pre {
211211
height: 1em;
212212
margin-right: 0.2em;
213213
}
214+
215+
.half {
216+
margin: 0px 10px 20px 10px;
217+
}
218+
219+
.flex-container {
220+
display: flex;
221+
}
222+
223+
@media only screen and (max-width: 600px) {
224+
.flex-container {
225+
display: block;
226+
}
227+
}

exercise-sheet-10.Rmd

Lines changed: 144 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ title: "Exercise sheet 10: UPGMA"
44

55
---------------------------------
66

7+
```{r, include=FALSE}
8+
source("custom_functions.R")
9+
library(flextable)
10+
library(officer)
11+
```
12+
713
::::{#img1-p .extra-m}
814
::: {#img3 .tutorial-img}
915

@@ -50,7 +56,12 @@ $$
5056

5157
In the following steps we calculate the evolutionary tree using WPGMA and the pairwise distances in the following distance matrix.
5258

53-
!!! MATRIX MISSING !!!
59+
```{r, results="asis", include=knitr::is_html_output(), echo=FALSE}
60+
sij <- read.csv("tables/sheet10_e1.csv", check.names=FALSE, sep=";")
61+
sij_ft <- flextable(sij)
62+
sij_ft <- custom_theme(sij_ft)
63+
index_replace(sij_ft)
64+
```
5465

5566
### 1a)
5667

@@ -99,11 +110,16 @@ Fill in the distance matrix with the correct distances form the set of leaves
99110

100111
##### Hide
101112

102-
##### Hint : Formulae
103-
104113

105114
##### Solution
106115

116+
```{r, results="asis", include=knitr::is_html_output(), echo=FALSE}
117+
sij <- read.csv("tables/sheet10_e1c.csv", check.names=FALSE, sep=";")
118+
sij_ft <- flextable(sij)
119+
sij_ft <- custom_theme(sij_ft)
120+
index_replace(sij_ft)
121+
```
122+
107123

108124
#### {-}
109125

@@ -143,39 +159,63 @@ Fill in a distance matrix with the remaining nodes and leaves.
143159

144160
##### Hide
145161

146-
##### Hint
147162

148163
##### Solution
149164

165+
```{r, results="asis", include=knitr::is_html_output(), echo=FALSE}
166+
sij <- read.csv("tables/sheet10_e1e.csv", check.names=FALSE, sep=";")
167+
sij_ft <- flextable(sij)
168+
sij_ft <- custom_theme(sij_ft)
169+
index_replace(sij_ft)
170+
```
171+
150172
#### {-}
151173

152174
### 1f)
153175

154176
What does the **subpart** of the tree look like in Newick format after selecting and joining your answer from *e)*
155177

178+
:::: {#explaining .message-box }
179+
180+
::: {#note-exp .note-header}
181+
```{r, include=knitr::is_html_output(), echo=FALSE,}
182+
knitr::include_graphics("figures/infoicon.svg")
183+
```
184+
**Note**
185+
:::
186+
::: {#note-exp .note-body}
187+
188+
The following answers will be given in [Newick format](https://en.wikipedia.org/wiki/Newick_format).
189+
Feel free to inspect them using an [online tool](http://www.trex.uqam.ca/index.php?action=newick&project=trex).
190+
191+
:::
192+
::::
193+
156194
#### {.tabset}
157195

158196

159197
##### Hide
160198

161199
##### Hint
162200

163-
- [ ] ((c : 3, d : 3) : 3.5, e : 3.5)
164-
- [ ] ((c : 3, d : 3) : 0.5, e : 3.5)
165-
- [ ] ((a : 1.5, b : 1.5) : 2.75, e : 4.25)
201+
- [ ] `((c : 3, d : 3) : 3.5, e : 3.5);`
202+
- [ ] `((c : 3, d : 3) : 0.5, e : 3.5);`
203+
- [ ] `((a : 1.5, b : 1.5) : 2.75, e : 4.25);`
166204

167-
- [ ] ((c : 3, d : 3) : 3.5, e : 3.5)
168-
- [x] ((c : 3, d : 3) : 0.5, e : 3.5)
169-
- [ ] ((a : 1.5, b : 1.5) : 2.75, e : 4.25)
170205

171206
##### Solution
172207

208+
- [ ] `((c : 3, d : 3) : 3.5, e : 3.5);`
209+
- [x] `((c : 3, d : 3) : 0.5, e : 3.5);`
210+
- [ ] `((a : 1.5, b : 1.5) : 2.75, e : 4.25);`
211+
173212
#### {-}
174213

175-
### 1f)
214+
### 1g)
176215

177216
Following the approach from the previous exercises, what does the **whole tree** look like.
178217

218+
179219
#### {.tabset}
180220

181221

@@ -184,15 +224,16 @@ Following the approach from the previous exercises, what does the **whole tree**
184224

185225
##### Hint
186226

187-
- [ ] ((a : 1.5, b : 1.5) : 4, ((c : 3, d : 3) : 0.5, e : 3.5) : 2);
188-
- [ ] ((a : 1.5, b : 1.5) : 4.25, ((c : 3, d : 3) : 0.5, e : 3.5) : 2.25);
189-
- [ ] (((c : 3, d : 3) : 3.5, e : 3.5): 4, (a : 1.5, b : 1.5) : 2);
227+
- [ ] `((a : 1.5, b : 1.5) : 4, ((c : 3, d : 3) : 0.5, e : 3.5) : 2);`
228+
- [ ] `((a : 1.5, b : 1.5) : 4.25, ((c : 3, d : 3) : 0.5, e : 3.5) : 2.25);`
229+
- [ ] `(((c : 3, d : 3) : 3.5, e : 3.5): 4, (a : 1.5, b : 1.5) : 2);`
190230

191231
##### Solution
192232

193-
- [x] ((a : 1.5, b : 1.5) : 4, ((c : 3, d : 3) : 0.5, e : 3.5) : 2);
194-
- [ ] ((a : 1.5, b : 1.5) : 4.25, ((c : 3, d : 3) : 0.5, e : 3.5) : 2.25);
195-
- [ ] (((c : 3, d : 3) : 3.5, e : 3.5): 4, (a : 1.5, b : 1.5) : 2);
233+
- [x] `((a : 1.5, b : 1.5) : 4, ((c : 3, d : 3) : 0.5, e : 3.5) : 2);`
234+
- [ ] `((a : 1.5, b : 1.5) : 4.25, ((c : 3, d : 3) : 0.5, e : 3.5) : 2.25);`
235+
- [ ] `(((c : 3, d : 3) : 3.5, e : 3.5): 4, (a : 1.5, b : 1.5) : 2);`
236+
196237

197238
#### {-}
198239

@@ -215,6 +256,12 @@ Imagine using UPGMA instead of WPGMA for construction of a tree. Which of the fo
215256
- [ ] UPGMA is equal to WPGMA if the number of leaves in the two clusters (|c| and |d|) is the same.
216257
- [ ] UPGMA can end up with wrong topologies when using non-ultrametric distances.
217258

259+
##### Hint: Formula
260+
261+
$$
262+
UPGMA: dist(x, e) = \dfrac{|c|dist(x,c) + |d|dist(x,d)}{|c| + |d|}
263+
$$
264+
218265

219266
##### Solution
220267

@@ -236,15 +283,94 @@ Imagine using UPGMA instead of WPGMA for construction of a tree. Which of the fo
236283

237284
Which of the following distance matrices are ultrametric?
238285

239-
!!MISSING!!
286+
287+
:::: {.flex-container}
288+
289+
::: {#half .half}
290+
291+
1)
292+
```{r, results="asis", include=knitr::is_html_output(), echo=FALSE}
293+
sij <- read.csv("tables/sheet10_e3_1.csv", check.names=FALSE, sep=";")
294+
sij_ft <- flextable(sij)
295+
sij_ft <- custom_theme(sij_ft)
296+
index_replace(sij_ft)
297+
```
298+
299+
:::
300+
301+
::: {#half .half}
302+
303+
2)
304+
```{r, results="asis", include=knitr::is_html_output(), echo=FALSE}
305+
sij <- read.csv("tables/sheet10_e3_2.csv", check.names=FALSE, sep=";")
306+
sij_ft <- flextable(sij)
307+
sij_ft <- custom_theme(sij_ft)
308+
index_replace(sij_ft)
309+
```
310+
311+
:::
312+
313+
::::
314+
315+
:::: {.flex-container}
316+
317+
318+
::: {#half .half}
319+
320+
3)
321+
```{r, results="asis", include=knitr::is_html_output(), echo=FALSE}
322+
sij <- read.csv("tables/sheet10_e3_3.csv", check.names=FALSE, sep=";")
323+
sij_ft <- flextable(sij)
324+
sij_ft <- custom_theme(sij_ft)
325+
index_replace(sij_ft)
326+
```
327+
328+
:::
329+
330+
::: {#half .half}
331+
332+
4)
333+
```{r, results="asis", include=knitr::is_html_output(), echo=FALSE}
334+
sij <- read.csv("tables/sheet10_e3_4.csv", check.names=FALSE, sep=";")
335+
sij_ft <- flextable(sij)
336+
sij_ft <- custom_theme(sij_ft)
337+
index_replace(sij_ft)
338+
```
339+
340+
:::
341+
342+
::::
240343

241344
#### {.tabset}
242345

243346
##### Hide
244347

348+
##### Hint
349+
350+
:::: {#explaining .message-box }
351+
::: {#note-exp .note-header}
352+
```{r, include=knitr::is_html_output(), echo=FALSE,}
353+
knitr::include_graphics("figures/infoicon.svg")
354+
```
355+
**Note**
356+
:::
357+
::: {#note-exp .note-body}
358+
359+
Definition Ultra-Metric:
360+
361+
\begin{align}
362+
w(x,y) &= 0 \leftrightarrow x = y\ &\text{(identity)}\\
363+
w(x, y) &= w(y, x)\ &\text{(symmetric)}\\
364+
w (x, z) &\leq w (x, y ) + w (y , z) &\text{(triangle inequality)}\\
365+
w (x, z) &\leq max\{ w (x, y ), w (y , z)\} &\text{(strong triangle inequality)}
366+
\end{align}
367+
368+
:::
369+
::::
245370

246371
##### Solution
247372

373+
**2)**
248374

249375

250376
#### {-}

exercise-sheet-7.Rmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ See Question 1B
170170

171171

172172
\begin{align}
173-
\lim \limits_{x \to \infty} P^t &=
173+
\lim \limits_{t \to \infty} P^t &=
174174
\begin{pmatrix}
175175
0.339 & 0.371 & 0.290\\
176176
0.339 & 0.371 & 0.290\\

tables/sheet10_e1.csv

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
D_{i,j};a;b;c;d;e
2+
a;0;3;12;12;9
3+
b; ;0;13;13;10
4+
c; ; ;0;6;7
5+
d; ; ; ;0;7
6+
e; ; ; ; ;0

tables/sheet10_e1c.csv

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
D_{i,j};{ab};c;d;e
2+
"{a,b}";0;12.5;12.5;9.5
3+
c; ;0;6;7
4+
d; ; ;0;7
5+
e; ; ; ;0

tables/sheet10_e1e.csv

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
D_{i,j};{ab};{c,d};e
2+
"{a,b}";0;12.5;9.5
3+
{c,d}; ;0;7
4+
e; ; ;0

tables/sheet10_e3.csv

Whitespace-only changes.

tables/sheet10_e3_1.csv

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
D_{i,j};a;b;c;d;e
2+
a;0;3;12;12;9
3+
b; ;0;13;13;10
4+
c; ; ;0;6;7
5+
d; ; ; ;0;7
6+
e; ; ; ; ;0

tables/sheet10_e3_2.csv

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
D_{i,j};a;b;c;d;e
2+
a;0;2;4;6;8
3+
b; ;0;4;6;8
4+
c; ; ;0;6;8
5+
d; ; ; ;0;8
6+
e; ; ; ; ;0

tables/sheet10_e3_3.csv

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
D_{i,j};a;b;c;d;e
2+
a;0;10;17;16;16
3+
b; ;0;15;14;14
4+
c; ; ;0;9;15
5+
d; ; ; ;0;14
6+
e; ; ; ; ;0

0 commit comments

Comments
 (0)