{width=10%} AlphaSimR: Practical implementation of genomic selection in AlphaSimR

```{=html}```
## Practical implementation of a breeding program with genomic selection In this part of the vignette, we will implement the genomic selection in a Maize pipeline. Two scenarios will be implemented after a fifteen-year Burn-In period. The first scenario will account only for truncated phenotypic selection. In the second scenario, we will implement genomic selection in the pipeline. So, in year 4, the individuals will be selected based on the estimated breeding values that came from a genomic model (ridge regression model). In addition, the parents will be selected based on 'ebv'. ## Package and files for recording the outputs ```{r, eval=FALSE} rm(list=ls()) # Packages require(AlphaSimR) # Creating the files to record the results MeanG_pop = matrix(NA, 35) MeanA_pop = matrix(NA, 35) VarG_pop = matrix(NA, 35) ``` ## Create parents and fill the pipeline ```{r, eval=FALSE} # Parameters files source("aux_files/GlobalParameters.R") # Create the parents source("aux_files/Create_parents.R") # FillPipeline source("aux_files/FillPipeline.R") # Environmental covariate P = runif(burninYears+futureYears) ``` ## Burn-In period ```{r, eval=FALSE} for(year in 1:burninYears){ p = P[year] cat("Working on year:",year,"\n") source("aux_files/UpdateParents.R") # Pick new parents based on last year's data source("aux_files/UpdateTesters.R") # Pick new testers and hybrid parents source("aux_files/AdvanceYearPS.R") # Advances yield trials by a year source("aux_files/WriteRecordsGS.R") # Write records for GS predictions source("aux_files/UpdateResults.R") # Track summary data } # Saving the info save.image("results/BURNIN.RData") ``` ## Phenotypic selection program ```{r, eval=FALSE} # 3.0 Loading the scenarios load("results/BURNIN.RData") for(year in (burninYears+1):(burninYears+futureYears)){ p = P[year] # 3.1 Loop cat("Working on year:",year,"\n") source("aux_files/UpdateParents.R") # Pick new parents based on last year's data source("aux_files/UpdateTesters.R") # Pick new testers and hybrid parents source("aux_files/AdvanceYearPS.R") # Advances yield trials by a year source("aux_files/UpdateResults.R") # Track summary data } # 3.2 Recording results output1 = data.frame(scenario=rep("PS", 35), # Scenario name MeanG_pop, MeanA_pop, VarG_pop, stringsAsFactors=FALSE) # 3.3 Saving the results as RDS saveRDS(output1,"results/Results_PS.rds") ``` ## Genomic selection program ```{r, eval=FALSE} # 3.0 Loading the scenarios load("results/BURNIN.RData") for(year in (burninYears+1):(burninYears+futureYears)){ p = P[year] cat("Working on year:",year,"\n") if(year == (burninYears+1)){ source('aux_files/fillGS.R') } source("aux_files/UpdateParents_GS.R") # Pick new parents based on last year's data source("aux_files/UpdateTesters.R") # Pick new testers and hybrid parents source("aux_files/AdvanceYearGS.R") # advance the populations source("aux_files/WriteRecordsGS.R") # Track records for GS source("aux_files/UpdateResults.R") # Track summary data } # 3.2 Recording results output1 = data.frame(scenario=rep("GS", 35), # Scenario name MeanG_pop, MeanA_pop, VarG_pop, stringsAsFactors=FALSE) # 3.3 Saving the results as RDS saveRDS(output1,"results/Results_GS.rds") ``` ## Plotting the results ```{r} # Loading the results Scenario1 = readRDS("results/Results_PS.rds") Scenario2 = readRDS("results/Results_GS.rds") # Plot hybrid mean of genetic values over time meanRanges = range(c(Scenario1$MeanG_pop[15:35], Scenario2$MeanG_pop[15:35])) plot(x = 15:35, y = Scenario1$MeanG_pop[15:35], type = "l", col = "black", lwd = 3, xlab = "Year", ylab = "Mean of genetic values", ylim = meanRanges) lines(x = 15:35, y = Scenario2$MeanG_pop[15:35], type = "l", col = "blue", lwd = 3) legend(x = "topleft", legend = c('Pheno', 'GS'), title = "Scenarios", lwd = 3, lty = c(1, 1), col = c("black", "blue"), bty = "n") ``` ## References ::: {#refs} :::