MatePopulations.par: Make a new generation out of 1 or more populations.

Usage Arguments Examples

View source: R/functions.R

Usage

1
MatePopulations.par(popList, nChildren = 100, cpc = 2, lambda = 2, mc.cores = 1)

Arguments

popList
nChildren
cpc
lambda
mc.cores

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function (popList, nChildren = 100, cpc = 2, lambda = 2, mc.cores = 1)
{
    individuals = sapply(popList, function(x) x@members)
    individuals = unlist(individuals)
    alleles = sapply(popList, function(x) x@alleles)
    alleles = unlist(alleles)
    alleles = unique(alleles)
    nCouples = round(nChildren/cpc)
    childrenPerCouple = rpois(nCouples, cpc)
    childrenPerCouple = childrenPerCouple[childrenPerCouple !=
        0]
    generateChildren = function(i) {
        parents = sample(individuals, 2)
        children = sapply(1:i, function(x) MateIndividuals(parent1 = parents[[1]],
            parent2 = parents[[2]], lambda = lambda))
        return(children)
    }
    childrenList = mclapply(childrenPerCouple, generateChildren,
        mc.cores = mc.cores)
    output = Population(members = unlist(childrenList), alleles = alleles)
    return(SelectIndividuals(output))
  }

alghul96/AdmSim documentation built on May 27, 2019, 3:29 p.m.