Skip to content

Commit

Permalink
Merge pull request #67 from NBISweden/dev-percyfal
Browse files Browse the repository at this point in the history
  • Loading branch information
percyfal authored Oct 24, 2023
2 parents b1b1f72 + d79e4d6 commit fe96b6b
Showing 1 changed file with 279 additions and 1 deletion.
280 changes: 279 additions & 1 deletion docs/slides/foundations/index.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -2334,7 +2334,285 @@ floating up and down at random.

:::

## Allele frequency distribution for
## Allele frequency distribution for N=1

Instead of looking at frequencies let's switch to distributions of
alleles for **one** individual, one locus. Then there are three
possible genotypes (**states**) $aa$, $aA$, and $AA$. Let $n=0,1,2$ be
an integer corresponding to each genotype (i.e., it counts the number
of $A$ alleles).

Assume individual mates with itself at random(!) starting in either of
the three states. How does distribution evolve?

:::: {.columns .fragment fragment-index=1}

::: {.column width="10%"}

t=0

:::

::: {.column width="30%"}

```{r, engine='tikz', fig.ext="svg"}
#| label: tikz-afd-aa
#| echo: false
#| eval: true
#| out-width: 200px
\begin{tikzpicture}[ybar interval]
\tikzstyle{tick}=[font=\scriptsize];
\tikzstyle{label}=[font=\small];
\draw[fill=black, draw=black]
plot coordinates{(0,1) (1,0) (2, 0) (3, 0)};
\node[label] (aa) at (0.5, 1.8) {aa};
\node[label] (Aa) at (1.5, 1.8) {Aa};
\node[label] (AA) at (2.5, 1.8) {AA};
\node[label] (0) at (0.5, 1.4) {0};
\node[label] (1) at (1.5, 1.4) {1};
\node[label] (2) at (2.5, 1.4) {2};
\draw[->] (0, -0.2) -- (0, 1.2);
\draw (-0.1, 1) -- (0.1, 1);
\draw (-0.1, 0) -- (0.1, 0);
\node[tick] at (-0.4, 1) {1};
\node[tick] at (-0.4, 0) {0};
\end{tikzpicture}
```

:::

::: {.column width="30%"}

```{r, engine='tikz', fig.ext="svg"}
#| label: tikz-afd-aA
#| echo: false
#| eval: true
#| out-width: 200px
\begin{tikzpicture}[ybar interval]
\tikzstyle{tick}=[font=\scriptsize];
\tikzstyle{label}=[font=\small];
\draw[fill=black, draw=black]
plot coordinates{(0,0) (1,1) (2, 0) (3, 0)};
\node[label] (aa) at (0.5, 1.8) {aa};
\node[label] (aA) at (1.5, 1.8) {aA};
\node[label] (AA) at (2.5, 1.8) {AA};
\node[label] (0) at (0.5, 1.4) {0};
\node[label] (1) at (1.5, 1.4) {1};
\node[label] (2) at (2.5, 1.4) {2};
\draw[->] (0, -0.2) -- (0, 1.2);
\draw (-0.1, 1) -- (0.1, 1);
\draw (-0.1, 0) -- (0.1, 0);
\node[tick] at (-0.4, 1) {1};
\node[tick] at (-0.4, 0) {0};
\end{tikzpicture}
```

:::

::: {.column width="30%"}

```{r, engine='tikz', fig.ext="svg"}
#| label: tikz-afd-AA
#| echo: false
#| eval: true
#| out-width: 200px
\begin{tikzpicture}[ybar interval]
\tikzstyle{tick}=[font=\scriptsize];
\tikzstyle{label}=[font=\small];
\draw[fill=black, draw=black]
plot coordinates{(0,0) (1,0) (2, 1) (3, 1)};
\node[label] (aa) at (0.5, 1.8) {aa};
\node[label] (aA) at (1.5, 1.8) {aA};
\node[label] (AA) at (2.5, 1.8) {AA};
\node[label] (0) at (0.5, 1.4) {0};
\node[label] (1) at (1.5, 1.4) {1};
\node[label] (2) at (2.5, 1.4) {2};
\draw[->] (0, -0.2) -- (0, 1.2);
\draw (-0.1, 1) -- (0.1, 1);
\draw (-0.1, 0) -- (0.1, 0);
\node[tick] at (-0.4, 1) {1};
\node[tick] at (-0.4, 0) {0};
\end{tikzpicture}
```

:::

::::

:::::{.translatey50}

:::: {.columns}

::: {.column width="10%"}

::: {.fragment fragment-index=2}

t=1

:::

:::

::: {.column width="30%"}

::: {.fragment fragment-index=2}

