// Keywords: nonWF, non-Wright-Fisher
initialize() {
initializeSLiMModelType("nonWF");
initializeSLiMOptions(keepPedigrees=T);
initializeSex("A");
defineConstant("carryingCapacities", c(400,500,600,700, 800, 900, 1000, 1100, 1200, 130));
defineConstant("frage",2);
defineConstant("lrage",7);
defineConstant("P",20);
initializeMutationType("m1", 0.5, "f", 0.0);
m1.convertToSubstitution = T;
initializeGenomicElementType("g1", m1, 1.0);
initializeGenomicElement(g1, 0, 99999);
initializeMutationRate(1e-7);
initializeRecombinationRate(1e-8);
}
reproduction(NULL, "F"){
sp = sim.subpopulations;
partnertag = individual.getValue("partner");
mate=NULL;
males=sp.individuals[sp.individuals.sex == "M" & sp.individuals.age > 3];
//if the female is single, select a single male as partner
if (partnertag == 0) {
if (males.size() > 0){
mates=males[males.getValue("partner")==0];
if (mates.size() > 0){
mate=sample(mates, 1);
individual.setValue("partner", mate.tag);
mate.setValue("partner", individual.tag);
}
}
}
else{
//if the female allready has a partner, this partner is kept
mate = subpop.subsetIndividuals(tag=partnertag);
}
random_value = runif(1);
// determine nr of offspring
if (random_value < 0.31) {
litter_size = 1;
} else if (random_value < 0.80) { // 0.31 + 0.49 = 0.80
litter_size = 2;
} else if (random_value < 0.85) { // 0.80 + 0.05 = 0.85
litter_size = 3;
} else {
litter_size = 4;
}
if (!isNULL(mate)){
if (mate.size() != 0){
offspring=subpop.addCrossed(individual, mate, count=litter_size);
for(i in seqLen(offspring.size())){
offspring[i].tag = sim.tag;
sim.tag = sim.tag + 1;
}
offspring.setValue("partner", 0);
}
}
// Disable callback
self.active = 1;
}
1 early() {
sim.addSubpop("p1", P);
p1.individuals.age = rdunif(P, min=0, max=7);
p1.individuals.tag = 1:P;
sim.tag = P+1;
for (ind in p1.individuals){
ind.setValue("partner", 0);
}
}
early() {
// life table based individual mortality
inds = sim.subpopulations.individuals;
ages = inds.age;
inds01 = inds[ages == 0];
inds12 = inds[ages == 1];
inds23 = inds[ages == 2];
inds34 = inds[ages == 3];
inds4p = inds[ages >= 4 & ages < 25];
inds25 = inds[ages >= 25];
// Mortality based on age and sex
death01_m = (runif(inds01.size()) < 0.384) & (inds01.sex == "M");
death12_m = (runif(inds12.size()) < 0.08) & (inds12.sex == "M");
death23_m = (runif(inds23.size()) < 0.048) & (inds23.sex == "M");
death34_m = (runif(inds34.size()) < 0.029) & (inds34.sex == "M");
death4p_m = (runif(inds4p.size()) < 0.15) & (inds4p.sex == "M");
death01_f = (runif(inds01.size()) < 0.284) & (inds01.sex == "F");
death12_f = (runif(inds12.size()) < 0.089) & (inds12.sex == "F");
death23_f = (runif(inds23.size()) < 0.20) & (inds23.sex == "F");
death34_f = (runif(inds34.size()) < 0.112) & (inds34.sex == "F");
death4p_f = (runif(inds4p.size()) < 0.112) & (inds4p.sex == "F");
// Kill individuals
dead_inds = (c(inds01[death01_m], inds12[death12_m],
inds23[death23_m], inds34[death34_m], inds4p[death4p_m],
inds01[death01_f], inds12[death12_f],
inds23[death23_f], inds34[death34_f], inds4p[death4p_f],
inds25));
for (ind in dead_inds) {
partnertag = ind.getValue("partner");
//catn(ind.tag +"+"+partnertag);
mate = sim.subpopulations.subsetIndividuals(tag=partnertag);
mate.setValue("partner", 0);
}
//line5 = paste(community.tick, dead_inds);
//writeFile("dead.txt", line5, append=T);
sim.killIndividuals(dead_inds);
}
15 early() {
for (spop in 2:8)
{sim.addSubpop(spop,0);
}
}
16 early (){
subpops = sim.subpopulations;
catn(subpops);
for (i in 1:7) {
migrants = p1.sampleIndividuals(15);
subpops[i].takeMigrants(migrants);
}
}
17:100 early() {
//fitness Scaling
for (i in 0:(sim.subpopulations.size() - 1)) {
subpop = sim.subpopulations[i];
Ksub = carryingCapacities[i];
if(subpop.individuals.size() > 0){
subpop.fitnessScaling = Ksub / (subpop.individualCount);
}
}
//Set Rotational migration
sourcePop = sim.subpopulations[i];
destPop = sim.subpopulations[asInteger((i + 1) % sim.subpopulations.size())];
// Select all single men
migrants = sourcePop.individuals[(sourcePop.individuals.sex == "M") & (sourcePop.individuals.getValue("partner") == 0)];
if (migrants.size() > 0) {
destPop.takeMigrants(migrants);
}
}
death01_m = (runif(inds01.size()) < 0.384) & (inds01.sex == "M");
death01_f = (runif(inds01.size()) < 0.284) & (inds01.sex == "F");
I'd suggest:
death01 = (runif(inds01.size()) < ifelse(inds01.sex == "M", 0.384, 0.284));
--
SLiM forward genetic simulation: http://messerlab.org/slim/
---
You received this message because you are subscribed to the Google Groups "slim-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to slim-discuss...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/slim-discuss/ffc7b754-a7a1-412c-a090-595be4511d2fn%40googlegroups.com.