fitnessEffect() callback for loss-of-function recessive effect

12 views
Skip to first unread message

Grace Rhodes

unread,
Aug 6, 2025, 10:28:02 AMAug 6
to slim-discuss

Hi all,


I am trying to use a fitnessEffect() callback to model loss-of-function mutations where individuals have decreased fitness when they have at least one mutation on both of their haplosomes. I chose to use fitnessEffect() because it is implemented per individual rather than per mutation per individual so that compound heterozygosity can have the same impact on fitness as homozygosity. My goal was to define fitnessEffect() to return a constant set in command line, DELTA, if the individual has a mutation on both copies and return 1 otherwise. From my understanding a fitness of 1 would be neutral (since all other fitness for the individual would be multiplied by 1), so DELTA would be set between 0 and 1 and homozygosity/compound heterozygosity would be more strongly selected against as DELTA gets smaller. However, when I look across multiple runs comparing DELTA=0.1 with DELTA=1.0, I see more homozygosity/compound heterozygosity for the smaller DELTA value (the opposite of what I had anticipated). The script is included below if anyone has any ideas of what I am doing wrong or debugging tips it would be very much appreciated!


Best,

Grace




// constants set in command line:
/// SAMP_SIZE: number of individuals to sample
/// DELTA: fitness value to be used in individuals with 2 affected gene copies, [0,1)

initialize() {
initializeMutationRate(1.24e-8);
// one mutation type: recessive neutral, fitness function defined later
initializeMutationType("m1", 0.0, "f", 0.0);
initializeGenomicElementType("g1", m1, 1.0);
initializeGenomicElement(g1, 0, 12500);
initializeRecombinationRate(1e-8);
}

// initialize one pop'n with 100k individuals
1 early() {
sim.addSubpop("p1", 100000);
}


fitnessEffect(){
num_lof = individual.haplosomes.countOfMutationsOfType(m1);
if ((num_lof[0]>0)&(num_lof[1]>0)) return DELTA;
else return 1.0;
}

// output sample of individuals after 10k generations
10000 late() {
allIndividuals = sim.subpopulations.individuals;
sampledIndividuals = sample(allIndividuals, SAMP_SIZE);
sampledIndividuals.haplosomes.outputHaplosomes();
}

Ben Haller

unread,
Aug 7, 2025, 9:37:42 AMAug 7
to Grace Rhodes, slim-discuss
Hi Grace!

I'm traveling right now so I'm not in a position to look into this much at the moment.  The SLiM script looks simple enough, and the result certainly seems to be the opposite of what's expected.  I'd suggest that:

- the bug is probably either in your script that calls out to SLiM (providing the opposite DELTA value of what you intend) or in your post-run script (similarly)

- you can probably scale down the model a lot and validate that the model itself is behaving as you would expect directly in SLiMgui, visually and with some print statements sprinkled around and such.  I'd suggest doing that – rather than trying to debug the problem through cryptic output files, debug the problem directly in SLiMgui, visually and interactively.  That's what SLiMgui is there for!  :->

If you remain stumped after investigating further, feel free to post again; provide information about all the steps you've taken to try to figure out the problem, and provide your pre- and post-run scripts since the bug is probably in them.  But of course others on the list may or may not have time to help you with the debugging process.  :->  Good luck and happy modeling!

Cheers,
-B.

Benjamin C. Haller
Messer Lab
Cornell University


Grace Rhodes wrote on 8/6/25 4:28 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/1a521214-1322-4617-a434-cbb3f25691dan%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages