Simulate nrep marginal Z-scores from joint Z-scores and convert these to posterior probabilities of causality

zj_pp(Zj, V, nrep = 1000, W = 0.2, Sigma)

Arguments

Zj

Vector of joint Z-scores (0s except at CV)

V

Variance of the estimated effect size (can be obtained using Var.beta.cc function)

nrep

Number of posterior probability systems to simulate (default 1000)

W

Prior for the standard deviation of the effect size parameter, beta (default 0.2)

Sigma

SNP correlation matrix

Value

Matrix of simulated posterior probabilties, one simulation per row

Details

Does not include posterior probabilities for null model

Examples

set.seed(1) nsnps <- 100 Zj <- rep(0, nsnps) iCV <- 4 # index of CV mu <- 5 # true effect at CV Zj[iCV] <- mu ## generate example LD matrix and MAFs library(mvtnorm) nsamples = 1000 simx <- function(nsnps, nsamples, S, maf=0.1) { mu <- rep(0,nsnps) rawvars <- rmvnorm(n=nsamples, mean=mu, sigma=S) pvars <- pnorm(rawvars) x <- qbinom(1-pvars, 1, maf) } S <- (1 - (abs(outer(1:nsnps,1:nsnps,`-`))/nsnps))^4 X <- simx(nsnps,nsamples,S) LD <- cor2(X) maf <- colMeans(X) ## generate V (variance of estimated effect sizes) varbeta <- Var.data.cc(f = maf, N = 5000, s = 0.5) res <- zj_pp(Zj, V = varbeta, nrep = 5, W = 0.2, Sigma = LD) res[c(1:5), c(1:5)]
#> [,1] [,2] [,3] [,4] [,5] #> [1,] 0.0116184284 1.070683e-02 0.007712446 0.93606227 0.0193099822 #> [2,] 0.1982476555 1.648822e-02 0.685335004 0.09911824 0.0007246623 #> [3,] 0.0003395254 4.096679e-04 0.003801747 0.94352560 0.0316109719 #> [4,] 0.0014649997 5.911848e-05 0.001070014 0.99716789 0.0002193873 #> [5,] 0.0037845944 5.557921e-03 0.004444873 0.89103578 0.0087604499