Description Usage Arguments Details Value Examples
View source: R/extra_functions.R
Calculate ABFs from Z scores
1 | bf_func(z, V, W = 0.2)
|
z |
Vector of Z-scores |
V |
Variance of the estimated effect size |
W |
Prior for the standard deviation of the effect size parameter, beta (default 0.2) |
Note, z and V should both be vectors or both be matrices
ABFs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | 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 = 0.5)
bf_func(z_scores, V = varbeta)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.