z0_pp.Rd
Posterior probabilities of causality from marginal Z-scores with prior SD as a parameter
z0_pp(z, f, type, N, s, W = 0.2, p1 = 1e-04)
z | Marginal Z-scores of SNPs |
---|---|
f | Minor allele frequencies |
type | Type of experiment ('quant' or 'cc') |
N | Total sample size |
s | Proportion of cases (N1/N0+N1), ignored if type=='quant' |
W | Prior for the standard deviation of the effect size parameter, beta (default 0.2) |
p1 | Prior probability a SNP is associated with the trait (default 1e-4) |
Posterior probabilities of null model (no genetic effect) and causality for each SNP
Converts Z-scores to posterior probabilities of causality, including the null model of no genetic effects
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) res <- z0_pp(z = z_scores, f = maf, type = "cc", N = N0+N1, s = N1/(N0+N1)) sum(res)#> [1] 1res#> [1] 9.281394e-07 1.215823e-10 2.631590e-11 4.426837e-10 1.068424e-06 #> [6] 3.646596e-11 3.907036e-10 5.990005e-11 2.225319e-10 9.103725e-11 #> [11] 3.354994e-11 3.654519e-07 4.079654e-11 1.142768e-10 2.433180e-02 #> [16] 4.793555e-09 2.268151e-11 2.162345e-11 9.711437e-10 3.718623e-10 #> [21] 9.641219e-11 7.894055e-10 2.884654e-10 2.116378e-11 4.568936e-04 #> [26] 1.138470e-10 2.161831e-11 2.337436e-11 2.173038e-07 5.462874e-11 #> [31] 4.208670e-11 5.567272e-08 2.085932e-11 3.839565e-11 2.046749e-11 #> [36] 6.941115e-08 4.350599e-11 3.965512e-11 2.044960e-11 3.680982e-09 #> [41] 2.453873e-10 2.374917e-11 2.690808e-11 1.700449e-10 7.664153e-11 #> [46] 1.561140e-10 1.788620e-10 3.732355e-11 2.605763e-10 2.215168e-11 #> [51] 5.796642e-10 4.163006e-11 1.037318e-10 3.518227e-11 4.952186e-09 #> [56] 1.361512e-07 3.980561e-04 3.749130e-11 2.235302e-09 8.404658e-11 #> [61] 2.296254e-11 9.625304e-01 2.183469e-11 1.618908e-10 2.176453e-11 #> [66] 2.232720e-10 2.380886e-11 2.351685e-05 2.035490e-07 2.357806e-11 #> [71] 1.225475e-02 5.726619e-11 1.826668e-10 1.054808e-10 8.917285e-10 #> [76] 1.758061e-08 3.064736e-11 4.951975e-11 2.107184e-11 2.202083e-11 #> [81] 9.365486e-11 8.599285e-11 2.418758e-11 8.041094e-09 4.251520e-07 #> [86] 9.610112e-11 3.450224e-11 2.650918e-09 3.230303e-11 3.950777e-11 #> [91] 3.002868e-11 7.542919e-11 1.089140e-08 6.683439e-09 1.774245e-10 #> [96] 9.769612e-07 8.280716e-11 2.242494e-08 8.825766e-11 1.297896e-08 #> [101] 5.891896e-11