Created
October 15, 2021 08:54
-
-
Save explodecomputer/3dac83a0925d1600b2a82b75c350190c to your computer and use it in GitHub Desktop.
Huntington's disease protector alleles
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
# Model of control-only Huntington's disease analysis | |
# If you have some CAG expansion cases who are non-symptomatic then what distinguishes them from non expansion individuals? | |
# This script shows the analysis is akin to an interaction analysis | |
library(dplyr) | |
n <- 1000000 | |
cag <- rpois(n, 2) | |
mod <- rbinom(n, 2, 0.4) - 1 | |
d <- rep(0, n) | |
d[cag > 5] <- 1 | |
d[cag > 5] <- rbinom(sum(cag > 5), 1, plogis(mod[cag > 5])) | |
table(d) | |
summary(lm(d ~ cag * mod)) | |
tapply(d[cag>5], mod[cag>5], mean) | |
dat <- tibble(d, cag, mod, rep=as.numeric(cag>5)) | |
summary(glm(rep ~ mod, data=dat, family="binomial", subset=dat$d == 0)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment