Skip to content

Commit

Permalink
Updating tutorial
Browse files Browse the repository at this point in the history
  • Loading branch information
“gabrielgesteira” committed Aug 26, 2022
1 parent 84d73f2 commit 97fd871
Show file tree
Hide file tree
Showing 4 changed files with 168 additions and 71 deletions.
127 changes: 127 additions & 0 deletions docs/1-tutorial.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
## Installing packages
## install.packages("qtlpoly")
##install.packages("mappoly")
## ##install.packages("devtools")
## devtools::install_github("gabrielgesteira/qtlpoly")

## Loading packages
library(qtlpoly)
library(mappoly)
plot_map_list(maps4x)
plot(maps4x[[1]])
summary_maps(maps4x)
head(pheno4x)

## Calculating genotype probabilities
genoprob4x = lapply(maps4x, calc_genoprob)

## Putting geno + pheno together
data = read_data(ploidy = 4, geno.prob = genoprob4x, pheno = pheno4x, step = 1)

## Viewing dataset
print(data, detailed = TRUE)

## Adjusting null model
null.mod = null_model(data = data, n.clusters = 4)

## Viewing null model
print(null.mod)

## Performing first search round
search.mod = search_qtl(data = data, model = null.mod, w.size = 15, sig.fwd = 0.01, n.clusters = 4)

## Visualizing results
print(search.mod)

## Performing model optimization
optimize.mod = optimize_qtl(data = data, model = search.mod, sig.bwd = 0.0001, n.clusters = 4)

## Visualizing results
print(optimize.mod)

## Performing another search round
search.mod2 = search_qtl(data=data, model = optimize.mod, sig.fwd = 0.0001, n.clusters = 4)

## Visualizing results
print(search.mod2)

## Genomewide profiling with final set of QTL
profile.mod = profile_qtl(data = data, model = optimize.mod, d.sint = 1.5, polygenes = FALSE, n.clusters = 4)

## Visualizing results
print(profile.mod)

## Checking lower SI
print(profile.mod, sint = "lower")

## Checking upper SI
print(profile.mod, sint = "upper")

## Performing automatic search
remim.mod = remim(data = data, w.size = 15, sig.fwd = 0.01, sig.bwd = 0.0001, d.sint = 1.5, n.clusters = 4)

## Visualizing results
print(remim.mod)

## Checking lower SI
print(remim.mod, sint = "lower")

## Checking upper SI
print(remim.mod, sint = "upper")

## Plotting profile
for(p in remim.mod$pheno.col) plot_profile(data = data, model = remim.mod, pheno.col = p, ylim = c(0,10))

## Plotting profile
plot_profile(data = data, model = remim.mod, grid = TRUE)
plot_profile(data = data, model = remim.mod, grid = FALSE)

## Plotting QTL SI
plot_sint(data = data, model = remim.mod)

## Calculate metrics
fitted.mod = fit_model(data=data, model=remim.mod, probs="joint", polygenes="none")

## Viewing results
summary(fitted.mod)

## Plotting QTL info
plot_qtl(data = data, model = remim.mod, fitted = fitted.mod, drop.pheno = FALSE)

## Account for allele effects
est.effects = qtl_effects(ploidy = 4, fitted = fitted.mod)

## Plot allele effects
plot(est.effects)

## Calculate breeding values
y.hat = breeding_values(data = data, fitted = fitted.mod)

## Plot BV
plot(y.hat)

## FEIM
## Perform permutations
perm = permutations(data = data, n.sim = 1000, n.clusters = 4)

## Check permutations
print(perm)

## Define significance threshold
(sig.lod = perm$sig.lod$`0.95`)

## Adjust FEIM model
feim.mod = feim(data = data, w.size = 15, sig.lod = sig.lod)

## Viewing FEIM results
print(feim.mod)

## Plotting FEIM results
plot_profile(data = data, model = feim.mod, grid = TRUE)

## Exporting results to VIEWpoly
## save(maps4x, file="mappoly.maps.RData")
## save(data, file="qtlpoly.data.RData")
## save(remim.mod, file="qtlpoly.remim.mod.RData")
## save(fitted.mod, file="qtlpoly.fitted.mod.RData")
## save(est.effects, file="qtlpoly.est.effects.RData")
16 changes: 14 additions & 2 deletions docs/1-tutorial.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ knitr::opts_chunk$set(eval = TRUE, cache = TRUE, echo = TRUE, results = 'hold',

# Introduction

The R package `qtlpoly` (v. 0.2.3) [@Pereira2020] is an under development software to map multiple quantitative trait loci (QTL) in full-sib families of outcrossing autopolyploid species. It is based on the following random-effect model:
The R package `qtlpoly` (v. 0.2.4) [@Pereira2020] is an under development software to map multiple quantitative trait loci (QTL) in full-sib families of outcrossing autopolyploid species. It is based on the following random-effect model:

$$\boldsymbol{y} = \boldsymbol{1}\mu + \sum_{q=1}^Q \boldsymbol{g}_q + \boldsymbol{e}$$

Expand All @@ -56,7 +56,7 @@ install.packages("qtlpoly")

To use the development version, please run the following commands to install `qtlpoly` and all of its dependencies:

```{r, eval=TRUE}
```{r, eval=FALSE}
##install.packages("devtools")
devtools::install_github("gabrielgesteira/qtlpoly")
```
Expand Down Expand Up @@ -445,6 +445,18 @@ plot_profile(data = data, model = feim.mod, grid = TRUE)

<!-- Notice that one QTL on LG 1 was not detected for the trait 'T32' (false negative), while one QTL on LG 3 for the trait 'T45' was wrongly assigned (false positive). This exemplifies the power of multiple-QTL models over the single-QTL ones. Therefore, the FEIM model may be recommended only as a first, quick approach, but not as the ultimate model for detecting QTL in autopolyploid species. -->

# Exporting to VIEWpoly

One can export the results from `MAPpoly` and `QTLpoly` to visualize them in the R package `VIEWpoly` with the commands below:

```{r, eval=FALSE}
save(maps4x, file="mappoly.maps.RData")
save(data, file="qtlpoly.data.RData")
save(remim.mod, file="qtlpoly.remim.mod.RData")
save(fitted.mod, file="qtlpoly.fitted.mod.RData")
save(est.effects, file="qtlpoly.est.effects.RData")
```

# Acknowledgments

This package has been developed as part of the [Genomic Tools for Sweetpotato Improvement](https://sweetpotatogenomics.cals.ncsu.edu/) (GT4SP) and [SweetGAINS](https://cgspace.cgiar.org/handle/10568/106838) projects, both funded by [Bill \& Melinda Gates Foundation](https://www.gatesfoundation.org/).
Expand Down
48 changes: 13 additions & 35 deletions docs/1-tutorial.html
Original file line number Diff line number Diff line change
Expand Up @@ -1627,7 +1627,7 @@ <h4 class="date">2022-08-26</h4>

<div id="introduction" class="section level1">
<h1>Introduction</h1>
<p>The R package <code>qtlpoly</code> (v. 0.2.3) <span class="citation">(Pereira et al. 2020)</span> is an under development
<p>The R package <code>qtlpoly</code> (v. 0.2.4) <span class="citation">(Pereira et al. 2020)</span> is an under development
software to map multiple quantitative trait loci (QTL) in full-sib
families of outcrossing autopolyploid species. It is based on the
following random-effect model:</p>
Expand Down Expand Up @@ -1659,40 +1659,7 @@ <h2>Install and load the <code>qtlpoly</code> package and data</h2>
<p>To use the development version, please run the following commands to
install <code>qtlpoly</code> and all of its dependencies:</p>
<div class="sourceCode" id="cb2"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="sc">&gt;</span> <span class="do">##install.packages(&quot;devtools&quot;)</span></span>
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a><span class="er">&gt;</span> devtools<span class="sc">::</span><span class="fu">install_github</span>(<span class="st">&quot;gabrielgesteira/qtlpoly&quot;</span>)</span>
<span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a><span class="do">## Downloading GitHub repo gabrielgesteira/qtlpoly@HEAD</span></span>
<span id="cb2-4"><a href="#cb2-4" aria-hidden="true" tabindex="-1"></a><span class="do">## Installing 17 packages: pillar, tibble, rlang, ps, processx, pkgload, evaluate, callr, Rcpp, nloptr, viridisLite, farver, lme4, scales, RcppArmadillo, gtools, ggplot2</span></span>
<span id="cb2-5"><a href="#cb2-5" aria-hidden="true" tabindex="-1"></a><span class="do">## Installing packages into &#39;/home/gdesiqu/R/x86_64-pc-linux-gnu-library/4.2&#39;</span></span>
<span id="cb2-6"><a href="#cb2-6" aria-hidden="true" tabindex="-1"></a><span class="do">## (as &#39;lib&#39; is unspecified)</span></span>
<span id="cb2-7"><a href="#cb2-7" aria-hidden="true" tabindex="-1"></a><span class="do">## Installing package into &#39;/home/gdesiqu/R/x86_64-pc-linux-gnu-library/4.2&#39;</span></span>
<span id="cb2-8"><a href="#cb2-8" aria-hidden="true" tabindex="-1"></a><span class="do">## (as &#39;lib&#39; is unspecified)</span></span>
<span id="cb2-9"><a href="#cb2-9" aria-hidden="true" tabindex="-1"></a><span class="do">## Warning in i.p(...): installation of package &#39;/tmp/RtmpJHrUuN/file43d3e1185e802/</span></span>
<span id="cb2-10"><a href="#cb2-10" aria-hidden="true" tabindex="-1"></a><span class="do">## qtlpoly_0.2.4.tar.gz&#39; had non-zero exit status</span></span>
<span id="cb2-11"><a href="#cb2-11" aria-hidden="true" tabindex="-1"></a><span class="do">## pillar (1.7.0 -&gt; 1.8.1 ) [CRAN]</span></span>
<span id="cb2-12"><a href="#cb2-12" aria-hidden="true" tabindex="-1"></a><span class="do">## tibble (3.1.6 -&gt; 3.1.8 ) [CRAN]</span></span>
<span id="cb2-13"><a href="#cb2-13" aria-hidden="true" tabindex="-1"></a><span class="do">## rlang (1.0.2 -&gt; 1.0.4 ) [CRAN]</span></span>
<span id="cb2-14"><a href="#cb2-14" aria-hidden="true" tabindex="-1"></a><span class="do">## ps (1.7.0 -&gt; 1.7.1 ) [CRAN]</span></span>
<span id="cb2-15"><a href="#cb2-15" aria-hidden="true" tabindex="-1"></a><span class="do">## processx (3.5.3 -&gt; 3.7.0 ) [CRAN]</span></span>
<span id="cb2-16"><a href="#cb2-16" aria-hidden="true" tabindex="-1"></a><span class="do">## pkgload (1.2.4 -&gt; 1.3.0 ) [CRAN]</span></span>
<span id="cb2-17"><a href="#cb2-17" aria-hidden="true" tabindex="-1"></a><span class="do">## evaluate (0.15 -&gt; 0.16 ) [CRAN]</span></span>
<span id="cb2-18"><a href="#cb2-18" aria-hidden="true" tabindex="-1"></a><span class="do">## callr (3.7.0 -&gt; 3.7.2 ) [CRAN]</span></span>
<span id="cb2-19"><a href="#cb2-19" aria-hidden="true" tabindex="-1"></a><span class="do">## Rcpp (1.0.8.3 -&gt; 1.0.9 ) [CRAN]</span></span>
<span id="cb2-20"><a href="#cb2-20" aria-hidden="true" tabindex="-1"></a><span class="do">## nloptr (2.0.0 -&gt; 2.0.3 ) [CRAN]</span></span>
<span id="cb2-21"><a href="#cb2-21" aria-hidden="true" tabindex="-1"></a><span class="do">## viridisLite (0.4.0 -&gt; 0.4.1 ) [CRAN]</span></span>
<span id="cb2-22"><a href="#cb2-22" aria-hidden="true" tabindex="-1"></a><span class="do">## farver (2.1.0 -&gt; 2.1.1 ) [CRAN]</span></span>
<span id="cb2-23"><a href="#cb2-23" aria-hidden="true" tabindex="-1"></a><span class="do">## lme4 (1.1-29 -&gt; 1.1-30 ) [CRAN]</span></span>
<span id="cb2-24"><a href="#cb2-24" aria-hidden="true" tabindex="-1"></a><span class="do">## scales (1.2.0 -&gt; 1.2.1 ) [CRAN]</span></span>
<span id="cb2-25"><a href="#cb2-25" aria-hidden="true" tabindex="-1"></a><span class="do">## RcppArmad... (0.11.1.1.0 -&gt; 0.11.2.3.1) [CRAN]</span></span>
<span id="cb2-26"><a href="#cb2-26" aria-hidden="true" tabindex="-1"></a><span class="do">## gtools (3.9.2 -&gt; 3.9.3 ) [CRAN]</span></span>
<span id="cb2-27"><a href="#cb2-27" aria-hidden="true" tabindex="-1"></a><span class="do">## ggplot2 (3.3.5 -&gt; 3.3.6 ) [CRAN]</span></span>
<span id="cb2-28"><a href="#cb2-28" aria-hidden="true" tabindex="-1"></a><span class="do">## * checking for file ‘/tmp/RtmpJHrUuN/remotes43d3ef58f51d/gabrielgesteira-QTLpoly-847ee41/DESCRIPTION’ ... OK</span></span>
<span id="cb2-29"><a href="#cb2-29" aria-hidden="true" tabindex="-1"></a><span class="do">## * preparing ‘qtlpoly’:</span></span>
<span id="cb2-30"><a href="#cb2-30" aria-hidden="true" tabindex="-1"></a><span class="do">## * checking DESCRIPTION meta-information ... OK</span></span>
<span id="cb2-31"><a href="#cb2-31" aria-hidden="true" tabindex="-1"></a><span class="do">## * cleaning src</span></span>
<span id="cb2-32"><a href="#cb2-32" aria-hidden="true" tabindex="-1"></a><span class="do">## * checking for LF line-endings in source and make files and shell scripts</span></span>
<span id="cb2-33"><a href="#cb2-33" aria-hidden="true" tabindex="-1"></a><span class="do">## * checking for empty or unneeded directories</span></span>
<span id="cb2-34"><a href="#cb2-34" aria-hidden="true" tabindex="-1"></a><span class="do">## * building ‘qtlpoly_0.2.4.tar.gz’</span></span>
<span id="cb2-35"><a href="#cb2-35" aria-hidden="true" tabindex="-1"></a><span class="do">## Warning: invalid uid value replaced by that for user &#39;nobody&#39;</span></span></code></pre></div>
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a><span class="er">&gt;</span> devtools<span class="sc">::</span><span class="fu">install_github</span>(<span class="st">&quot;gabrielgesteira/qtlpoly&quot;</span>)</span></code></pre></div>
<p>Then, use the function <code>library()</code> – or
<code>require()</code> – to load the package:</p>
<div class="sourceCode" id="cb3"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="sc">&gt;</span> <span class="fu">library</span>(qtlpoly) </span></code></pre></div>
Expand Down Expand Up @@ -2696,6 +2663,17 @@ <h2>Interval mapping</h2>
<!-- Notice that one QTL on LG 1 was not detected for the trait 'T32' (false negative), while one QTL on LG 3 for the trait 'T45' was wrongly assigned (false positive). This exemplifies the power of multiple-QTL models over the single-QTL ones. Therefore, the FEIM model may be recommended only as a first, quick approach, but not as the ultimate model for detecting QTL in autopolyploid species. -->
</div>
</div>
<div id="exporting-to-viewpoly" class="section level1">
<h1>Exporting to VIEWpoly</h1>
<p>One can export the results from <code>MAPpoly</code> and
<code>QTLpoly</code> to visualize them in the R package
<code>VIEWpoly</code> with the commands below:</p>
<div class="sourceCode" id="cb44"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb44-1"><a href="#cb44-1" aria-hidden="true" tabindex="-1"></a><span class="sc">&gt;</span> <span class="fu">save</span>(maps4x, <span class="at">file=</span><span class="st">&quot;mappoly.maps.RData&quot;</span>)</span>
<span id="cb44-2"><a href="#cb44-2" aria-hidden="true" tabindex="-1"></a><span class="sc">&gt;</span> <span class="fu">save</span>(data, <span class="at">file=</span><span class="st">&quot;qtlpoly.data.RData&quot;</span>)</span>
<span id="cb44-3"><a href="#cb44-3" aria-hidden="true" tabindex="-1"></a><span class="sc">&gt;</span> <span class="fu">save</span>(remim.mod, <span class="at">file=</span><span class="st">&quot;qtlpoly.remim.mod.RData&quot;</span>)</span>
<span id="cb44-4"><a href="#cb44-4" aria-hidden="true" tabindex="-1"></a><span class="sc">&gt;</span> <span class="fu">save</span>(fitted.mod, <span class="at">file=</span><span class="st">&quot;qtlpoly.fitted.mod.RData&quot;</span>)</span>
<span id="cb44-5"><a href="#cb44-5" aria-hidden="true" tabindex="-1"></a><span class="sc">&gt;</span> <span class="fu">save</span>(est.effects, <span class="at">file=</span><span class="st">&quot;qtlpoly.est.effects.RData&quot;</span>)</span></code></pre></div>
</div>
<div id="acknowledgments" class="section level1">
<h1>Acknowledgments</h1>
<p>This package has been developed as part of the <a href="https://sweetpotatogenomics.cals.ncsu.edu/">Genomic Tools for
Expand Down
48 changes: 14 additions & 34 deletions docs/1-tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ editor_options:

# Introduction

The R package `qtlpoly` (v. 0.2.3) [@Pereira2020] is an under development software to map multiple quantitative trait loci (QTL) in full-sib families of outcrossing autopolyploid species. It is based on the following random-effect model:
The R package `qtlpoly` (v. 0.2.4) [@Pereira2020] is an under development software to map multiple quantitative trait loci (QTL) in full-sib families of outcrossing autopolyploid species. It is based on the following random-effect model:

$$\boldsymbol{y} = \boldsymbol{1}\mu + \sum_{q=1}^Q \boldsymbol{g}_q + \boldsymbol{e}$$

Expand All @@ -59,39 +59,6 @@ To use the development version, please run the following commands to install `qt
```r
> ##install.packages("devtools")
> devtools::install_github("gabrielgesteira/qtlpoly")
## Downloading GitHub repo gabrielgesteira/qtlpoly@HEAD
## Installing 17 packages: pillar, tibble, rlang, ps, processx, pkgload, evaluate, callr, Rcpp, nloptr, viridisLite, farver, lme4, scales, RcppArmadillo, gtools, ggplot2
## Installing packages into '/home/gdesiqu/R/x86_64-pc-linux-gnu-library/4.2'
## (as 'lib' is unspecified)
## Installing package into '/home/gdesiqu/R/x86_64-pc-linux-gnu-library/4.2'
## (as 'lib' is unspecified)
## Warning in i.p(...): installation of package '/tmp/RtmpJHrUuN/file43d3e1185e802/
## qtlpoly_0.2.4.tar.gz' had non-zero exit status
## pillar (1.7.0 -> 1.8.1 ) [CRAN]
## tibble (3.1.6 -> 3.1.8 ) [CRAN]
## rlang (1.0.2 -> 1.0.4 ) [CRAN]
## ps (1.7.0 -> 1.7.1 ) [CRAN]
## processx (3.5.3 -> 3.7.0 ) [CRAN]
## pkgload (1.2.4 -> 1.3.0 ) [CRAN]
## evaluate (0.15 -> 0.16 ) [CRAN]
## callr (3.7.0 -> 3.7.2 ) [CRAN]
## Rcpp (1.0.8.3 -> 1.0.9 ) [CRAN]
## nloptr (2.0.0 -> 2.0.3 ) [CRAN]
## viridisLite (0.4.0 -> 0.4.1 ) [CRAN]
## farver (2.1.0 -> 2.1.1 ) [CRAN]
## lme4 (1.1-29 -> 1.1-30 ) [CRAN]
## scales (1.2.0 -> 1.2.1 ) [CRAN]
## RcppArmad... (0.11.1.1.0 -> 0.11.2.3.1) [CRAN]
## gtools (3.9.2 -> 3.9.3 ) [CRAN]
## ggplot2 (3.3.5 -> 3.3.6 ) [CRAN]
## * checking for file ‘/tmp/RtmpJHrUuN/remotes43d3ef58f51d/gabrielgesteira-QTLpoly-847ee41/DESCRIPTION’ ... OK
## * preparing ‘qtlpoly’:
## * checking DESCRIPTION meta-information ... OK
## * cleaning src
## * checking for LF line-endings in source and make files and shell scripts
## * checking for empty or unneeded directories
## * building ‘qtlpoly_0.2.4.tar.gz’
## Warning: invalid uid value replaced by that for user 'nobody'
```

Then, use the function `library()` -- or `require()` -- to load the package:
Expand Down Expand Up @@ -1075,6 +1042,19 @@ Finally, one may want to plot the profiles and compare to the [plot profiles] fr

<!-- Notice that one QTL on LG 1 was not detected for the trait 'T32' (false negative), while one QTL on LG 3 for the trait 'T45' was wrongly assigned (false positive). This exemplifies the power of multiple-QTL models over the single-QTL ones. Therefore, the FEIM model may be recommended only as a first, quick approach, but not as the ultimate model for detecting QTL in autopolyploid species. -->

# Exporting to VIEWpoly

One can export the results from `MAPpoly` and `QTLpoly` to visualize them in the R package `VIEWpoly` with the commands below:


```r
> save(maps4x, file="mappoly.maps.RData")
> save(data, file="qtlpoly.data.RData")
> save(remim.mod, file="qtlpoly.remim.mod.RData")
> save(fitted.mod, file="qtlpoly.fitted.mod.RData")
> save(est.effects, file="qtlpoly.est.effects.RData")
```

# Acknowledgments

This package has been developed as part of the [Genomic Tools for Sweetpotato Improvement](https://sweetpotatogenomics.cals.ncsu.edu/) (GT4SP) and [SweetGAINS](https://cgspace.cgiar.org/handle/10568/106838) projects, both funded by [Bill \& Melinda Gates Foundation](https://www.gatesfoundation.org/).
Expand Down

0 comments on commit 97fd871

Please sign in to comment.