Per-gene properties that affect selection coefficients

16 views
Skip to first unread message

Hannes Becher

unread,
Aug 27, 2025, 5:03:16 AM (11 days ago) Aug 27
to slim-discuss
Hi Ben and forum,

This is related to David Riker's question https://groups.google.com/g/slim-discuss/c/8--2HZRhen4/m/AS66YmcYAgAJ, but goes beyond it.

I would like to simulate a genome with multiple genes in it (hundreds or thousands). Each gene should have a property (a float value, say, reflecting the gene's expression level in the real world, outside SLiM). The selection coefficients of new mutations in each gene should then be a function of that gene's property.
Because there is no gene object in SLiM, I cannot just "make" genes with properties like this. What I can think of is:
  • (Programmatically) make one genomic element type per gene, each with its dedicated mutation type(s),
  • I could decide to have a limited set of gene property values and thus have classes of genes, so would only need a limited number of genomic element types, or I could
  • Use only one genome element type and use mutation effect callbacks and adjust mutation effects according to position/overlap with any specific gene
I'd be very happy to try any of these, but all these seem a little tedious to me and I wonder, have I missed something.

Hope this is clear,
All the best,
Hannes

Hannes Becher

unread,
Aug 27, 2025, 6:22:06 AM (11 days ago) Aug 27
to slim-discuss
Having thought about it, a more efficient way would be to adjust a mutation's effect once, when it is created, using a mutation() callback.

Peter Ralph

unread,
Aug 27, 2025, 9:10:03 AM (11 days ago) Aug 27
to Hannes Becher, slim-discuss
Hello!

That seems like the right way - and if you at the start of the simulation make a vector of length equal to the length of the genome, whose k-th element is the desired float value for mutations at that position, then it'd be quite easy (and O(1)) to just look up that value in the mutation callback.

--peter

From: slim-d...@googlegroups.com <slim-d...@googlegroups.com> on behalf of Hannes Becher <hannes...@gmail.com>
Sent: Wednesday, August 27, 2025 3:22 AM
To: slim-discuss <slim-d...@googlegroups.com>
Subject: Re: Per-gene properties that affect selection coefficients
 
--
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/427b7395-d5f6-4d78-ab90-6dec4d6ad2c3n%40googlegroups.com.

Hannes Becher

unread,
Aug 27, 2025, 10:52:55 AM (11 days ago) Aug 27
to slim-discuss
Thanks Peter! Exactly what I am doing ATM.
Now fingers crossed the results will be interesting...
Hannes

Ben Haller

unread,
Aug 28, 2025, 6:05:01 PM (10 days ago) Aug 28
to Peter Ralph, Hannes Becher, slim-discuss
Hi Hannes and Peter,

Perhaps a useful addendum to this discussion is that:

(1) the GenomicElement class, like most classes in SLiM, has a `tag` property that you can attach an integer value to; you could use this to annotate all of the genomic elements in your model (or perhaps just the ones representing exons, etc.) with `tag` values that indicate which gene they are a part of;

(2) the Chromosome class (you can get the focal chromosome in a single-chromosome model with sim.chromosome) has methods `hasGenomicElementForPosition()` and `genomicElementForPosition()` that allow you to look up the genomic element for a given position – from which you could then look up the `tag` value, telling you which gene that position belongs to, if any.

You could then have your mutation() callback look up the gene associated with the position that is mutating with genomicElementForPosition(), and based upon that, look up the DFE for that gene and draw the appropriate selection coefficient.  Something like that.  That would avoid needing a vector of length equal to the length of the genome (which might be quite long!); you'd only need a vector of length equal to the number of genes being modeled, and then the `tag` values attached to the genomic elements.

Whether this is better or worse than the design you and Peter have been discussing is hard to say.  :->  Arguably more elegant in some sense, but perhaps a little less performant?  Anyhow, just throwing this into the mix, since many people don't realize that you can attach information to genomic elements with the `tag` property.

Cheers,
-B.

Benjamin C. Haller
Messer Lab
Cornell University



Peter Ralph wrote on 8/27/25 9:09 AM:
Reply all
Reply to author
Forward
0 new messages