Posterior probabilities of causality from marginal Z-scores

ppfunc(z, V, W = 0.2)

Arguments

z

Vector of marginal Z-scores

V

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

W

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

Value

Vector of posterior probabilities

Details

This function converts Z-scores to posterior probabilities of causality i.e. not including the null model of no genetic effects, so that the sum of the posterior probabilities for all variants is 1

Examples

set.seed(1) nsnps = 100 N0 = 5000 N1 = 5000 z_scores <- rnorm(nsnps, 0, 3) ## 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) maf <- colMeans(X) varbeta <- Var.data.cc(f = maf, N = N0+N1, s = N1/(N0+N1)) res <- ppfunc(z = z_scores, V = varbeta) sum(res)
#> [1] 1
res
#> [1] 1.215824e-10 2.631593e-11 4.426841e-10 1.068425e-06 3.646599e-11 #> [6] 3.907039e-10 5.990011e-11 2.225321e-10 9.103733e-11 3.354997e-11 #> [11] 3.654523e-07 4.079658e-11 1.142769e-10 2.433182e-02 4.793560e-09 #> [16] 2.268153e-11 2.162347e-11 9.711446e-10 3.718626e-10 9.641228e-11 #> [21] 7.894062e-10 2.884657e-10 2.116380e-11 4.568940e-04 1.138471e-10 #> [26] 2.161833e-11 2.337438e-11 2.173040e-07 5.462879e-11 4.208674e-11 #> [31] 5.567277e-08 2.085934e-11 3.839569e-11 2.046751e-11 6.941122e-08 #> [36] 4.350603e-11 3.965515e-11 2.044962e-11 3.680986e-09 2.453875e-10 #> [41] 2.374919e-11 2.690810e-11 1.700450e-10 7.664161e-11 1.561141e-10 #> [46] 1.788622e-10 3.732358e-11 2.605765e-10 2.215170e-11 5.796648e-10 #> [51] 4.163009e-11 1.037319e-10 3.518230e-11 4.952190e-09 1.361513e-07 #> [56] 3.980564e-04 3.749134e-11 2.235304e-09 8.404665e-11 2.296256e-11 #> [61] 9.625313e-01 2.183471e-11 1.618909e-10 2.176455e-11 2.232722e-10 #> [66] 2.380888e-11 2.351687e-05 2.035492e-07 2.357808e-11 1.225476e-02 #> [71] 5.726625e-11 1.826669e-10 1.054809e-10 8.917293e-10 1.758062e-08 #> [76] 3.064738e-11 4.951979e-11 2.107186e-11 2.202085e-11 9.365495e-11 #> [81] 8.599292e-11 2.418761e-11 8.041102e-09 4.251524e-07 9.610121e-11 #> [86] 3.450227e-11 2.650920e-09 3.230306e-11 3.950781e-11 3.002871e-11 #> [91] 7.542926e-11 1.089141e-08 6.683445e-09 1.774247e-10 9.769621e-07 #> [96] 8.280724e-11 2.242496e-08 8.825774e-11 1.297898e-08 5.891902e-11