gaynorr / AlphaSimR

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

Write vignette on how to modify runMacs() and how to use other simulators for founders #165

Open gregorgorjanc opened 8 months ago

gregorgorjanc commented 8 months ago

Essentially turn this script into

https://github.com/gaynorr/AlphaSimR_Examples/blob/master/misc/ManualMaCS.R

https://github.com/gaynorr/AlphaSimR_Examples/blob/master/misc/msprime.R

and show how to bring in stdpopsim results and SlendR results too

gaynorr commented 8 months ago

The msprime example predates importHaplo, so it uses newMapPop with its list arguments. The importHaplo functions uses data.frames / matrices for arguments which are probably easier for most to grasp.

Here is an old example using importHaplo to read in down sampled data. Note that it shows the use of the optional raw format for haplotype data.

library(AlphaSimR)

# Create a large population
founderPop = quickHaplo(nInd=100, nChr=10, segSites=1e5)

# Extract the genetic map and select a subset of sites
genMap = getGenMap(founderPop)
take = sample(nrow(genMap), 10000)
take = sort(take) # Not required, but preserves chromosome order later
genMap = genMap[take,]

# Extract selected marker haplotypes
# Use "raw" format to reduce memory usage
haplo = pullMarkerHaplo(founderPop, genMap$id, asRaw=TRUE)

# Create a new founder population with reduced set of markers
newFounderPop = importHaplo(haplo, genMap)
gaynorr commented 8 months ago

Another example of importHaplo is here: https://github.com/gaynorr/AlphaSimR_Examples/blob/master/misc/ASR_ImportExternalData.R

gregorgorjanc commented 2 weeks ago

@hannesbecher can you help with this so we clearly document & demonstrate how to use MaCS (less relevant going forward) and msprime/stdpopsim (more relevant going forward) with AlphaSimR?