knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
AlphaSimR is a package with many useful functions to simulate plant and animal breeding schemes. But it is not very easy to implement. AlfSimHlpR defines functions that provide structure for a breeding scheme
# Make sure you have the right packages installed neededPackages <- c("AlphaSimR", "dplyr", "tidyr", "plotrix", "lme4", "sommer", "optiSel") for (p in neededPackages) if (!require(p, character.only=T)) install.packages(p) suppressMessages(library(AlphaSimHlpR))
Define the genetic architecture of the population and other breeding scheme parameters in a list bsp
.
bsp <- specifyPopulation(ctrlFileName="../inst/PopulationCtrlFile_Small.txt") bsp <- specifyPipeline(bsp, ctrlFileName="../inst/ControlFile_Small.txt") bsp <- specifyCosts(bsp, ctrlFileName="../inst/CostsCtrlFile_Small.txt") print(bsp) nReplications <- 3 bsp$nCyclesToRun <- 6
r bsp$nCyclesToRun
cyclesReplicate a very simple breeding program r nReplications
times.
replicRecords <- lapply(1:nReplications, runBreedingScheme, nCycles=bsp$nCyclesToRun, initializeFunc=initFuncADChk, productPipeline=prodPipeFncChk, populationImprovement=popImprov1Cyc, bsp)
And plot them out
plotData <- plotRecords(replicRecords) meanMeans <- tapply(plotData$genValMean, list(plotData$year, plotData$stage), mean) meanMeans <- meanMeans[,c("F1", bsp$stageNames)] stdErrMeans <- tapply(plotData$genValMean, list(plotData$year, plotData$stage), std.error) stdErrMeans <- stdErrMeans[,c("F1", bsp$stageNames)] print(meanMeans) print(stdErrMeans)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.