Created
August 20, 2019 16:34
-
-
Save explodecomputer/557f4a8fdac4abc92ddd8b1dc77a9789 to your computer and use it in GitHub Desktop.
Merged SNP HWE
This file contains hidden or 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
maf <- function(x) { sum(x) / (length(x) * 2)} | |
hwe <- function(x) { | |
observed <- table(x) | |
m <- maf(x) | |
expected <- c( | |
(1-m)^2, 2 * m * (1-m), m^2 | |
) * length(x) | |
chisq.test(rbind(observed, round(expected))) | |
print(rbind(observed, round(expected))) | |
} | |
deletion <- rbinom(100000, 2, 0.123) | |
variant <- rbinom(100000, 2, 0.039) | |
probe <- | |
abscaled <- round(ab / 2) | |
abscaled <- round(ab) | |
ab <- a | |
ab[b == 2] <- 0 | |
ab[b == 1] <- a[b == 1] * 0.5 | |
ab <- round(ab) | |
maf(a) | |
maf(b) | |
maf(ab) | |
hwe(a) | |
hwe(b) | |
hwe(ab) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment