Somatic Mutations in non-WF Model

7 views
Skip to first unread message

Camille Rumberger

unread,
Nov 10, 2025, 11:58:02 AM (13 days ago) Nov 10
to slim-discuss
Hi Ben,

I've been working on a script modeling adaptation to an environmental gradient in a partially-clonal organism. I was hoping to add somatic mutations to this simulation, but am running into an issue with adding mutations to individuals of age > 0 because I have tree-seq enabled. I want these somatic mutations to have potential fitness effects, so I don't think it makes sense to model these mutations in post-processing with pyslim. This is the callback that I am currently (trying to) use:

```

late() { 

inds = sim.subpopulations.individuals;

for (ind in inds)

{

for (genome in ind.genomes)

{

if(runif(1) <= MU_SOM)

{

pos = rdunif(1, min=0, max=1000000);

genome.addNewDrawnMutation(m2, pos); // not working because we can't add new mutations to any individual older than age 0 while treeseq is on

}

}

}

}

```


Any advice about alternatives for modeling somatic mutations would be welcome - maybe it would make sense to try and indirectly model the fitness effects of somatic mutations rather than adding them directly to the simulation?


Thanks!

Camille

Ben Haller

unread,
Nov 10, 2025, 3:05:58 PM (13 days ago) Nov 10
to Camille Rumberger, slim-discuss
Hi Camille!

Yes, you can't add mutations to individuals at age > 0 when doing tree-sequence recording.  I think – Peter can clarify – that restriction is actually necessary on the tskit end of things as well; it isn't just a limitation on the SLiM side.

So, what to do?  I can think of two basic alternatives:

- When a somatic mutation occurs, clone the original individual to make a new "descendant" individual that has the somatic mutation, and then probably kill the original individual (unless you want to keep both, to represent cells in the individual that do/don't possess the new mutation; you could potentially keep many separate clonal lineages representing different somatic cell lines within each individual!)

- When a somatic mutation occurs, keep track of that in some way in your own data structure.  At the simplest level, maybe you use tagF to hold the accumulated fitness effects of all somatic mutations an individual has undergone, or at the most complex level, maybe you keep a DataFrame object for each individual (using setValue() to attach it to the individual), with information in columns about time of mutation, selection coefficient, and other data.

Either way, you can put the total fitness effect into fitnessScaling for the individual to make it actually do something.  And either way, you could persist the information in the .trees file using the top-level metadata dictionary that you can pass to treeSeqOutput().  Which of the above approaches makes more sense probably depends on what exactly you're trying to do.  :->

I hope this clarifies things a bit!  Happy modeling!

Cheers,
-B.

Benjamin C. Haller
Messer Lab
Cornell University



Camille Rumberger wrote on 11/10/25 11:58 AM:
--
SLiM forward genetic simulation: http://messerlab.org/slim/
Before posting, please read http://benhaller.com/slim/bugs_and_questions.html
---
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/bac72f25-9ad2-4f17-9b80-8e747fc1b0f6n%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages