Skip to content

Instantly share code, notes, and snippets.

@GabrielHoffman
Last active June 10, 2024 19:58
Show Gist options
  • Save GabrielHoffman/529e61c203554a547b144ec2856cc8e8 to your computer and use it in GitHub Desktop.
Save GabrielHoffman/529e61c203554a547b144ec2856cc8e8 to your computer and use it in GitHub Desktop.
Evaluate all variants for eQTL analysis
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