In this tutorial, we demonstrate how to use Bayes.GLMM in a genome-wide association analysis using ADSP data as an example. In ADSP, whole genome sequences (WGS) results of 576 individuals from 111 families were collected. Each individual was diagnosed with one of the four AD levels: no (80), possible (81), probable (360), and definite (55). Additional sample information includes family pedigree, race, ethnicity, age, sex, and APOE e2/e3/e4 genotypes.

library(rstan)
library(bayes.glmm)

Example

data("sample", package = "bayes.glmm")

pheno = data$pheno
geno = data$geno
cov = data$cov
L <- t(chol(data$K))

# package data
# myglm = stan_model("~/GitHub/bayes.glmm/inst/extdata/glm.stan")
# save(myglm, file = "~/GitHub/bayes.glmm/inst/extdata/glm.rdt")
# myglmm = stan_model("~/GitHub/bayes.glmm/inst/extdata/glmm.stan")
# save(myglmm, file = "~/GitHub/bayes.glmm/inst/extdata/glmm.rdt")

# dt0 = list(N = 576, K = 4, D = 2, cov = cov, L = L, pheno = pheno)
# dt0$geno = rep(0, 576)
# dt0$prior_non = 1
# dt0$prior_inf = 0
# y1 = optimizing(myglm, data = dt0)
# y2 = sampling(myglm, data = dt0, chains = 3, cores = 3)
# y2 = sampling(myglm, data = dt0, chains = 3, cores = 3, pars = pId, control = list(adapt_delta = .9))

# use bayes.glmm function
mymodel = stan_models(model = "glm")

y1 = myGWAS_fit(model = mymodel, method = "optimizing", type = "categorical", cov = cov, geno = geno[c(1, 3), ], pheno = pheno)
y1

y2 = myGWAS_fit(model = mymodel, method = "sampling", type = "categorical", cov = cov, geno = geno[c(1, 3), ], pheno = pheno)
y2


xulong82/bayes.glmm documentation built on May 4, 2019, 1:27 p.m.