View source: R/set_hyper_init.R
set_hyper | R Documentation |
This function is used to provide hyperparameter values for
atlasqtl
.
set_hyper(q, p, eta, kappa, n0, nu, rho, t02)
q |
Number of responses. |
p |
Number of candidate predictors. |
eta |
Vector of length 1 or q. Provides the shape hyperparameter
|
kappa |
Vector of length 1 or q. Provides the rate hyperparameter
|
n0 |
Vector of length 1 or q, prior mean for the response effects. |
nu |
Vector of length 1 providing the shape hyperparameter |
rho |
Vector of length 1 providing the rate hyperparameter |
t02 |
Prior variance for the response effects. |
The atlasqtl
function can also be used with default
hyperparameter values (i.e., without using set_hyper
) by
setting its argument list_hyper
to NULL
.
An object of class "hyper
" preparing user hyperparameter in a
form that can be passed to the atlasqtl
function.
set_init
, atlasqtl
seed <- 123; set.seed(seed)
###################
## Simulate data ##
###################
## Examples using small problem sizes:
##
n <- 200; p <- 50; p_act <- 10; q <- 100; q_act <- 50
# Candidate predictors (subject to selection)
#
# Here example with common genetic variants under Hardy-Weinberg equilibrium
#
X_act <- matrix(rbinom(n * p_act, size = 2, p = 0.25), nrow = n)
X_inact <- matrix(rbinom(n * (p - p_act), size = 2, p = 0.25), nrow = n)
# shuffle indices
shuff_x_ind <- sample(p)
shuff_y_ind <- sample(q)
X <- cbind(X_act, X_inact)[, shuff_x_ind]
# Association pattern and effect sizes
#
pat <- matrix(FALSE, ncol = q, nrow = p)
bool_x <- shuff_x_ind <= p_act
bool_y <- shuff_y_ind <= q_act
pat_act <- beta_act <- matrix(0, nrow = p_act, ncol = q_act)
pat_act[sample(p_act * q_act, floor(p_act * q_act / 5))] <- 1
beta_act[as.logical(pat_act)] <- rnorm(sum(pat_act))
pat[bool_x, bool_y] <- pat_act
# Gaussian responses
#
Y_act <- matrix(rnorm(n * q_act, mean = X_act %*% beta_act), nrow = n)
Y_inact <- matrix(rnorm(n * (q - q_act)), nrow = n)
Y <- cbind(Y_act, Y_inact)[, shuff_y_ind]
#############################
## Specify hyperparameters ##
#############################
list_hyper <- set_hyper(q, p, eta = 1, kappa = 1, n0 = -2, nu = 1, rho = 1,
t02 = 0.1)
########################
## Infer associations ##
########################
p0 <- c(mean(colSums(pat)), 10)
res_atlas <- atlasqtl(Y, X, p0, list_hyper = list_hyper, user_seed = seed)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.