Description Usage Arguments Details Value Examples
View source: R/posterior_prob_functions.R
Wakefield's log asymptotic Bayes factor (lABF) with prior standard deviation of effect size as a parameter
1 | approx.bf.p(pvals, f, type, N, s, W = 0.2)
|
pvals |
P-values |
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 (W=0.2 default) |
([Wakefield et al. 2009](https://onlinelibrary.wiley.com/doi/abs/10.1002/gepi.20359) This function converts p-values to log ABFs, also reporting intermediate calculations
data.frame containing lABF and intermediate calculations
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | set.seed(1)
nsnps = 100
N0 = 5000
N1 = 5000
z_scores <- rnorm(nsnps, 0, 3)
p_values <- 2 * pnorm( - abs ( z_scores ) )
## 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)
approx.bf.p(pvals = p_values, f = maf, type = "cc", N = N0+N1, s = N1/(N0+N1))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.