Last chance! 50% off unlimited learning
Sale ends in
Estimate the heritability of a set of traits via a linear mixed model, with possible allowance for covariates.
est_herit(
pheno,
kinship,
addcovar = NULL,
weights = NULL,
reml = TRUE,
cores = 1,
...
)
A vector of estimated heritabilities, corresponding to the
columns in pheno
. The result has attributes "sample_size"
,
"log10lik"
and "resid_sd"
.
A numeric matrix of phenotypes, individuals x phenotypes.
A kinship matrix.
An optional numeric matrix of additive covariates.
An optional numeric vector of positive weights for the
individuals. As with the other inputs, it must have names
for individual identifiers.
If true, use REML; otherwise, use maximimum likelihood.
Number of CPU cores to use, for parallel calculations.
(If 0
, use parallel::detectCores()
.)
Alternatively, this can be links to a set of cluster sockets, as
produced by parallel::makeCluster()
.
Additional control parameters (see details).
We fit the model
If weights
are provided, the covariance matrix becomes
For each of the inputs, the row names are used as individual identifiers, to align individuals.
If reml=TRUE
, restricted maximum likelihood (reml) is used
to estimate the heritability, separately for each phenotype.
Additional control parameters include tol
for the tolerance
for convergence, quiet
for controlling whether messages will
be display, max_batch
for the maximum number of phenotypes
in a batch, and check_boundary
for whether the 0 and 1
boundary values for the estimated heritability will be checked
explicitly.
# read data
iron <- read_cross2(system.file("extdata", "iron.zip", package="qtl2"))
iron <- iron[,c("19","X")] # subset to two chromosomes
# insert pseudomarkers into map
map <- insert_pseudomarkers(iron$gmap, step=1)
# calculate genotype probabilities
probs <- calc_genoprob(iron, map, error_prob=0.002)
# kinship matrix
kinship <- calc_kinship(probs)
# grab phenotypes and covariates; ensure that covariates have names attribute
pheno <- iron$pheno
covar <- match(iron$covar$sex, c("f", "m")) # make numeric
names(covar) <- rownames(iron$covar)
# perform genome scan
hsq <- est_herit(pheno, kinship, covar)
Run the code above in your browser using DataLab