Last active
June 10, 2024 19:58
-
-
Save GabrielHoffman/529e61c203554a547b144ec2856cc8e8 to your computer and use it in GitHub Desktop.
Evaluate all variants for eQTL analysis
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
library(lme4) | |
set.seed(101) | |
dd <- expand.grid(f1 = factor(1:10), | |
f2 = LETTERS[1:20], g=1:20, rep=1:15, | |
KEEP.OUT.ATTRS=FALSE) | |
summary(mu <- 5*(-4 + with(dd, as.integer(f1) + 4*as.numeric(f2)))) | |
dd$y <- rnbinom(nrow(dd), mu = mu, size = 0.5) | |
str(dd) | |
require("MASS") | |
# estimate parameters and theta | |
fit <- glmer.nb(y ~ f1*f2 + (1|g), data=dd) | |
# get theta from NB fit | |
theta.hat = lme4:::getNBdisp(fit)) | |
# fit with fixed theta | |
fit2 = glmer(y ~ f1*f2 + (1|g), | |
data = dd, | |
family = negative.binomial(theta.hat)) | |
fit1 = lm(y ~ SNP1) | |
fit2 = lm(y ~ SNP2) | |
cor(z1, z2) = cor(SNP1, SNP2) | |
fit1 = lm(y ~ SNP1 + time + SNP1:time) | |
fit2 = lm(y ~ SNP2 + time + SNP2:time) | |
cor(z1, z2) = f(SNP1, SNP2, time) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment