Last updated: 2021-08-27
Checks: 7 0
Knit directory: BreedingSchemeOpt/
This reproducible R Markdown analysis was created with workflowr (version 1.6.2). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.
Great! Since the R Markdown file has been committed to the Git repository, you know the exact version of the code that produced these results.
Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.
The command set.seed(20210422)
was run prior to running the code in the R Markdown file. Setting a seed ensures that any results that rely on randomness, e.g. subsampling or permutations, are reproducible.
Great job! Recording the operating system, R version, and package versions is critical for reproducibility.
Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.
Great job! Using relative paths to the files within your workflowr project makes it easier to run your code on other machines.
Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility.
The results in this page were generated with repository version 9d369ee. See the Past versions tab to see a history of the changes made to the R Markdown and HTML files.
Note that you need to be careful to ensure that all relevant files for the analysis have been committed to Git prior to generating the results (you can use wflow_publish
or wflow_git_commit
). workflowr only checks the R Markdown file, but you know if there are other scripts or data files that it depends on. Below is the status of the Git repository when the results were generated:
Ignored files:
Ignored: .DS_Store
Ignored: .Rhistory
Ignored: .Rproj.user/
Ignored: analysis/.DS_Store
Ignored: analysis/images/.DS_Store
Ignored: data/.DS_Store
Untracked files:
Untracked: data/baselineScheme.gsheet
Untracked: data/siErrorVarEst_byTrialType_directApproach_2021Aug25.rds
Untracked: output/benchmark_sim.rds
Untracked: output/benchmark_sims5.rds
Untracked: output/burnIn_test.rds
Untracked: output/postBurnIn_test.rds
Untracked: output/test_burnIn_sim.rds
Unstaged changes:
Modified: data/README.md
Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.
These are the previous versions of the repository in which changes were made to the R Markdown (analysis/example-simulation-reducing-error-with-new-tools.Rmd
) and HTML (docs/example-simulation-reducing-error-with-new-tools.html
) files. If you’ve configured a remote Git repository (see ?wflow_git_remote
), click on the hyperlinks in the table below to view the files as they were in that past version.
File | Version | Author | Date | Message |
---|---|---|---|---|
html | 92bd15b | wolfemd | 2021-04-22 | Build site. |
html | 1d503b6 | wolfemd | 2021-04-22 | Build site. |
html | fe3048a | wolfemd | 2021-04-22 | Build site. |
Rmd | 9df9d9b | wolfemd | 2021-04-22 | Publish the initial files for the Breeding Scheme Optimization Group project |
AlphaSimHlpR first steps: Installation and quickly running the AlphaSimHlpR
tutorial example.
Generate a baseline population. As this is an example, I won’t use empirical inputs. Ignore costs for now.
BaselineControlFile.txt
and BaselinePopulationFile.txt
in this repository.I want to set-up “burn-in” generations of phenotypic selection. See if I can work that in AlphaSimHlpR
.
SPOILER ALERT: Not quite working yet. More work needed.
The first step is to read in the control files defining the baseline breeding program and other breeding scheme parameters in a list bsp
.
The tutorial example repeatedly runs the runBreedingScheme()
function, which in turn depends on specified functions: initializeFunc=initFuncADChk, productPipeline=prodPipeFncChk, populationImprovement=popImprov1Cyc
.
selCritPipeAdv
and selCritPopImprov
are set to selCritIID.
Now, to continue, we can’t use the runBreedingScheme()
function because it will re-run the initializeFunc()
and subsequently runMacs2()
, which overwrites our founder haplotypes.
Make my own function: runBreedingScheme_wBurnIn()
.
Specify number of burn-in and post-burn in cycles.
Also let’s uses two separate bsp
objects, one for before, another for after. Use with caution.
rm(list=ls()); gc()
used (Mb) gc trigger (Mb) limit (Mb) max used (Mb)
Ncells 720741 38.5 1347232 72 NA 1347232 72.0
Vcells 1339776 10.3 8388608 64 65536 1971303 15.1
library(tidyverse); library(magrittr);
── Attaching packages ─────────────────────────────────────── tidyverse 1.3.1 ──
✓ ggplot2 3.3.5 ✓ purrr 0.3.4
✓ tibble 3.1.3 ✓ dplyr 1.0.7
✓ tidyr 1.1.3 ✓ stringr 1.4.0
✓ readr 2.0.1 ✓ forcats 0.5.1
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
x dplyr::filter() masks stats::filter()
x dplyr::lag() masks stats::lag()
Attaching package: 'magrittr'
The following object is masked from 'package:purrr':
set_names
The following object is masked from 'package:tidyr':
extract
suppressMessages(library(AlphaSimHlpR))
<- specifyPopulation(ctrlFileName="data/BaselinePopulationFile.txt")
bsp <- specifyPipeline(bsp, ctrlFileName="data/BaselineControlFile.txt") bsp
<- function(replication=NULL,
runBreedingScheme_wBurnIn nBurnInCycles=10,nPostBurnInCycles=10,
bspBurnIn,bspPostBurnIn,
initializeFunc,
productPipeline,
populationImprovement){
cat("******", replication, "\n")
# This initiates the founding population
<- initializeFunc(bspBurnIn)
initList <- initList$SP
SP <- initList$bsp
bspBurnIn <- initList$records
records
# Burn-in cycles
for (cycle in 1:nBurnInCycles){
cat(cycle, " ")
<- productPipeline(records, bspBurnIn, SP)
records <- populationImprovement(records, bspBurnIn, SP)
records
}# records <- AlphaSimHlpR:::lastCycStgOut(records, bspPostBurnIn, SP)
cat("\n")
cat("Burn-in Cycles")
cat("\n")
# Post burn-in cycles
for (cycle in (nBurnInCycles+1):(nBurnInCycles+nPostBurnInCycles)){
cat(cycle, " ")
<- productPipeline(records, bspPostBurnIn, SP)
records <- populationImprovement(records, bspPostBurnIn, SP)
records
}cat("\n")
# Finalize the stageOutputs
<- AlphaSimHlpR:::lastCycStgOut(records, bspPostBurnIn, SP)
records
return(list(records=records,
bspBurnIn=bspBurnIn,
bspPostBurnIn=bspPostBurnIn,
SP=SP))
}
For burn-in, using phenotypic selection, so the bsp
already created.
For post burn-in, change selCritPopImprov
to selCritGRM
, but ignore selCritPipeAdv
for now.
<-bsp
bspBurnIn<-bspBurnIn
bspPostBurnIn"selCritPopImprov"]] <- selCritGRM
bspPostBurnIn[[
<-runBreedingScheme_wBurnIn(replication = 1,
test_simnBurnInCycles=2,nPostBurnInCycles=2,
bspBurnIn=bspBurnIn,
bspPostBurnIn=bspPostBurnIn,
initializeFunc=initializeScheme,
productPipeline=productPipeline,
populationImprovement=popImprov1Cyc)
Unfortunately, haven’t gotten this to work yet. It seems likely more tweaking to the package is necessary.
I traced the problem at least as far as the populationImprovement()
function in the post-burn-in phase and the makeGRM()
.
Set-up an experiment. No burn-in simulations.
# rm(list=ls()); gc()
# library(tidyverse); library(magrittr);
# suppressMessages(library(AlphaSimHlpR))
# bsp <- specifyPopulation(ctrlFileName="BaselinePopulationFile.txt")
# bsp <- specifyPipeline(bsp, ctrlFileName="BaselineControlFile.txt")
# test<-runBreedingScheme(replication = 1, nCycles = 5, # just 5 for now
# initializeFunc=initializeScheme,
# productPipeline=prodPipeFncChk,
# populationImprovement=popImprov1Cyc, bsp)
#
# test_burnin$records$stageOutputs %>% ggplot(.,aes(x=year,y=genValMean, color=stage)) + geom_line()
# test_burnin$records
sessionInfo()
R version 4.1.0 (2021-05-18)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Big Sur 10.16
Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/4.1/Resources/lib/libRblas.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.1/Resources/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] AlphaSimHlpR_0.2.1 AlphaSimR_1.0.3 R6_2.5.0 magrittr_2.0.1
[5] forcats_0.5.1 stringr_1.4.0 dplyr_1.0.7 purrr_0.3.4
[9] readr_2.0.1 tidyr_1.1.3 tibble_3.1.3 ggplot2_3.3.5
[13] tidyverse_1.3.1 workflowr_1.6.2
loaded via a namespace (and not attached):
[1] Rcpp_1.0.7 lubridate_1.7.10 assertthat_0.2.1 rprojroot_2.0.2
[5] digest_0.6.27 utf8_1.2.2 cellranger_1.1.0 backports_1.2.1
[9] reprex_2.0.1 evaluate_0.14 httr_1.4.2 pillar_1.6.2
[13] rlang_0.4.11 readxl_1.3.1 rstudioapi_0.13 whisker_0.4
[17] jquerylib_0.1.4 rmarkdown_2.10 munsell_0.5.0 broom_0.7.9
[21] compiler_4.1.0 httpuv_1.6.1 modelr_0.1.8 xfun_0.25
[25] pkgconfig_2.0.3 htmltools_0.5.1.1 tidyselect_1.1.1 fansi_0.5.0
[29] crayon_1.4.1 tzdb_0.1.2 dbplyr_2.1.1 withr_2.4.2
[33] later_1.2.0 grid_4.1.0 jsonlite_1.7.2 gtable_0.3.0
[37] lifecycle_1.0.0 DBI_1.1.1 git2r_0.28.0 scales_1.1.1
[41] cli_3.0.1 stringi_1.7.3 fs_1.5.0 promises_1.2.0.1
[45] xml2_1.3.2 bslib_0.2.5.1 ellipsis_0.3.2 generics_0.1.0
[49] vctrs_0.3.8 tools_4.1.0 glue_1.4.2 hms_1.1.0
[53] yaml_2.2.1 colorspace_2.0-2 rvest_1.0.1 knitr_1.33
[57] haven_2.4.3 sass_0.4.0