Sex-specific monogamy

16 views
Skip to first unread message

Viv

unread,
May 6, 2025, 5:51:03 PMMay 6
to slim-discuss
Hi Ben,

I have been trying to model monogamous mating on the X chromosome. As I am modelling separate sexes, the reproduction callback from recipe 15.3 is not appropriate as I need to sample males and females, as opposed to just two randomly chosen parents. I was wondering if you could advise on how to go about this? My main issue is that I cannot just loop through all males and all females as there is no guarantee that there are the same number of each (particularly when modelling uneven sex ratios). Below is the standard reproduction callback from recipe 15.3 that I have been working from. Many thanks!

Best,

Viv

reproduction() {
// randomize the order of p1.individuals
parents = sample(p1.individuals, p1.individualCount);

// draw monogamous pairs and generate litters
for (i in seq(0, p1.individualCount - 2, by=2))
{
parent1 = parents[i];
parent2 = parents[i + 1];
p1.addCrossed(parent1, parent2, count=rpois(1, 2.7));
}

Ben Haller

unread,
May 6, 2025, 8:33:56 PMMay 6
to Viv, slim-discuss
Hi Viv!

People mean different things by "monogamous mating", but here's one example of the approach you might want to take:

initialize() {

initializeSLiMModelType("nonWF");

initializeSex();

defineConstant("K", 500); // carrying capacity

}

reproduction() {

// monogamous mating between whoever is around

males = p1.subsetIndividuals(sex="M");

females = p1.subsetIndividuals(sex="F");

pairs = min(size(males), size(females));

// sample down to the number of pairs; this also shuffles the individuals

males = sample(males, pairs);

females = sample(females, pairs);

// mate pairs, with a mean litter size of 2.5

for (m in males, f in females)

p1.addCrossed(f, m, count=rpois(1, 2.5));

// everybody has reproduced; don't do any more reproduction this tick

self.active = 0;

}

1 early() {

sim.addSubpop("p1", K);

}

early() {

p1.fitnessScaling = K / p1.individualCount;

}

2000 late() { }

It might not do exactly what you want.  In general, the first step should be to work out *exactly* what you want to have happen, with pencil and paper.  Who mates with who, what happens if the sex ratio is unbalanced, etc.?  Once you know exactly what you want to have happen, I find the correct implementation in code is generally much clearer.  Happy modeling!

Cheers,
-B.

Benjamin C. Haller
Messer Lab
Cornell University


Viv wrote on 5/6/25 5:51 PM:
--
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/620762bb-bab3-4d2c-b437-5a346a947a7cn%40googlegroups.com.

Viv

unread,
May 7, 2025, 12:55:12 PMMay 7
to slim-discuss
Ah its the sampling down bit I was missing. That's been a great help. Thank you!
Reply all
Reply to author
Forward
0 new messages