Multivariate Bayesian variable selection regression
In [1]:
knitr::opts_chunk$set(echo = TRUE)

R Markdown

In [2]:
library(susieR)
set.seed(1)
data(N2finemapping.rds)
dat = N2finemapping
names(dat)
r = 1
fitted = susie(dat$X, dat$Y[,r], L=5,
               estimate_residual_variance=TRUE,
               scaled_prior_variance=0.2,
               tol=1e-3, track_fit=TRUE)
sets = susie_get_cs(fitted,
            coverage = 0.95,
            X = dat$X,
            min_abs_corr = 0.1)
pip = susie_get_pip(fitted, sets$cs_index)
z_score = susieR:::calc_z(dat$X, dat$Y[,r])
b = dat$true_coef[,r]
Warning message in data(N2finemapping.rds):
“data set ‘N2finemapping.rds’ not found”
  1. 'X'
  2. 'chrom'
  3. 'pos'
  4. 'true_coef'
  5. 'residual_variance'
  6. 'Y'
  7. 'allele_freq'
  8. 'V'

try BF for true variables

In [3]:
# simple BF, X an n by p matrix
log10BF = function(X,y,sigmaa){
p = ncol(X)
n = nrow(X)
X = cbind(rep(1,n),X)
invnu = diag(c(0,rep(1/sigmaa^2,p)))
invOmega = invnu + t(X) %*% X
B = solve(invOmega, t(X) %*% cbind(y))
invOmega0 = n
return(-0.5*log10(det(invOmega)) + 0.5*log10(invOmega0) - p*log10(sigmaa) -(n/2) * (log10( t(y- X %*% B) %*% y) - log10(t(y) %*% y - n*mean(y)^2) ))
}

x = scale(dat$X)
y = scale(dat$Y[,r])
log10BF(x[,which(b!=0)], y,1)
log10BF(x[,which(b!=0)], y,2)
log10BF(x[,which(b!=0)], y,0.5)
A matrix: 1 × 1 of type dbl
27.83138
A matrix: 1 × 1 of type dbl
27.29535
A matrix: 1 × 1 of type dbl
28.17213

The top finemap config was (780,916), with reported log10bf of 15.22015.

In [4]:
log10BF(x[,c(780,916)], y,0.05)
 log10BF(x[,which(b!=0)], y,0.05)

 log10BF(x[,c(780,916)], y,0.1)
 log10BF(x[,which(b!=0)], y,0.1)
A matrix: 1 × 1 of type dbl
14.12636
A matrix: 1 × 1 of type dbl
13.98579
A matrix: 1 × 1 of type dbl
18.50727
A matrix: 1 × 1 of type dbl
23.04867

Copyright © 2016-2020 Gao Wang et al at Stephens Lab, University of Chicago