knitr::opts_chunk$set(fig.dpi=96)
BreedingSchemeLanguage is a package that simulates plant breeding using phenotypic or genomic selection. All package functions simulate recognizable breeding tasks that can be assembled into breeding schemes. For example, users can simulate phenotyping in multiple (possibly correlated) locations over years, calculate the cost of the simulated breeding scheme, and compare multiple breeding strategies. Reasonable defaults are given for each function, but many aspects are customizable. Functions are context dependent, e.g, by default, the phenotype()
function will generate phenotypes for the last population created.
Load the BreedingSchemeLanguage. Find a temporary directory to work with for this vignette.
library(BreedingSchemeLanguage) simTempDir <- tempdir()
Define the genetic architecture of the plant species and other whole simulation settings. Because generating historical haplotypes is rather slow, save them so they can be reused.
simEnv <- defineSpecies(nSim=3, saveDataFileName=paste(simTempDir, "simSpecies", sep="/"))
Here, we plan to conduct three simulations using default settings (i.e., genome with seven chromosomes of 150 cM length, historical effective population size of 100, trait controlled by additive QTLs, etc.).
The BSL keeps simulation objects in an R environment. If users specify the default simEnv
the environment object does not need to be passed to the functions.
Specify environmental variances and breeding costs
locCor <- matrix(c(1, 0.6, 0.3, 0.6, 1, 0.8, 0.3, 0.8, 1) , 3) errVars <- c(Preliminary=4, Advanced=1) defineVariances(locCorrelations=locCor, plotTypeErrVars=errVars) plotCosts <- c(Preliminary=2, Advanced=5) defineCosts(phenoCost=plotCosts)
Initialize the breeding population from historical haplotypes.
initializePopulation()
Estimate the per se or own performance of individuals in the initial breeding population and select based on these values.
phenotype(locations=1:3, years=1:2, plotType="Preliminary") predictValue() select()
select()
so the default of using the values just estimated (in the predictValue()
function) and selecting 40 individuals applies. The function cross()
creates the next generation of 100 individuals (also by default).Cross to create progeny, phenotype them then select using pedigree information
cross() phenotype(plotType="Advanced", locations=3, years=3) predictValue(sharingInfo="pedigree") select()
Genomic selection among progeny produced by selfing
selfFertilize(nProgeny=120) genotype() predictValue(sharingInfo="markers", locations=3) select() cross()
genotype()
causes marker data to be available for all individuals of the breeding scheme.predictValue()
function uses GBLUP when "markers" is given as the sharingInfo parameter.cycleMeans <- plotData(addDataFileName=paste(simTempDir, "simPlot", sep="/"))
First, it is best to delete the previous simulation environment, then load the data using the name given at the beginning of the vignette. Simple simulation using defaults.
if (exists("simEnv")){ rm(list=names(simEnv), envir=simEnv) rm(simEnv) } simEnv <- defineSpecies(loadData=paste(simTempDir, "simSpecies", sep="/")) initializePopulation() phenotype() select() cross() phenotype() select() cross() phenotype() select() cross() cycleMeans <- plotData(add=TRUE, addDataFileName=paste(simTempDir, "simPlot", sep="/"))
fr <- file.remove(paste(simTempDir, "simSpecies.RData", sep="/")) fr <- file.remove(paste(simTempDir, "simPlot.rds", sep="/"))
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.