Skip to contents

This function performs Bayesian linear regression using the `gbayes` function from the `qgg` package. It then returns the estimated slopes.

Usage

bayesAlphabetWeights(
  X,
  y,
  method,
  Z = NULL,
  h2 = NULL,
  nit = 5000,
  nburn = 1000,
  nthin = 5,
  methodArgs = QggOptions()
)

Arguments

X

A numeric matrix of genotypes.

y

A numeric vector of phenotypes.

method

A character string declaring the method/prior to be used. Options are bayesN, bayesL, bayesA, bayesC, or bayesR.

Z

An optional numeric matrix of covariates.

h2

Numeric or NULL. Prior heritability for the sampler; NULL lets qgg estimate it.

nit

Integer. Total number of MCMC iterations. Default 5000.

nburn

Integer. Number of burn-in iterations discarded. Default 1000.

nthin

Integer. Thinning interval for retained MCMC samples. Default 5.

methodArgs

Options forwarded to qgg::gbayes, built with QggOptions. A bare list is refused: it cannot be checked against the engine, so a misspelled option would be silently ignored.

Value

A vector containing the weights to be applied to each genotype in predicting the phenotype.

Details

This function fits a Bayesian linear regression model with a range of priors.

Examples

X <- matrix(rnorm(100000), nrow = 1000)
Z <- matrix(round(runif(3000, 0, 0.8), 0), nrow = 1000)
set1 <- sample(seq_len(ncol(X)), 5)
set2 <- sample(seq_len(ncol(X)), 5)
sets <- list(set1, set2)
g <- rowSums(X[, c(set1, set2)])
e <- rnorm(nrow(X), mean = 0, sd = 1)
y <- g + e
bayesLWeights(y = y, X = X, Z = Z)
#> Type of analysis performed: st-blr-individual-level-dense-ld
#>   [1]  4.914563e-04 -3.455287e-03  2.285000e-02  2.982315e-01  3.105277e-01
#>   [6]  1.160392e-02 -4.257758e-03 -4.027864e-03 -6.492253e-03 -1.855197e-03
#>  [11]  3.756255e-03 -1.431560e-02 -6.837405e-03  2.481571e-03 -2.489394e-03
#>  [16]  1.798530e-02  8.515772e-03  1.259846e-02  2.900407e-01 -7.771659e-03
#>  [21] -8.184038e-03  1.114185e-02  1.368296e-02 -5.817292e-03  3.042268e-01
#>  [26]  1.066966e-02 -8.489891e-03  1.690149e-02  9.807141e-04  1.291876e-02
#>  [31]  5.008090e-03 -9.208801e-03  4.606125e-04 -5.335791e-03  1.169377e-02
#>  [36]  7.014884e-03  1.101366e-02  4.035054e-04  5.955327e-03 -5.716785e-03
#>  [41] -1.300670e-02  3.097087e-01 -2.250993e-03  5.108324e-03  7.792683e-03
#>  [46]  1.546371e-03  1.455310e-02 -1.079061e-02 -9.793386e-03  4.617195e-03
#>  [51]  2.148324e-02  2.074609e-03 -2.348584e-03 -1.581396e-03  1.174458e-02
#>  [56]  4.631000e-03 -3.021246e-03  1.184418e-02 -2.613706e-03  1.154015e-02
#>  [61] -6.534006e-03 -3.994157e-03 -2.033909e-03 -1.351323e-02  3.017073e-01
#>  [66] -5.673637e-03 -5.990740e-03 -6.782766e-03 -3.170484e-03 -6.980842e-03
#>  [71] -1.147676e-03 -2.015833e-02  1.272571e-02 -4.375557e-03 -3.426146e-03
#>  [76] -1.467720e-03 -2.042092e-03 -5.765125e-03  2.827300e-01  2.826187e-01
#>  [81] -3.001325e-03  2.888050e-01  1.544028e-02 -3.434372e-05 -5.392376e-03
#>  [86]  5.135910e-03  2.644537e-02  1.239697e-02  1.698128e-02  1.069157e-02
#>  [91] -4.992490e-03  2.080240e-03 -5.225339e-03 -1.500870e-02  6.069905e-03
#>  [96] -9.687333e-03  3.017362e-01 -1.146037e-03 -1.891101e-04  1.017300e-02
bayesRWeights(y = y, X = X, Z = Z)
#> Type of analysis performed: st-blr-individual-level-dense-ld
#>   [1] -3.973643e-05 -6.098638e-06  1.705551e-03  2.998407e-01  3.161284e-01
#>   [6]  2.044838e-04 -8.456504e-06  3.661007e-07 -3.789092e-05 -2.058454e-06
#>  [11]  2.255674e-05 -1.833540e-04 -1.733175e-05 -3.512419e-05 -1.172632e-05
#>  [16]  3.755913e-04  1.026153e-04  1.133920e-04  2.908136e-01 -2.979307e-08
#>  [21] -9.842383e-05  1.321217e-04  8.928845e-05 -1.033975e-04  3.078051e-01
#>  [26]  1.024443e-04 -1.656046e-04  3.670699e-04 -2.272936e-05  2.152096e-04
#>  [31]  4.387799e-05 -1.062588e-04 -1.706029e-05 -5.906538e-05  1.029234e-04
#>  [36]  9.294092e-06  1.331915e-04 -1.363515e-05  1.510712e-04 -4.483505e-05
#>  [41] -1.422085e-04  3.110943e-01  2.769805e-06  2.679715e-06  1.309510e-04
#>  [46]  1.264400e-05  3.314570e-04 -2.406515e-05 -2.765446e-06 -1.582769e-05
#>  [51]  4.405672e-04 -5.489413e-05 -3.385110e-05  1.334581e-05  1.772962e-04
#>  [56] -3.915823e-06  3.633939e-07  1.918070e-04 -6.522358e-05  2.664626e-04
#>  [61] -3.634725e-05 -4.817091e-05 -1.356998e-05 -3.426630e-04  3.032617e-01
#>  [66] -4.694625e-05 -1.289409e-05 -4.123718e-05 -1.571670e-05 -5.544389e-05
#>  [71] -1.187221e-05 -8.898313e-04  2.008140e-04 -5.521297e-05 -4.032410e-05
#>  [76]  1.027346e-05 -1.239677e-05 -6.542492e-05  2.882108e-01  2.784351e-01
#>  [81] -7.213118e-06  2.916810e-01  3.212136e-04 -4.105837e-08 -3.081144e-05
#>  [86]  5.698251e-05  4.773111e-03  2.727124e-04  2.048494e-04  1.979992e-04
#>  [91] -5.167894e-05  5.236955e-05 -4.386091e-05 -1.927613e-04  1.140341e-07
#>  [96] -7.442300e-05  2.981916e-01 -2.499964e-05  3.776035e-05  5.989244e-05