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: