{"id":39438007,"url":"https://github.com/variani/lme4qtl","last_synced_at":"2026-01-18T04:15:47.815Z","repository":{"id":50150550,"uuid":"58938082","full_name":"variani/lme4qtl","owner":"variani","description":"Mixed models @lme4 + custom covariances + parameter constraints","archived":false,"fork":false,"pushed_at":"2021-01-07T20:10:21.000Z","size":397,"stargazers_count":44,"open_issues_count":2,"forks_count":8,"subscribers_count":2,"default_branch":"master","last_synced_at":"2023-10-20T23:38:52.564Z","etag":null,"topics":["covariance","family","gwas","ibd","kinship","lme4","pedigree","qtl","random-effects","relatedness","variance-covariance"],"latest_commit_sha":null,"homepage":"","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/variani.png","metadata":{"files":{"readme":"README.Rmd","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-05-16T14:16:04.000Z","updated_at":"2023-10-08T07:53:27.000Z","dependencies_parsed_at":"2022-09-12T21:50:17.543Z","dependency_job_id":null,"html_url":"https://github.com/variani/lme4qtl","commit_stats":null,"previous_names":[],"tags_count":2,"template":null,"template_full_name":null,"purl":"pkg:github/variani/lme4qtl","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/variani%2Flme4qtl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/variani%2Flme4qtl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/variani%2Flme4qtl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/variani%2Flme4qtl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/variani","download_url":"https://codeload.github.com/variani/lme4qtl/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/variani%2Flme4qtl/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28529475,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-18T00:39:45.795Z","status":"online","status_checked_at":"2026-01-18T02:00:07.578Z","response_time":98,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["covariance","family","gwas","ibd","kinship","lme4","pedigree","qtl","random-effects","relatedness","variance-covariance"],"created_at":"2026-01-18T04:15:47.759Z","updated_at":"2026-01-18T04:15:47.809Z","avatar_url":"https://github.com/variani.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\noutput: github_document\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r, include = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\",\n  fig.width = 8, fig.height = 8,\n  cache.path = \"man/cache/README-\",\n  out.width = \"50%\"\n)\n```\n# lme4qtl\n\n\u003c!-- badges: start --\u003e\n[![travis-ci build status](https://travis-ci.org/variani/lme4qtl.svg?branch=master)](https://travis-ci.org/variani/lme4qtl)\n\u003c!-- badges: end --\u003e\n\n`lme4qtl` extends the [lme4](https://github.com/lme4/lme4) R package for quantitative trait locus (qtl) mapping. It is all about the covariance structure of random effects. `lme4qtl` supports user-defined matrices for that,\ne.g. kinship or IBDs.\n\nSee slides [bit.ly/1UiTZvQ](http://bit.ly/1UiTZvQ) introducing the `lme4qtl` R package or read our [article](http://dx.doi.org/10.1186/s12859-018-2057-x) / [preprint](http://www.biorxiv.org/content/early/2017/08/31/139816).\n\n|  Package | Continuous response |\n|----------|---------------------|\n| stats   | `lm(myTrait ~ myCovariate, myData)` |\n| lme4    | `lmer(myTrait ~ myCovariate + (1|myID), myData)` |\n| lme4qtl | `relmatLmer(myTrait ~ myCovariate + (1|myID), myData, relmat = list(myID = myMatrix))` |\n\n|  Package | Binary response |\n|----------|---------------------|\n| stats    | `glm(myStatus ~ 1, myData, family = binomial)` |\n| lme4    | `glmer(myStatus ~ (1|myID), myData, family = binomial)` |\n| lme4qtl | `relmatGlmer(myStatus ~ (1|myID), myData, relmat = list(myID = myMatrix), family = binomial)` |\n\nNote that rownames/colnames of `myMatrix` have to be values of `myID` variable, so matching between relationship matrix and grouping variable is possible. The order [doesn't matter](https://github.com/variani/lme4qtl/issues/3#issuecomment-346905978).\n\n## Installation\n\nYou can install the development version from [GitHub](https://github.com/variani/lme4qtl) with:  \n\n``` r\n# install.packages(\"devtools\")\ndevtools::install_github(\"variani/lme4qtl\")\n```\n\nThe official release on [CRAN](https://CRAN.R-project.org) is [pending](https://github.com/variani/lme4qtl/issues/9).\n\n## Citation\n\nTo cite the `lme4qtl` package in publications use:\n\n```\n  Ziyatdinov et al., lme4qtl: linear mixed models with flexible\n  covariance structure for genetic studies of related individuals, \n  BMC Bioinformatics (2018)\n```\n\n\n## Contact\n\nYou are welcome to submit suggestions and bug-reports at https://github.com/variani/lme4qtl/issues.\n\n## Related projects\n\n- fastGWA/GCTA tool for large-scale association studies (e.g. UKB) and based on sparse GRM; [bioarxiv](https://www.biorxiv.org/content/10.1101/598110v1) \n- [GENESIS](https://bioconductor.org/packages/release/bioc/html/GENESIS.html) Bioconductor R package\n\n## Example\n\n```{r ex_inc}\nlibrary(lme4)\nlibrary(lattice)\n```\n\n```{r ex_inc2, eval = FALSE}\nlibrary(lme4qtl)\n```\n\n```{r ex_inc3, echo = FALSE, message = F}\nload_all()\n```\n\n```{r pkg_ver}\npackageVersion(\"lme4qtl\")\n```\n\nLoad simulated data, phenotypes `dat40` and the kinship matrix `kin2`.\n\n```{r ex_data}\ndata(dat40, package = \"lme4qtl\")\n\ndim(dat40)\ndim(kin2)\n\nhead(dat40)\nkin2[1:5, 1:5] # nuclear family with 2 parents and 3 kids\n```\n\nFit a model for continuous trait with two random effects, \nfamily-grouping `(1|FAM)` and additive genetic `(1|ID)`.\n\n```{r ex_fit1}\nm1 \u003c- relmatLmer(trait1 ~ AGE + SEX + (1|FAMID) + (1|ID), dat40, relmat = list(ID = kin2))\nm1\n```\n\nGet a point estimate of heritability (h2), the proportion of variance explained by `(1|ID)`.\n\n```{r ex_h2}\nlme4::VarCorr(m1)\nlme4qtl::VarProp(m1)\n```\n\nProfile the variance components (h2) to get the 95% confidence intervals.\nThe method functions `profile` and `confint` are implemented in lme4.\nNote that a different model `m2` is used,\nbecause profiling is prone to errors/warnings if model fit is poor.\n\n```{r ex_prof, cache = T}\nm2 \u003c- relmatLmer(trait2 ~ (1|ID), dat40, relmat = list(ID = kin2)) \nVarProp(m2)\n\nprof \u003c- profile(m2)\nprof_prop \u003c- lme4qtl::varpropProf(prof) # convert to proportions\nconfint(prof_prop)\n```\n\n```{r plot_prof, fig.width = 8, fig.height = 4}\ndensityplot(prof)\ndensityplot(prof_prop)\n```\n\n```{r plot_prof_splom}\ntry(splom(prof)) \n\nprof_clean \u003c- na.omit(prof) # caution: NAs are indicators of poor fits\nsplom(prof_clean)\n```\n\nFit a model with genetic and residual variances that differ by gender (sex-specificity model).\nThe formula syntax with `dummy` (see `?lme4::dummy`) is applied to the residual variance `(1|RID)`\nto cancel the residual correlation. \n\n```{r gxe, cache = T}\ndat40 \u003c- within(dat40, RID \u003c- ID) # replicate ID \n\nm4 \u003c- relmatLmer(trait2 ~ SEX + (0 + SEX|ID) + (0 + dummy(SEX)|RID), dat40, relmat = list(ID = kin2)) \nVarCorr(m4)\n```\n\nAn example of parameter constraints that make the genetic variance between genders equal.\n\n```{r gex_eq, cache = T}\nm4_vareq \u003c- relmatLmer(trait2 ~ SEX + (0 + SEX|ID) + (0 + dummy(SEX)|RID), dat40, relmat = list(ID = kin2),\n  vcControl = list(vareq = list(id = c(1, 2, 3)))) \nVarCorr(m4_vareq)\n```\n\nAnother example of parameter constraint that implies the genetic correlation between genders equal to 1.\n\n```{r gxe_rho1, cache = T}\nm4_rhog1 \u003c- relmatLmer(trait2 ~ SEX + (0 + SEX|ID) + (0 + dummy(SEX)|RID), dat40, relmat = list(ID = kin2),\n  vcControl = list(rho1 = list(id = 3))) \nVarCorr(m4_rhog1)\n```\n\nFit a model for binary trait.\n\n```{r ex_fit3, cache = T}\nm3 \u003c- relmatGlmer(trait1bin ~ (1|ID), dat40, relmat = list(ID = kin2), family = binomial(probit))\nm3\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvariani%2Flme4qtl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvariani%2Flme4qtl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvariani%2Flme4qtl/lists"}