scan1gen: General genome scan with a single-QTL model

View source: R/scan1gen.R

scan1genR Documentation

General genome scan with a single-QTL model

Description

General genome scan with a single-QTL model, with possible allowance for covariates and a polygeneic effect, but taking a general function that calculates a LOD score at a single position.

Usage

scan1gen(
  genoprobs,
  pheno,
  kinship = NULL,
  addcovar = NULL,
  Xcovar = NULL,
  intcovar = NULL,
  weights = NULL,
  func,
  vectorize_func = TRUE,
  cores = 1,
  ...
)

Arguments

genoprobs

Genotype probabilities as calculated by calc_genoprob().

pheno

A numeric matrix of phenotypes, individuals x phenotypes.

kinship

Optional kinship matrix, or a list of kinship matrices (one per chromosome), in order to use the LOCO (leave one chromosome out) method.

addcovar

An optional numeric matrix of additive covariates.

Xcovar

An optional numeric matrix with additional additive covariates used for null hypothesis when scanning the X chromosome.

intcovar

An numeric optional matrix of interactive covariates.

weights

An optional numeric vector of positive weights for the individuals. As with the other inputs, it must have names for individual identifiers.

func

Function to calculate log10 likelihood. It is called as func(pr, pheno, kinship, addcovar, intcovar, weights, ...) where pr is for the genotype probabilities at a fixed position. It will also be used to calculate the null log10 likelihood, with pr being NULL in that case.

vectorize_func

If TRUE (the default), assume that func takes only a single phenotype. If FALSE, assume func is able to take a matrix of phenotypes and return a vector of log10 likelihood values.

cores

Number of CPU cores to use, for parallel calculations.

...

Additional arguments passed to func().

Value

An object of class "scan1": a matrix of LOD scores, positions x phenotypes.

See Also

scan1(), scan1perm(), scan1max()

Examples

# read data
iron <- read_cross2(system.file("extdata", "iron.zip", package="qtl2"))


# insert pseudomarkers into map
map <- insert_pseudomarkers(iron$gmap, step=1)

# calculate genotype probabilities
probs <- calc_genoprob(iron, map, error_prob=0.002)

# covariates for X chr under null
Xcovar <- get_x_covar(iron)

# create binary trait
bin_pheno <- setNames(as.numeric(iron$pheno[,1] > median(iron$pheno[,1])),
                      rownames(iron$pheno))

ll_glm <-
   function(pr, pheno, addcovar=NULL, ...)
{
   formula <- ifelse(is.null(pr), "pheno ~ 1", "pheno ~ pr")
   if(!is.null(addcovar)) formula <- paste(formula, "+ addcovar")

    glm_out <- glm(as.formula(formula), family=binomial(link=probit))
    -glm_out$deviance/(2*log(10)) # log10 likelihood
}

# perform genome scan using glm() with probit link function
out <- scan1gen(probs, bin_pheno, Xcovar=Xcovar, func=ll_glm)


qtl2 documentation built on July 6, 2026, 5:11 p.m.