Inference of zQTL regression without multivariate effect size.

fit.zqtl.vanilla(effect, effect.se, X, multi.C, univar.C)

Arguments

effect

Marginal effect size matrix (SNP x trait)

effect.se

Marginal effect size standard error matrix (SNP x trait)

X

Design matrix (reference Ind x SNP)

n

sample size of actual data (will ignore if n = 0)

multi.C

multivariate SNP annotations (SNP x something; default: NULL)

univar.C

univariate SNP annotations (SNP x something; default: NULL)

options

A list of inference/optimization options.

do.hyper

Hyper parameter tuning (default: FALSE)

do.rescale

Rescale z-scores by standard deviation (default: FALSE)

tau

Fixed value of tau

pi

Fixed value of pi

tau.lb

Lower-bound of tau (default: -10)

tau.ub

Upper-bound of tau (default: -4)

pi.lb

Lower-bound of pi (default: -4)

pi.ub

Upper-bound of pi (default: -1)

tol

Convergence criterion (default: 1e-4)

gammax

Maximum precision (default: 1000)

rate

Update rate (default: 1e-2)

decay

Update rate decay (default: 0)

jitter

SD of random jitter for mediation & factorization (default: 0.1)

nsample

Number of stochastic samples (default: 10)

vbiter

Number of variational Bayes iterations (default: 2000)

verbose

Verbosity (default: TRUE)

print.interv

Printing interval (default: 10)

nthread

Number of threads during calculation (default: 1)

eigen.tol

Error tolerance in Eigen decomposition (default: 0.01)

eigen.reg

Regularization of Eigen decomposition (default: 0.0)

do.stdize

Standardize (default: TRUE)

out.residual

estimate residual z-scores (default: FALSE)

do.var.calc

variance calculation (default: FALSE)

scale.var

Scaled variance calculation (default: FALSE)

nboot

Number of bootstraps (default: 0)

nboot.var

Number of bootstraps for variance estimation (default: 100)

min.se

Minimum level of SE (default: 1e-4)

rseed

Random seed

Value

a list of variational inference results.

  • conf.multi: association with multivariate confounding variables

  • conf.uni: association with univariate confounding variables

  • resid: residuals

  • gwas.clean: cleansed version of univariate GWAS effects

  • var: variance decomposition results

  • llik: log-likelihood trace over the optimization

Author

Yongjin Park, ypp@stat.ubc.ca, ypp.ubc@gmail.com

Examples


n = 500
p = 2000
m = 1

set.seed(1)
.rnorm <- function(a, b) matrix(rnorm(a * b), a, b)
X = .rnorm(n, p)
Y = matrix(0, n, m)
h2 = 0.25
y1 = X[, 1:500] %*% .rnorm(500, 1) * sqrt(h2/500)
y0 = .rnorm(n, 1) * sqrt(1 - h2)
Y = y1 + y0
qtl.tab = calc.qtl.stat(X, Y)
qtl.1.tab = calc.qtl.stat(X, y1)
z.1 = matrix(qtl.1.tab$beta/qtl.1.tab$se, ncol = 1)
qtl.0.tab = calc.qtl.stat(X[sample(n), , drop = FALSE], y1)
z.0 = matrix(qtl.0.tab$beta/qtl.0.tab$se, ncol = 1)
z.out = fit.zqtl.vanilla(matrix(qtl.tab$beta, ncol=1),
                               matrix(qtl.tab$se, ncol=1),
                               X = X,
                               univar.C = cbind(z.1, z.0),
                               do.var.calc = TRUE,
                               scale.var = TRUE,
                               nboot.var = 100)

library(dplyr)
.make.df <- function(x) {
    data.frame(mean = x$mean, sd = x$sd)
}
.power10 <- function(x, component) {
    take.var.power10(x) %>%
        .make.df() %>%
        mutate(component)
}
var.tab = bind_rows(.power10(z.out$var$univar.tot, 'univar.tot'),
                    .power10(z.out$var$multivar.tot, 'multivar.tot'),
                    .power10(z.out$var$resid, 'resid'),
                    .power10(z.out$var$univar, 'univar'))
print(var.tab)
#>           mean           sd    component
#> 1 2.622431e-01 4.953439e-03   univar.tot
#> 2 8.132623e-10 8.883874e-11 multivar.tot
#> 3 4.714143e-01 1.143686e-03        resid
#> 4 2.537794e-01 5.254870e-02       univar
#> 5 1.870377e-06 3.389168e-06       univar