gaynorr / AlphaSimR

R package for breeding program simulations
https://gaynorr.github.io/AlphaSimR/
Other
43 stars 18 forks source link

genParam() fails when pop has just one individual #17

Closed gregorgorjanc closed 2 years ago

gregorgorjanc commented 3 years ago

genParam() fails when pop has just one individual

> founderPop = quickHaplo(nInd=10, nChr=1, segSites=10, inbred=TRUE)
> SP = SimParam$new(founderPop)
> SP$addTraitA(10)
> pop = newPop(founderPop, simParam=SP)
> genParam(pop[1])
Error in popVar(cbind(bv[, i], dd[, i]))[1, 2] : subscript out of bounds
gregorgorjanc commented 2 years ago

@gaynorr can you have a look at this pull request? It's kind of important for us downstream since there is just one queen per colony and we need this edge case to work. The fix I provided is in line what the rest of the function is doing in that edge case. The code breaks because of the assumed indexing, but underlying C++ code does not give you back a matrix, hence my by-pass-fix for that case.

gaynorr commented 2 years ago

I've merged the request into the devel branch and it will be included in the next release.