Closed gaynorr closed 1 year ago
@gaynorr what about not throwing an error, but giving a warning that we only got x sites and still returning an object?
@gaynorr I tested two versions of AlphaSimR.
My R session is not crashing in this test, and I am already receiving an error message. Thus, I assumed the issue started in the last version, 1.3.1.
Code:
founderPop = runMacs(nInd=100, nChr=1, segSites=30000)
Output:
Error in MaCS(command, segSites, inbred, ploidy, nThreads, seed) : Not enough segregating sites generated
In this test, my R session crashed (RStudio or via Terminal)!
The error starts in line 227 of founderPop.R
, and it is probably related to C++ code:
macsOut = MaCS(command, segSites, inbred, ploidy, nThreads, seed)
I will investigate the reason behind it and get back to you.
This should be resolved now. I was using Rcpp::stop
when the number of sites was below the requested number. This was occurring within an OpenMP loop, so it caused a CTD when triggered.
I've changed it so that C++ function instead returns all the sites that are generated. The R function then checks if the returned number of sites matches the requested number. If it doesn't, the function returns an error with the following message, "MaCS did not return enough segSites, use segSites=NULL to return all sites generated by MaCS". I decided to do an error instead of warning, because I suspect that most scripts are likely to be broken by not returning enough segSites.
Describe the bug The
runMacs
andrunMacs2
functions can crash an R session when the user requests a value of segSites that is larger than the number simulated.Steps To Reproduce
Expected behavior The functions should return an error indicating not enough segregating sites were simulated.