| Title: | Simple LMM Fitter for QTL Mapping |
|---|---|
| Description: | A port of parts of 'pylmm' for fitting linear mixed models relevant to genome-wide association studies (GWAS) and quantitative trait locus (QTL) mapping. |
| Authors: | Karl W Broman [aut, cre] (ORCID: <https://orcid.org/0000-0002-4914-6671>, (closely following the pylmm code by Nick Furlotte)) |
| Maintainer: | Karl W Broman <[email protected]> |
| License: | AGPL-3 |
| Version: | 0.2-2 |
| Built: | 2026-06-05 11:27:44 UTC |
| Source: | https://github.com/kbroman/lmmlite |
Calculate the log likelihood for a given value of the heritability, hsq.
calcLL(hsq, Kva, y, X, reml = TRUE, use_cpp = TRUE)calcLL(hsq, Kva, y, X, reml = TRUE, use_cpp = TRUE)
hsq |
heritability |
Kva |
eigenvalues of K (calculated by |
y |
rotated phenotypes (calculated by |
X |
rotated covariate matrix (calculated by |
reml |
If TRUE, use REML; otherwise use ordinary maximum likelihood. |
use_cpp |
= if TRUE, use c++ version of code |
The log likelihood value, with the corresponding estimates
of beta and sigmasq included as attributes.
data(recla) e <- eigen_rotation(recla$kinship, recla$pheno[,1], recla$covar) loglik <- calcLL(0.5, e$Kva, e$y, e$X) many_loglik <- calcLL(seq(0, 1, by=0.1), e$Kva, e$y, e$X)data(recla) e <- eigen_rotation(recla$kinship, recla$pheno[,1], recla$covar) loglik <- calcLL(0.5, e$Kva, e$y, e$X) many_loglik <- calcLL(seq(0, 1, by=0.1), e$Kva, e$y, e$X)
Do eigen decomposition of kinship matrix and rotate X and
y by that, i.e., pre-multiply by the transpose of the matrix
of eigenvectors. If Kva and Kve_t provided, just do
the "rotation".
eigen_rotation(K, y, X = NULL, Kva = NULL, Kve_t = NULL, use_cpp = TRUE)eigen_rotation(K, y, X = NULL, Kva = NULL, Kve_t = NULL, use_cpp = TRUE)
K |
Kinship matrix (required if |
y |
Phenotypes |
X |
Numeric matrix with covariates. If NULL, use a column of 1's (for intercept). |
Kva |
Eigenvalues of |
Kve_t |
= transposed eigenvectors of K (optional, ignored if |
use_cpp |
= if TRUE, use c++ version of code |
List containing Kva, Kve_t and rotated
y and X.
data(recla) e <- eigen_rotation(recla$kinship, recla$pheno[,1], recla$covar)data(recla) e <- eigen_rotation(recla$kinship, recla$pheno[,1], recla$covar)
Fit a linear mixed model of the form y = Xb + e where e follows a
multivariate normal distribution with mean 0 and variance matrix
sigmasq_g K + sigmasq_e I, where K is a known kniship
matrix and I is the identity matrix.
fitLMM( Kva, y, X, reml = TRUE, check_boundary = TRUE, tol = 0.0001, use_cpp = TRUE, compute_se = FALSE )fitLMM( Kva, y, X, reml = TRUE, check_boundary = TRUE, tol = 0.0001, use_cpp = TRUE, compute_se = FALSE )
Kva |
Eigenvalues of K (calculated by |
y |
Rotated phenotypes (calculated by |
X |
Rotated covariate matrix (calculated by |
reml |
If TRUE, use REML; otherwise use ordinary maximum likelihood. |
check_boundary |
If TRUE, explicitly check log likelihood at 0 and 1. |
tol |
Tolerance for convergence |
use_cpp |
= if TRUE, use c++ version of code |
compute_se |
= if TRUE, return the standard error of the |
List containing estimates of beta, sigmasq,
hsq, sigmasq_g, and sigmasq_e, as well as the log
likelihood (loglik). If compute_se=TRUE, the output also
contains hsq_se.
data(recla) e <- eigen_rotation(recla$kinship, recla$pheno[,1], recla$covar) result <- fitLMM(e$Kva, e$y, e$X) # also compute SE wSE <- fitLMM(e$Kva, e$y, e$X, compute_se = TRUE, use_cpp=FALSE) c(hsq=wSE$hsq, SE=wSE$hsq_se)data(recla) e <- eigen_rotation(recla$kinship, recla$pheno[,1], recla$covar) result <- fitLMM(e$Kva, e$y, e$X) # also compute SE wSE <- fitLMM(e$Kva, e$y, e$X, compute_se = TRUE, use_cpp=FALSE) c(hsq=wSE$hsq, SE=wSE$hsq_se)
For a fixed value for hsq, the heritability, calculate the
corresponding maximum likelihood estimates of beta and
sigmasq, with the latter being the total variance,
sigmasq_g + sigmasq_e.
getMLsoln(hsq, Kva, y, X, reml = TRUE, use_cpp = TRUE)getMLsoln(hsq, Kva, y, X, reml = TRUE, use_cpp = TRUE)
hsq |
heritability |
Kva |
eigenvalues of K (calculated by |
y |
rotated phenotypes (calculated by |
X |
rotated covariate matrix (calculated by |
reml |
If TRUE, use REML; otherwise use ordinary maximum likelihood. |
use_cpp |
= if TRUE, use c++ version of code |
list containing beta and sigmasq, with residual
sum of squares and (if reml=TRUE, log det (XSX)) as
attributes.
data(recla) e <- eigen_rotation(recla$kinship, recla$pheno[,1], recla$covar) ml <- getMLsoln(0.5, e$Kva, e$y, e$X)data(recla) e <- eigen_rotation(recla$kinship, recla$pheno[,1], recla$covar) ml <- getMLsoln(0.5, e$Kva, e$y, e$X)
Estimated kinship matrix, phenotypes, and covariates for diversity outcross mice, taken from Recla et al. (2014) and Logan et al. (2013)
A list with three components, kinship, pheno,
and covar, each a matrix.
These are data for a set of diversity outcross mice. The kinship matrix was calculated from MUGA array data, using the R/qtl2 package.
QTL Archive, https://phenome.jax.org/projects/Recla1
Recla JM, Robledo RF, Gatti DM, Bult CJ, Churchill GA, Chesler EJ (2014) Precise genetic mapping and integrative bioinformatics in Diversity Outbred mice reveals Hydin as a novel pain gene. Mamm Genome 25:211-222
Logan RW, Robledo RF, Recla JM, Philip VM, Bubier JA, Jay JJ, Harwood C, Wilcox T, Gatti DM, Bult CJ, Churchill GA, Chesler EJ (2013) High-precision genetic mapping of behavioral traits in the diversity outbred mouse population. Genes Brain Behav 12:424-437
data(recla)data(recla)