bf_func: Calculate ABFs from Z scores

Description Usage Arguments Details Value Examples

View source: R/extra_functions.R

Description

Calculate ABFs from Z scores

Usage

1
bf_func(z, V, W = 0.2)

Arguments

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)

Details

Note, z and V should both be vectors or both be matrices

Value

ABFs

Examples

 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)

corrcoverage documentation built on Dec. 7, 2019, 1:07 a.m.