{"id":32203665,"url":"https://github.com/fboehm/qtl2pleio","last_synced_at":"2026-02-21T01:31:32.053Z","repository":{"id":56935411,"uuid":"104493705","full_name":"fboehm/qtl2pleio","owner":"fboehm","description":"Testing pleiotropy vs. separate QTL in multiparental populations","archived":false,"fork":false,"pushed_at":"2021-07-13T20:20:32.000Z","size":5482,"stargazers_count":5,"open_issues_count":11,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2026-02-01T11:34:48.469Z","etag":null,"topics":["multiparental-populations","quantitative-genetics","quantitative-trait"],"latest_commit_sha":null,"homepage":"","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fboehm.png","metadata":{"files":{"readme":"README.Rmd","changelog":"NEWS.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":"codemeta.json","zenodo":".zenodo.json"}},"created_at":"2017-09-22T16:06:34.000Z","updated_at":"2024-10-08T05:42:04.000Z","dependencies_parsed_at":"2022-08-21T06:50:44.483Z","dependency_job_id":null,"html_url":"https://github.com/fboehm/qtl2pleio","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/fboehm/qtl2pleio","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fboehm%2Fqtl2pleio","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fboehm%2Fqtl2pleio/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fboehm%2Fqtl2pleio/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fboehm%2Fqtl2pleio/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fboehm","download_url":"https://codeload.github.com/fboehm/qtl2pleio/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fboehm%2Fqtl2pleio/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29110548,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-05T03:44:17.043Z","status":"ssl_error","status_checked_at":"2026-02-05T03:44:12.077Z","response_time":65,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["multiparental-populations","quantitative-genetics","quantitative-trait"],"created_at":"2025-10-22T04:44:56.508Z","updated_at":"2026-02-21T01:31:32.016Z","avatar_url":"https://github.com/fboehm.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 README.Rmd --\u003e\n\n\n\n```{r setup, include = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\",\n  out.width = \"100%\",\n  message = FALSE,\n  warning = FALSE\n)\n```\n\n# qtl2pleio\n\n[![R-CMD-check](https://github.com/fboehm/qtl2pleio/workflows/R-CMD-check/badge.svg)](https://github.com/fboehm/qtl2pleio/actions)\n[![CRAN_Status_Badge](https://www.r-pkg.org/badges/version/qtl2pleio)](https://cran.r-project.org/package=qtl2pleio)\n[![Coverage Status](https://img.shields.io/codecov/c/github/fboehm/qtl2pleio/master.svg)](https://codecov.io/github/fboehm/qtl2pleio?branch=master)\n[![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)\n[![status](https://joss.theoj.org/papers/66bca5dc3d2e72b6259159bad07aafaf/status.svg)](https://joss.theoj.org/papers/10.21105/joss.01435)\n[![DOI](https://zenodo.org/badge/104493705.svg)](https://zenodo.org/badge/latestdoi/104493705)\n\n\n\n\n## Overview\n\n`qtl2pleio` is a software package for use with the [R statistical computing environment](https://cran.r-project.org/). `qtl2pleio` is freely available for download and use. I share it under the [MIT license](https://opensource.org/licenses/mit-license.php). The user will also want to download and install the [`qtl2` R package](https://kbroman.org/qtl2/).\n\nClick [here](https://mybinder.org/v2/gh/fboehm/qtl2pleio/master?urlpath=rstudio) to explore `qtl2pleio` within a live [Rstudio](https://rstudio.com/) session in \"the cloud\".\n\n## Contributor guidelines\n\nWe eagerly welcome contributions to `qtl2pleio`. All pull requests will be considered. Features requests and bug reports may be filed as Github issues. All contributors must abide by the [code of conduct](https://github.com/fboehm/qtl2pleio/blob/master/CONDUCT.md). \n\n## Technical support \n\nFor technical support, please open a Github issue. If you're just getting started with `qtl2pleio`, please examine the [vignettes](https://fboehm.us/software/qtl2pleio) on the [package's web site](https://fboehm.us/software/qtl2pleio). You can also email \u003cfrederick.boehm@gmail.com\u003e for assistance. \n\n\n\n\n## Goals\n\nThe goal of `qtl2pleio` is, for a pair of traits that show evidence for\na QTL in a common region, to distinguish between pleiotropy (the null\nhypothesis, that they are affected by a common QTL) and the\nalternative that they are affected by separate QTL. It extends the\nlikelihood ratio test of [Jiang and Zeng\n(1995)](https://www.genetics.org/content/140/3/1111.long) for\nmultiparental populations, such as Diversity Outbred mice, including\nthe use of multivariate polygenic random effects to account for population structure.\n`qtl2pleio` data structures are those used in the\n[`rqtl/qtl2`](https://kbroman.org/qtl2/) package.\n\n\n## Installation\n\n\nTo install qtl2pleio, use `install_github()` from the\n[devtools](https://devtools.r-lib.org) package.\n\n\n```{r install-qtl2pleio, eval = FALSE}\ninstall.packages(\"qtl2pleio\")\n```\n\nYou may also wish to install the [R/qtl2](https://kbroman.org/qtl2/). We\nwill use it below.\n\n```{r install-qtl2, eval = FALSE}\ninstall.packages(\"qtl2\")\n```\n\n\n## Example\n\nBelow, we walk through an example analysis with Diversity Outbred\nmouse data. We need a number of preliminary steps before we can\nperform our test of pleiotropy vs. separate QTL. Many procedures rely\non the R package `qtl2`. We first load the `qtl2`\nand `qtl2pleio` packages.\n\n```{r pkgs}\nlibrary(qtl2)\nlibrary(qtl2pleio)\nlibrary(ggplot2)\n```\n\n\n### Reading data from `qtl2data` repository on github\n\nWe'll consider the\n[`DOex`](https://github.com/rqtl/qtl2data/tree/master/DOex/) data in\nthe [`qtl2data`](https://github.com/rqtl/qtl2data/) repository.\nWe'll download the DOex.zip file before calculating founder allele dosages.\n\n```{r download-DOex}\nfile \u003c- paste0(\"https://raw.githubusercontent.com/rqtl/\",\n               \"qtl2data/master/DOex/DOex.zip\")\nDOex \u003c- read_cross2(file)\n```\n\n\n```{r calc-genoprobs}\nprobs \u003c- calc_genoprob(DOex)\n```\n\n\nLet's calculate the founder allele dosages from the 36-state genotype probabilities.\n\n```{r calc-allele-probs}\npr \u003c- genoprob_to_alleleprob(probs)\n```\n\n\nWe now have an allele probabilities object stored in `pr`.\n\n```{r check-pr}\nnames(pr)\ndim(pr$`2`)\n```\n\nWe see that `pr` is a list of 3 three-dimensional arrays - one array for each of 3 chromosomes.\n\n### Kinship calculations\n\nFor our statistical model, we need a kinship matrix. We get one with the `calc_kinship` function in the `rqtl/qtl2` package.\n\n\n```{r calc-kinship}\nkinship \u003c- calc_kinship(probs = pr, type = \"loco\")\n```\n\n### Statistical model specification\n\nWe use the multivariate linear mixed effects model:\n\n$$\n\\text{vec}(Y) = X \\text{vec}(B) + \\text{vec}(G) + \\text{vec}(E)\n$$\n\nwhere $Y$ contains phenotypes, X contains founder allele probabilities and covariates, and B contains founder allele effects. G is the polygenic random effects, while E is the random errors. We provide more details in the vignette.\n\n\n\n### Simulating phenotypes with `qtl2pleio::sim1`\n\n\nThe function to simulate phenotypes in `qtl2pleio` is `sim1`.\n\n```{r pp-def}\n# set up the design matrix, X\npp \u003c- pr[[2]] #we'll work with Chr 3's genotype data\n```\n\n\n```{r X-def}\n#Next, we prepare a design matrix X\nX \u003c- gemma2::stagger_mats(pp[ , , 50], pp[ , , 50])\n```\n\n```{r B-def}\n# assemble B matrix of allele effects\nB \u003c- matrix(data = c(-1, -1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, 1, 1, 1), nrow = 8, ncol = 2, byrow = FALSE)\n# set.seed to ensure reproducibility\nset.seed(2018-01-30)\nSig \u003c- calc_Sigma(Vg = diag(2), Ve = diag(2), kinship = kinship[[2]])\n# call to sim1\nYpre \u003c- sim1(X = X, B = B, Sigma = Sig)\nY \u003c- matrix(Ypre, nrow = 261, ncol = 2, byrow = FALSE)\nrownames(Y) \u003c- rownames(pp)\ncolnames(Y) \u003c- c(\"tr1\", \"tr2\")\n```\n\nLet's perform univariate QTL mapping for each of the two traits in the Y matrix.\n\n```{r 1d-scans}\ns1 \u003c- scan1(genoprobs = pr, pheno = Y, kinship = kinship)\n```\n\nHere is a plot of the results.\n\n```{r 1d-lod-plots, include=FALSE}\nplot(s1, DOex$pmap)\nplot(s1, DOex$pmap, lod=2, col=\"violetred\", add=TRUE)\nlegend(\"topleft\", colnames(s1), lwd=2, col=c(\"darkslateblue\", \"violetred\"), bg=\"gray92\")\n```\n\n```{r, echo = FALSE}\nknitr::include_graphics(\"https://raw.githubusercontent.com/fboehm/qtl2pleio/master/man/figures/README-1d-lod-plots-1.png\")\n```\n\nAnd here are the observed QTL peaks with LOD \u003e 8.\n\n```{r find-peaks}\nfind_peaks(s1, map = DOex$pmap, threshold=8)\n```\n\n\n\n\n\n### Perform two-dimensional scan as first step in pleiotropy vs. separate QTL hypothesis test\n\n\nWe now have the inputs that we need to do a pleiotropy vs. separate QTL test. We have the founder allele dosages for one chromosome, *i.e.*, Chr 3, in the R object `pp`, the matrix of two trait measurements in `Y`, and a LOCO-derived kinship matrix, `kinship[[2]]`.\n\n\n```{r 2d-scan}\nout \u003c- suppressMessages(scan_pvl(probs = pp,\n                pheno = Y,\n                kinship = kinship[[2]], # 2nd entry in kinship list is Chr 3\n                start_snp = 38,\n                n_snp = 25\n                ))\n```\n\n\n### Create a profile LOD plot to visualize results of two-dimensional scan\n\nTo visualize results from our two-dimensional scan, we calculate profile LOD for each trait. The code below makes use of the R package `ggplot2` to plot profile LODs over the scan region.\n\n\n```{r profile-plot, include = TRUE}\nlibrary(dplyr)\nout %\u003e%\n  calc_profile_lods() %\u003e%\n  add_pmap(pmap = DOex$pmap$`3`) %\u003e%\n  ggplot() + geom_line(aes(x = marker_position, y = profile_lod, colour = trait))\n```\n\n\n\n\n### Calculate the likelihood ratio test statistic for pleiotropy v separate QTL\n\nWe use the function `calc_lrt_tib` to calculate the likelihood ratio test statistic value for the specified traits and specified genomic region.\n\n```{r lrt-calc}\n(lrt \u003c- calc_lrt_tib(out))\n```\n\n### Bootstrap analysis to get p-values\n\n\nBefore we call `boot_pvl`, we need to identify the index (on the chromosome under study) of the marker that maximizes the likelihood under the pleiotropy constraint. To do this, we use the `qtl2pleio` function `find_pleio_peak_tib`.\n\n```{r get-pleio-index}\n(pleio_index \u003c- find_pleio_peak_tib(out, start_snp = 38))\n```\n\n\n\n```{r boot}\nset.seed(2018-11-25) # set for reproducibility purposes.\nb_out \u003c- suppressMessages(boot_pvl(probs = pp,\n         pheno = Y,\n         pleio_peak_index = pleio_index,\n         kinship = kinship[[2]], # 2nd element in kinship list is Chr 3\n         nboot = 10,\n         start_snp = 38,\n         n_snp = 25\n         ))\n```\n\n\n```{r pval}\n(pvalue \u003c- mean(b_out \u003e= lrt))\n```\n\n\n\n## Citation information\n\n```{r cite}\ncitation(\"qtl2pleio\")\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffboehm%2Fqtl2pleio","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffboehm%2Fqtl2pleio","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffboehm%2Fqtl2pleio/lists"}