Hi Terry. Recipe 16.12, which I pointed you
to before, is a nonWF model and does not use a mateChoice() callback;
in fact, mateChoice() callbacks can only be used in WF models. In nonWF
models, reproduction is instead handled by reproduction() callbacks.
You might want to have another read through recipe 16.12 to understand
all of this better; but here is an example model that arranges matings
as you described:
initialize() {
initializeSLiMModelType("nonWF");
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);
}
function (void)mateTaggedIndividuals(i$ parent1Tag, i$ parent2Tag, i$
childTag) {
parent1 = p1.subsetIndividuals(tag=parent1Tag);
parent2 = p1.subsetIndividuals(tag=parent2Tag);
child = p1.addCrossed(parent1, parent2);
child.tag = childTag;
}
2 reproduction() {
// generation1: s0.1+s0.2,s0.1+s0.3,s0.1+s0.4,s0.2+s0.5,s0.3+s0.5
mateTaggedIndividuals(1, 2, childTag=1);
mateTaggedIndividuals(1, 3, childTag=2);
mateTaggedIndividuals(1, 4, childTag=3);
mateTaggedIndividuals(2, 5, childTag=4);
mateTaggedIndividuals(3, 5, childTag=5);
self.active = 0;
}
3 reproduction() {
// generation2: s1.1+s1.2,s1.1+s1.3,s1.1+s1.4,s1.2+s1.5,s1.4+s1.5
mateTaggedIndividuals(1, 2, childTag=1);
mateTaggedIndividuals(1, 3, childTag=2);
mateTaggedIndividuals(1, 4, childTag=3);
mateTaggedIndividuals(2, 5, childTag=4);
mateTaggedIndividuals(4, 5, childTag=5);
self.active = 0;
}
4 reproduction() {
// generation3: s2.1+s2.2,s2.1+s2.3,s2.1+s2.4,s2.2+s2.5,s2.4+s2.5
mateTaggedIndividuals(1, 2, childTag=1);
mateTaggedIndividuals(1, 3, childTag=2);
mateTaggedIndividuals(1, 4, childTag=3);
mateTaggedIndividuals(2, 5, childTag=4);
mateTaggedIndividuals(4, 5, childTag=5);
self.active = 0;
}
1 early() {
sim.addSubpop("p1", 5);
p1.individuals.tag = 1:5;
}
survival() {
// kill the parental generation
if (individual.age > 0)
return F;
return NULL;
}
4 late() { }
Of course this could be modified so that the mating pattern is driven by
tables instead of being hard-coded in the script itself; that is
essentially what recipe 16.12 demonstrates. But I've made the mating
code explicit above to make it more clear what is going on. Also, this
code uses tag values, but one could design the code to use pedigree IDs
instead, which might be particularly convenient if one were using
tree-sequence recording. I used a user-defined function to do the tag
lookups and such, but there's no particular need for that, and it's a
bit inefficient; with a table-driven design you probably wouldn't do
that any more. As usual with scriptability, there are many ways to
achieve the same goal, but I hope this points you in the right
direction.
Cheers,
-B.
Benjamin C. Haller
Messer Lab
Cornell University
Zuxi Cui wrote on 7/6/22 10:41 AM: