ppfunc.mat: Find PPs of SNPs from matrix of Z-scores

Description Usage Arguments Details Value Author(s) Examples

View source: R/posterior_prob_functions.R

Description

Posterior probabilities of causality from matrix of marginal Z-scores (1 simulation per row)

Usage

1
ppfunc.mat(zstar, V, W = 0.2)

Arguments

zstar

Matrix of marginal z-scores, one replicate per row

V

Variance of the estimated effect size, one element per column of zstar

W

Prior for the standard deviation of the effect size parameter, beta

Details

This function converts a matrix of Z-scores (one row per simulation) to posterior probabilities of causality, not including the null model of no genetic effects, so that the sum of the posterior probabilities for each simulation (each row) is 1.

Value

Matrix of posterior probabilities of causality

Author(s)

Chris Wallace

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
25
26
27
28
29
30
set.seed(1)
nsnps = 100
N0 = 5000
N1 = 5000

## 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))

# simulate matrix of Z scores
# 1 simulation per row
z_scores <- matrix(rnorm(nsnps*100, 0, 3), ncol = nsnps)

# each row is a vector of simulated PPs
res <- ppfunc.mat(zstar = z_scores, V = varbeta)

rowSums(res)

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