```{r, engine='tikz', fig.ext="svg"}
#| label: tikz-afd-aa-1
#| echo: false
#| eval: true
#| out-width: 200px
\begin{tikzpicture}[ybar interval]
\tikzstyle{tick}=[font=\scriptsize];
\tikzstyle{label}=[font=\small];
\draw[fill=black, draw=black]
plot coordinates{(0,1) (1,0) (2, 0) (3, 0)};
\draw[->] (0, -0.2) -- (0, 1.2);
\draw (-0.1, 1) -- (0.1, 1);
\draw (-0.1, 0) -- (0.1, 0);
\node[tick] at (-0.4, 1) {1};
\node[tick] at (-0.4, 0) {0};
\end{tikzpicture}
```

:::

:::

::: {.column width="30%"}

::: {.fragment fragment-index=4}

```{r, engine='tikz', fig.ext="svg"}
#| label: tikz-afd-aA-1
#| echo: false
#| eval: true
#| out-width: 200px
\begin{tikzpicture}[ybar interval]
\tikzstyle{tick}=[font=\scriptsize];
\tikzstyle{label}=[font=\small];
\draw[fill=black, draw=black]
plot coordinates{(0,0.25) (1,0.5) (2, 0.25) (3, 0.25)};
\draw[->] (0, -0.2) -- (0, 1.2);
\draw (-0.1, 1) -- (0.1, 1);
\draw (-0.1, 0) -- (0.1, 0);
\node[tick] at (-0.4, 1) {1};
\node[tick] at (-0.4, 0) {0};
\end{tikzpicture}
```

:::

:::

::: {.column width="30%"}

::: {.fragment fragment-index=3}

```{r, engine='tikz', fig.ext="svg"}
#| label: tikz-afd-AA-1
#| echo: false
#| eval: true
#| out-width: 200px
\begin{tikzpicture}[ybar interval]
\tikzstyle{tick}=[font=\scriptsize];
\tikzstyle{label}=[font=\small];
\draw[fill=black, draw=black]
plot coordinates{(0,0) (1,0) (2, 1) (3, 1)};
\draw[->] (0, -0.2) -- (0, 1.2);
\draw (-0.1, 1) -- (0.1, 1);
\draw (-0.1, 0) -- (0.1, 0);
\node[tick] at (-0.4, 1) {1};
\node[tick] at (-0.4, 0) {0};
\end{tikzpicture}
```

:::

:::

::::

:::::

:::::{.translatey100}

:::: {.columns}

::: {.column width="10%"}

::: {.fragment fragment-index=5}

t=2

:::

:::

::: {.column width="30%"}

:::

::: {.column width="30%"}

::: {.fragment fragment-index=5}

```{r, engine='tikz', fig.ext="svg"}
#| label: tikz-afd-aA-2
#| echo: false
#| eval: true
#| out-width: 200px
\begin{tikzpicture}[ybar interval]
\tikzstyle{tick}=[font=\scriptsize];
\tikzstyle{label}=[font=\small];
\draw[fill=black, draw=black]
plot coordinates{(0,0.375) (1,0.25) (2, 0.375) (3, 0.25)};
\draw[->] (0, -0.2) -- (0, 1.2);
\draw (-0.1, 1) -- (0.1, 1);
\draw (-0.1, 0) -- (0.1, 0);
\node[tick] at (-0.4, 1) {1};
\node[tick] at (-0.4, 0) {0};
\end{tikzpicture}
```

:::

:::

::: {.column width="30%"}

:::

::::

:::::

::: {.notes}

Example from [@gillespie_PopulationGeneticsConcise_2004, p. 24]. We
look at a single hermaphroditic individual that mates with itself at
random. For each generation, given a genotype distribution, we
calculate the outcome for the next generation. For instance, starting
out in state 0 (only $aa$ genotypes, hence only $a$ alleles), we can
only produce new $aa$ genotypes and will therefore never leave
state 0. The same holds for state 2. These states are *absorbing
states*.

Starting from state 1 ($aA$) we can get $aa$ genotype with 25%
probability, since the probability of picking one $a$ is 50%, and we
perform two draws. Similarly, we get $AA$ with 25% probability,
leaving 50% to $aA$.

In the next generation, the $aA$ genotype frequency is 0.5, to be
split in fractions 0.25, 0.5, 0.25 as before, and so on.

To study the system we therefore need to enumerate the probabilistic
outcomes from each state ($aa$ -> 1, 0, 0, $aA$ -> 0.25, 0.5, 0.25,
$AA$ <- 0, 0, 1). To get the state in next generation, we multiply the
current distribution with these outcomes. The next slide gives
Kimura's example for the case where we have N=10 chromosomes.

:::

## Probability distributions of allele frequencies

Expand Down

0 comments on commit fe96b6b

Please sign in to comment.