Last active
October 6, 2021 19:08
-
-
Save jonesor/866310a5b334e3e1fcb2659ac8e2c0de to your computer and use it in GitHub Desktop.
A de Finetti diagram showing Hardy-Weinberg Equilibrium
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# de Finetti diagram | |
library(dplyr) | |
library(ggplot2) | |
library(ggtern) | |
library(magrittr) | |
HWEfrequencies <- data.frame( | |
p = seq(0, 1, 0.01) | |
) %>% | |
mutate(q = 1 - p) %>% | |
mutate(AA = p^2, Aa = 2 * p * q, aa = q^2) | |
ggtern( | |
data = HWEfrequencies, | |
aes(x = AA, y = Aa, z = aa) | |
) + geom_line(size = 1) + | |
labs( | |
x = "aa (%)", y = "Aa (%)", z = "AA (%)", | |
title = "Hardy-Weinberg Equilibrium", | |
subtitle = "de Finetti diagram" | |
) + | |
theme_bvbw() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment