---
title: "QTL detection in multiparental populations characterized in multiple environments"
author: "Vincent Garin"
date: "24/12/2022"
output: rmarkdown::html_vignette
bibliography: bibliography.bib
link-citations: yes
vignette: >
  %\VignetteIndexEntry{QTL detection in multiparental populations characterized in multiple environments}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
```

## Multiparental populations

::: {style="text-align: justify"}
Multiparental populations (MPPs) like the nested association mapping (NAM; @mcmullen_2009) or multi-parent advanced generation inter-cross (MAGIC; @cavanagh2008mutations) populations have emerged as central genetic resources for research and breeding purposes [@scott2020multi]. The diallels [@blanc_2006], the factorial designs or the collections of crosses developed in breeding programs [@wurschum_2012_fam] can also be considered as MPPs. We can classify MPPs given the use of intrecrossing. In a first type of MPPs, there is no intercrossing. Each genotype inherits its alleles from two parents. Those MPPs can be seen as a collection of crosses (e.g. NAM or factorial design). A second type of MPPs like MAGIC involve genotypes that are a mosaic of more than two parents or founders. In this package, we only consider the first type of MPPs without intercrossing or collections of crosses with shared parents.
:::

## MPP-ME QTL detection

::: {style="text-align: justify"}
Even though several statistical methodologies and software are available to perform QTL detection in MPPs, there is potentially few or no open-source solution for the detection of QTL in MPPs characterized in multiple environments (MPP-ME). In this extension of **_mppR_**, we propose a method to detect QTLs in MPP-ME data.
:::

## Model description

::: {style="text-align: justify"}
We start from the QTL detection model 3 described in [@garin2020multi]:

$$\underline{y}_{icj} = E_{j} + C_{cj} + x_{i_{q}p} * \beta_{pj} + \underline{GE}_{icj} + \underline{e}_{icj} \quad [1]$$

where $\underline{y}_{icj}$ is the genotype adjusted mean (e.g. BLUE) of genotype $i$ from cross $c$ in environment $j$. $E_{j}$ is a fixed environment term, $C_{cj}$ a fixed cross within environment interaction, $x_{i_{q}p}$ is the number of allele copies coming from parent $p$ at QTL position $q$, and $\beta_{pj}$ represent the QTL effect of parental allele $p$ in environment $j$. Different definitions of the QTL allelic effect are possible [@garin2017type]. In this version of the model we assumed that each parent carries a different allele and that each of those alleles can have an environmental specific effect. The model is therefore saturated with the estimation of $N_{env} * N_{par}$ effects with the most frequent allele set as the reference in all environments (e.g. the central or recurrent parent in NAM). In model 1, QTL terms are considered as fixed. Therefore, the user needs to provide best linear unbiased estimates (BLUEs) as trait value.

The term $GE_{icj}$ is the residual genetic variation and $e_{icj}$ the plot error term. In model 1 because genotype values are averaged over replication $e_{icj}$ and $GE_{icj}$ are confounded. The variance of the $(GE_{icj} + e_{icj})$ term can be modeled with different variance covariance (VCOV) structures. A first possibility is to assume a constant genotypic variance across environments $\sigma_{G}^{2}$ (compound symmetry - CS) and a unique variance for the plot error term $\sigma_{e}^{2}$:

$$V\begin{bmatrix} y_{i11} \\ y_{i'21} \\ y_{i12} \\ y_{i'22} \\ y_{i13} \\ y_{i'23} \end{bmatrix}
=
\begin{bmatrix} \sigma_{G}^{2} + \sigma_{e}^{2} & 0 & \sigma_{G}^{2} & 0 & \sigma_{G}^{2} & 0 \\
                0 & \sigma_{G}^{2} + \sigma_{e}^{2} & 0 & \sigma_{G}^{2} & 0 & \sigma_{G}^{2} \\
                \sigma_{G}^{2} & 0 & \sigma_{G}^{2} + \sigma_{e}^{2} & 0 & \sigma_{G}^{2} & 0 \\
                0 & \sigma_{G}^{2} & 0 & \sigma_{G}^{2} + \sigma_{e}^{2} & 0 & \sigma_{G}^{2} \\
                \sigma_{G}^{2} & 0 & \sigma_{G}^{2} & 0 & \sigma_{G}^{2} + \sigma_{e}^{2} & 0 \\
                0 & \sigma_{G}^{2} & 0 & \sigma_{G}^{2} & 0 & \sigma_{G}^{2} + \sigma_{e}^{2} \\
\end{bmatrix}$$

The CS model requires the estimation of a single term ($\sigma_{G}^{2}$) to describe genetic the covariance between all pairs of environments. This model assumes that the background polygenic effect (effect of all genome positions except the tested QTL and cofactors) is the same in all environments [@van2001some].

A more realistic option called unstructured (UN) model allows the genetic covariance to be different in every pairs of environments. From a genetic point of view, it means that a set of genes have a different effect in each environments [@van2001some]. In the unstructured model, each pair of environment get a specific genetic covariance term $cov(y..j, y..j') = \sigma_{G_{jj'}}^{2}$

$$V\begin{bmatrix} y_{i11} \\ y_{i'21} \\ y_{i12} \\ y_{i'22} \\ y_{i13} \\ y_{i'23} \end{bmatrix}
=
\begin{bmatrix} \sigma_{G_{1}}^{2} + \sigma_{e}^{2} & 0 & \sigma_{G_{12}} & 0 & \sigma_{G_{13}} & 0 \\
                0 & \sigma_{G_{1}}^{2} + \sigma_{e}^{2} & 0 & \sigma_{G_{12}} & 0 & \sigma_{G_{13}} \\
                \sigma_{G_{12}} & 0 & \sigma_{G_{2}}^{2} + \sigma_{e}^{2} & 0 & \sigma_{G_{23}} & 0 \\
                0 & \sigma_{G_{12}} & 0 & \sigma_{G_{2}}^{2} + \sigma_{e}^{2} & 0 & \sigma_{G_{23}} \\
                \sigma_{G_{13}} & 0 & \sigma_{G_{23}} & 0 & \sigma_{G_{3}}^{2} + \sigma_{e}^{2} & 0 \\
                0 & \sigma_{G_{13}} & 0 & \sigma_{G_{23}} & 0 & \sigma_{G_{3}}^{2} + \sigma_{e}^{2} \\
\end{bmatrix}$$

We considered the UN model as the default option.

:::

## QTL detection procedure

::: {style="text-align: justify"}

The QTL detection procedure is composed of the following steps:

1. SIM scan
2. Selection of cofactors
3. CIM scan
4. Selection of QTLs
5. Estimation of the QTL allele effects
6. Estimation of the QTL R2 contribution
7. Plot of the QTL profile
8. Visualisation of the allelic significance along the genome

The function `mppGE_proc()` perform the whole procedure detailed above. For further details, see the examples below.

:::

## Approximate Wald statistic computation

::: {style="text-align: justify"}

The calculation of an 'exact' mixed model at each marker (QTL) position of the genome is computationally demanding, which can quickly make detection unfeasible, especially with large populations. Therefore, to reduce the computation demand for a genome scan, we implemented an approximate mixed model computation similar to the generalized least square strategy implemented in @kruijer2015marker or @garin2017type. The procedure consists of estimating a general VCOV ($\hat{V}$) using model 1 without the tested QTL position for the simple interval mapping (SIM) scan. For the composite interval mapping (CIM) model, $\hat{V}$ is estimated including the cofactors as fixed effect without the QTL position. For the CIM scan, there will be as many $\hat{V}$ as the number of cofactors combinations given cofactor exclusion around the tested position.

There are two option for the estimation of $\hat{V}$. In the first option we estimate a unique $\hat{V}$ taking all cofactors into consideration (`VCOV_data = "unique"`). In the second option, different $\hat{V}$ should be formed by removing the cofactor information that is too close of a tested QTL position (`VCOV_data = "minus_cof"`).

The statistical significance of the tested QTL position and the allelic effects is obtained by substituting $\hat{V}$ to get the following Wald statistic

$$W_Q = \beta^{T} [V(\beta)]^{-1} \beta \quad [2]$$

where,

$$\beta = (X^{T} \hat{V}^{-1} X)^{-1} X^T \hat{V}^{-1} y \quad [3]$$

and

$$V(\beta) = (X^{T} \hat{V}^{-1} X)^{-1}$$

$X$ represents the fixed effect matrix including the cross effect, the cofactors, and the QTL position, and $y$ is the vector of genotypic values. $W_Q \sim \chi_{d}^{2}$ with degree of freedom ($d$) equal to the number of tested QTL allelic effects (e.g. $(N_{par}-1) * N_{env}$ for a QTL term with environment-specific allelic effects).

:::

## QTL effects estimation

::: {style="text-align: justify"}

It is possible to estimate the QTL parental allelic effect using model 1. Model 1 allows the estimation of QTL allelic effect for each parents in each environment. One parent is set as reference. By default, it is the most frequent parental allele. Therefore, in populations like the nested association mapping (NAM) populations, the central parent is considered as the reference. The reference parent can be specified by the user through the `ref_par` argument. The parental QTL allelic effect must be interpreted as the extra effect of one allele copy with respect to the reference parent in the considered environment.

:::

## QTL by environment effect determination

After QTL detection, it is possible to determine if the QTL allelic effects interact with the environment or rather have a consistent effect across environments. For that purpose, the parental QTL effects can be decomposed into a main effect component ($\alpha_p$) and a QEI component ($\beta_{pj}$) that are estimated simultaneously, which gives the following multi-QTL model:

$$\underline{y}_{icj} = E_{j} + C_{cj} + \sum_{q=1}^{n_{QTL}} x_{i_{q}p} * (\alpha_p + \beta_{pj}) + \underline{GE}_{icj} + \underline{e}_{icj} \quad [4]$$

We can test for the significance of the $\alpha_p$ and $\beta_{pj}$ terms using the Wald test. Those tests allow the determination of the specific parental effect significance ($\alpha_p$ or $\beta_{pj}$ significant), and the determination of the specific parental allele interaction with the environment ($\beta_{pj}$ significant).

## QTL by environmental covariate (EC) effect estimation

::: {style="text-align: justify"}

For the parental allelic effects showing a significant interaction with the environment in model 4, it is possible to extend the model to test the sensitivity of the QTL allele to a specific environmental covariate ($EC_j$, e.g. temperature or humidity). For that purpose, we can rewrite the QTL effect term $\beta_{pj}$ of the parents with a significant environmental interaction (pxE). We can replace $\beta_{pj}$ with $EC_j*S_p+l_{p\epsilon}$. $EC_j$ represents the EC value in environment j associated with the sensitivity term $S_p$. The $S_{p}$ determines the rate of change of the parental QTL allelic additive effect given an extra unit of EC. Finally, $l_{p\epsilon}$ is a residual effect. The fitted model becomes:

$$\underline{y}_{icj} = E_{j} + C_{cj} + \sum_{q=1}^{n_{QTL}} x_{i_{q}p} * (\alpha_p + \beta_{pj}) + x_{i_{q}pxE} * (\alpha_p + EC_j*S_p+l_{p\epsilon}) + \underline{GE}_{icj} + \underline{e}_{icj} \quad [5]$$
The significance of the sensitivity term $S_p$ can be evaluated with the Wald test. Contrary to the model fitted for the QTL detection scan, model 1 for QTL effect estimation, models 4 and 5 are fitted using an 'exact' REML solution using the R pakage `nlme`.

:::

## QTL analysis example

### Data

::: {style="text-align: justify"}

The format of the data is the same as the default `mppData` objects format used in `mppR`. The traits measured in the different environments are simply added as separate columns of the `pheno` argument when you create the `mppData` object with `create.mppData()`.

The data used in this vignette (`mppData_GE`) come from the EU-NAM Flint population [@bauer_2013]. The genotype data come from five crosses between the donor parents: D152, F03802, F2, F283, DK105 with the recurrent parent UH007. We selected a subset of 100 markers spread over chromosomes five and six. The genetic map was calculated by @giraud_2014. The phenotypic data represent the within environment adjusted means for dry matter yield (DMY) calculated at La Coruna (CIAM), Roggenstein (TUM), Einbeck (KWS), and Ploudaniel (INRA_P) @lehermeier_2014.

:::

```{r setup, fig.height = 4, fig.width = 5}
library(mppR)
data(mppData_GE)
design_connectivity(par_per_cross = mppData_GE$par.per.cross)
```

### Simple interval mapping (SIM)

::: {style="text-align: justify"}

To perform the SIM scan, you simply need to pass the `mppData` object to the function and specify the environments you want to use in the `trait` argument. If needed, a reference parent can be specified using the `ref_par` argument. For example, here we analyse DMY characterized in the CIAM and TUM environments. After calculation, the SIM profile can be ploted with `plot()`

:::

```{r SIM, fig.height = 5, fig.width = 7}
SIM <- mppGE_SIM(mppData = mppData_GE, trait = c('DMY_CIAM', 'DMY_TUM'), ref_par = 'UH007')
plot(x = SIM)
```

### Cofactors selection

::: {style="text-align: justify"}

The cofactors as well as the QTLs are selected using the same function (`QTL_select()`). It performs an iterative search per chromosome starting from the most significant position above the `threshold` value. Then, marker positions falling on the left and right of the selected position by a distance specified in `window` are excluded. The search continues with the remaining positions by repeating the selection and exclusion steps. The search stops when no position remains above the `threshold`.

The default value of `window` (50) is deliberately large to limit the number of included cofactors and not overfit the model. In the `mppGE_proc()` function, the cofactor threshold and window parameters can be modified through the `thre.cof` and `win.cof` arguments.

:::

```{r cofactors}
cofactors <- QTL_select(Qprof = SIM, threshold = 4, window = 50)
```

### Composite interval mapping (CIM)

To perform the CIM scan, you simply need to pass the selected cofators in the `mppGE_CIM()` function. The `window` parameter specifies the distance on the left and right where cofactors are excluded in the neighborhood of a tested position. The `VCOV_data` argument allow to specify if the user want to estimate a unique general VCOV with all cofactors included (`"unique"`) or several VCOV removing cofactor in the neighbouring of a QTL position (`"minus_cof"`). The unique option is faster.

```{r CIM}
CIM <- mppGE_CIM(mppData = mppData_GE, trait = c('DMY_CIAM', 'DMY_TUM'),
                 cofactors = cofactors, window = 20, VCOV_data = "unique")
```

### QTLs selection

The selection of QTLs is done using the same function as the one used for cofactors. For the selection of QTLs it is possible to restrict the size of the exclusion `window` around the selected positions. In the `mppGE_proc()` function, the QTL threshold and window parameters can be modified through the `thre.QTL` and `win.QTL` arguments.

```{r QTLs}
QTL <- QTL_select(Qprof = CIM, threshold = 4, window = 20)
```

### QTLs effect and significance estimations

The function `QTL_effect_GE()` allows the estimation of the QTL allele effects and their significances. It calculates an exact version of mixed model 1 with single or multiple QTLs. The QTL allele effects are estimated using [3] and their significance with the Wald test [2].

The results of the QTL allelic effect estimation are returned in a list where each component represent the effects of one QTL. The individual within environment QTL effects are represented in row while the effects ($\hat{\beta}$), their standard error, as well as their significance are represented in columns. For example, looking at the first QTL, we can see that in the first environment the allele of parent DK105 decreases the DMY by -9.861 deciton/ha compared to the central parent UH007. In the second environment, the effect of DK105 is only -1.559. The effect is highly significant in the first environment but not in the second. 

```{r QTL_effects}
Qeff <- QTL_effect_GE(mppData = mppData_GE, trait = c('DMY_CIAM', 'DMY_TUM'),
                       QTL = QTL)
Qeff$QTL_1
```

A specific parent can be selected as reference using the `ref_par` argument. For example we can set as reference the parent 'F2' instead of the central parent (UH007).

```{r QTL_effects_2}
Qeff <- QTL_effect_GE(mppData = mppData_GE, trait = c('DMY_CIAM', 'DMY_TUM'),
                       QTL = QTL, ref_par = 'F2')
Qeff$QTL_1
```



### QTLs R2 calculation

The function `QTL_R2_GE()` allows the estimation of an $R^{2}$ contribution of all the QTLs (global) and of each QTL positions (partial). For simplicity, the $R^{2}$ is estimated using a linear model version of [1] and not a mixed model, which means that the $GE_{icj}$ term is absent from the model and that only a unique variance error term $\sigma_{e}^{2}$ is estimated. Therefore, the $R^{2}$ values represent general tendencies and should be taken with caution. The global adjusted $R^{2}$ is defined as

$$R^{2} = 100*(1-(\frac{RSS_{full}/d_{full}}{RSS_{red}/d_{red}}))$$

where $RSS_{full}$ and $RSS_{red}$ are the residual sum of squares of the model with and without the QTL positions. $d_{full}$ and $d_{red}$ represent the degrees of freedom of the corresponding models. The partial (adjusted) $R^{2}$ of QTL $i$ is the difference between the global $R^{2}$ obtained with all QTLs and the $R^{2}$ obtained with a model minus QTL $i$.

```{r QTL_R2}
QR2 <- QTL_R2_GE(mppData = mppData_GE, trait = c('DMY_CIAM', 'DMY_TUM'), QTL = QTL)

QR2$glb.adj.R2
QR2$part.adj.R2.diff

```

### QTL profile plot

The profile plot of the QTL significance can be obtained using the `plot.QTLprof()` function that plots the $-log_{10}(p-val)$ of the position along the genome.

```{r Q_prof, fig.height = 5, fig.width = 7}
plot(x = CIM)
```

### Whole-genome genetic effect significance plot

It is also possible to visualize the significance of the QTL parental allele along the genome by passing the QTL profile information (`CIM`) to the `plot_Qeff_prof()` function. The `QTL` argument can be used to specify potential QTL positions.

The color intensity $z = -log10(p-val)$ is proportional to the statistical significance of the parental allelic effects obtained from the Wald test [2]. $z$ has an upper limit of six to not let extreme signficant value influence too much the color scale. Compared to the reference parent (top of the graph) the red (blue) colour represents a negative (positive) effect. The different panels from the top to the bottom represent the different environments.

```{r Q_eff_plot, fig.height = 5, fig.width = 7}
plot_allele_eff_GE(mppData = mppData_GE, nEnv = 2,
                   EnvNames = c('CIAM', 'TUM'), Qprof = CIM,
                   QTL = QTL, text.size = 14)
```

### mppGE_proc: wrapper function

It is possible to calculate the whole procedure described using the `mppGE_proc()` function. This function uses the same arguments as the one defined in the sub-functions (e.g. `mppData`, `trait`, `thre.cof`, `win.cof`, `window`, `ref_par` etc.). In this function, it is possible to specify a working directory in `output.loc`. A folder with the `pop.name` and `trait.name` will be created to store intermediate data output like the SIM and CIM profiles, some results (list of QTLs, plots), as well as a summary of the results (QTL_REPORT.txt). Here we can still introduce the argument `n.cores` which allows to run the function in parallel.

```{r mppGE_proc}
MPP_GE_QTL <- mppGE_proc(pop.name = 'EUNAM', trait.name = 'DMY',
                         mppData = mppData_GE, trait = c('DMY_CIAM', 'DMY_TUM'),
                         n.cores = 1, verbose = FALSE, output.loc = tempdir())
