This function takes as input individual phenotype and genotype data for a given feature-SNP pair and tests for marginal and response QTLs.

map_qtl_for_each(
  input,
  feat.id = NULL,
  snp.id = NULL,
  fn,
  scale = FALSE,
  rint = FALSE,
  tu.lambda = NULL,
  type = "response",
  seed = 1,
  epsilon = 0.01,
  control = NULL,
  gls = FALSE
)

Arguments

input

A list containing phenotype, genotype, treatment, and subject. The elements must be named "y", "g", "t", and "subject".

feat.id

A character string specifying the feature name.

snp.id

A character string specifying the SNP name.

fn

A character string specifying the function. This must be one of "nonlinear" and "linear", corresponding to nonlinear and linear models, respectively.

scale

A logical scalar as to whether to standardize the phenotype, y. This can be set to TRUE only if fn is set to "linear".

rint

A logical scalar as to whether the phenotypes need to be RINT-transformed. This cannot be set to TRUE if fn is set to "nonlinear".

tu.lambda

A list obtained from get_eigen. It must contain the transposed eigenvector matrix and the eigenvalues of the covariance matrix. The element names must be "tU" and "lambda".

type

A character string specifying the type of QTLs. This must be one of "marginal" and "response".

seed

An integer specifying a seed for RNG.

epsilon

A small positive scalar. The upper bound of the \(h^2\) search interval is set to \(1 - \epsilon\). Default is 1e-2. Ignored when ranef is FALSE.

control

A list of control parameters passed to optim for the inner BFGS step. If NULL, the defaults are used. Ignored when gls = TRUE.

gls

A logical scalar. If TRUE, use the closed-form generalized least squares (GLS) estimator instead of BFGS. Only valid when fn is "linear". Default is FALSE.

Value

A list containing some of the following elements:

  • feat_id - A character string specifying the feature ID.

  • snp_id - A character string specifying the SNP ID.

  • beta0 - A scalar value representing the intercept estimate.

  • beta_g - A scalar value representing the genotype effect estimate based on the marginal model (when type = "marginal") or the interaction model (when type = "response").

  • beta_t - A scalar value representing the treatment effect estimate based on the interaction model.

  • beta_gxt - A scalar value representing the interaction effect estimate based on the interaction model.

  • sigma - A scalar value representing the estimate of the residual error standard deviation.

  • sigma_u - A scalar value representing the estimate of the random effect standard deviation.

  • p_value - A scalar value representing the nominal p-value from LRT.

  • return_code - An integer: 0 if all optimizations converged, NA otherwise.

Examples

input <- list(
    feat.id = "f1",
    snp.id = "g1",
    y = rnorm(20),
    g = rep(c(0, 1, 2), length.out = 20),
    t = rep(c(0, 1), 10),
    subject = rep(paste0("d", 1:10), each = 2)
)
result <- map_qtl_for_each(input = input, fn = "linear")