```

### QTL by environment effect determination

Once a list of QTL has been determined using the genome scan functions `mppGE_SIM()`, `mppGE_CIM()` or `mppGE_proc()`, it is possible to refine our understanding of the QTL parental allelic effects by determining which of those effects have a significant interaction with the environment. To do that, it is possible to use the function `QTL_effect_main_QEI()`, which calculates model 4. For the illustration, we extended the number of environments by adding the INRA and KWS locations.

```{r QTL_effect_main_QEI}

Qeff <- QTL_effect_main_QEI(mppData = mppData_GE,
                            trait = c('DMY_CIAM', 'DMY_TUM', 'DMY_INRA_P', 'DMY_KWS'),
                            env_id = c('CIAM', 'TUM', 'INRA', 'KWS'),
                            QTL = QTL)
```

The function return two lists of $N_{QTL}$ length. The first list (`Q_sign`) describes the significance of the main ($\alpha_p$) and QTLxE ($\beta_{pj}$) term per parent for each QTL. For example, at QTL 2, we can notice that the 'F2', 'F283' and the 'F03802' parents have a significant interaction with the environment because the $-log10(p-val)$ of the $\beta_{pj}$ is larger than 1.301, which correspond to p-value of 0.05. 

```{r QTL_effect_main_QEI Q_sign}
Qeff$Q_sign$QTL2
```

The main and the QTLxE effect estimates are stored in the `Q_eff` list. For example for QTL 2, we can notice that the last environment 'KWS' was automatically set as the reference.

```{r QTL_effect_main_QEI Q_eff}
Qeff$Q_eff$QTL2
```


### QTLxEC effect estimation

Once the QTL alleles with a significant interaction with the environment have been determined, it is possible to investigate if those alleles are sensitive to specific environmental covariates using the function `QTL_effect_main_QxEC()`. This function estimates model 5. For that purpose, you can pass the results obtained with `QTL_effect_main_QEI()` to the `Qmain_QxE` argument from `QTL_effect_main_QxEC()`. You also need to provide the environmental covariate (EC) information in the format of a numeric matrix with environment in row and EC in column

```{r QTL_effect_main_QxEC}
# provide the environmental covariate information as a matrix
EC <- matrix(c(180, 310, 240, 280), 4, 1)
rownames(EC) <- c('CIAM', 'TUM', 'INRA', 'KWS')
colnames(EC) <- 'cum_rain'

Qeff <- QTL_effect_main_QxEC(mppData = mppData_GE,
                        trait = c('DMY_CIAM', 'DMY_TUM', 'DMY_INRA_P', 'DMY_KWS'),
                        env_id = c('CIAM', 'TUM', 'INRA', 'KWS'),
                        QTL = QTL, EC = EC, Qmain_QEI = Qeff, thre_QTL = 1.301)
```


The function extends the QTLxE term for the parental allelic effects with a $-log10(p-value)$ superior to the `thre_QTL` argument. It returns a list with the second element 'Qeff_EC' being a list with the $\alpha_p$ (all parental alleles) and $S_p$ (only parental allele with significant QTLxE) estimates. For example, with a $-log10(p-value)$ for the $S_p$ term equal to 2.26 and 2.08, the 'F03802' and the 'F283' parental allele interact significantly with the cumulated rain.

```{r QTL_effect_main_QxEC Qeff_EC}
Qeff$Qeff_EC$QTL2
```


It is possible to estimate the effect of several ECs but user should be careful to have enough degrees of freedom (df) to estimate those sensitivity curves. For example, with four environments, you should only estimate the effect of one EC at a time because you only have two remaining degrees of freedom (4 env - 1 df main effect - 1 df sensitivity slope).

### Plot QTL x EC sensitivity slopes

After calculation, it is possible to plot the sensitivity slopes estimated with the function `QTL_effect_main_QxEC()`. The slope represent the rate of change in the parental allelic effect given change in EC with respect to the reference parent.

```{r plot QTL x EC, fig.height = 5, fig.width = 5}
plot_QxEC(Qeff, EC = EC, env_id = c('CIAM', 'TUM', 'INRA', 'KWS'), 
          QTL = 2, EC_id = 'cum rain', trait_id = 'DMY')
```


### Computation time

::: {style="text-align: justify"}

We tested the proposed procedure on several sorghum BCNAM populations as well as maize NAM population and breeding MPPs. The table below show the computation time required for different configurations. Computations were realized on an AMD Ryzen 7-cores 5800 U processor with 16 GB RAM.

```{r comp_res_table, echo = FALSE}
library(knitr)
tab <- data.frame(Population = c('BCNAM Grinkan', 'BCNAM Kenin-Keni', 'BCNAM Lata' ,'EUNAM Dent', 'EUNAM Flint', 'Breeding pop1', 'Breeding pop2'),
                  Ngeno = c(1598, 575, 896, 841, 811, 2071, 820),
                  Nmarker = c(51545, 51545, 51545, 18621, 5949, 1812, 1760),
                  Nenv = c(4, 4, 3, 4, 6, 3, 5),
                  Ncore = c(4, 4, 4, 1, 1, 1, 1),
                  `SIM(m)` = c(20, 1.5, 3, 18, 15, 5, 9),
                  `CIM(h)` = c(11, 0.17, 0.33, 9.5, 16, 1.3, 10.2),
                  `QTL_effect(m)` = c(15, 1.5, 2, 19, 150, 9, 33),
                  `Total(h)` = c(11.6, 0.25, 0.4, 10.2, 19, 1.5, 10.8)
                  )
kable(tab, caption = 'Computation time examples',
      col.names = c('Populations', 'Ngeno', 'Nmarker', 'Nenv', 'Ncore', 'SIM [m]', 'CIM [h]', 'QTL_effects [m]', 'Total [h]'))
```


From a general point of view, even though we tried to reduce as much as possible the computation time, it can still take several hours to perform a complete analysis. The computation time depends principally on the population size (number of genotypes), the number of environments, as well as the number of markers. The use of multiple cores (`n.cores` argument) is a first possibility to reduce the computational time.

The computation of the CIM part including cofactors is the most demanding. The whole procedure time can be largely reduced if the user only perform a SIM (`SIM_only = TRUE` in `mppGE_proc()`). Generally, the large effect QTLs are the same or fall in similar region in the SIM and CIM analysis. The number of cofactor position selected will also considerably extend the computational time. For that reason we advise to restrict their number by selecting maximum one cofactor per chrosome.

Ultimately, even if the computation time can be long we should always put that in balance with the time required to develop the population, phenotype it and get the genotypic data.

:::

## References


