Hi Luca! For one thing, I think you've got
an issue with this line:
p1.individuals.setSpatialPosition(p1.pointUniform(size(p1)));
The size(p1) call doesn't do what you want it to do. The size of p1 is
1; it is a vector of length 1, containing just one subpopulation. The
number of individuals in a subpopulation can be obtained from the
individualCount property, so try this instead:
p1.individuals.setSpatialPosition(p1.pointUniform(p1.individualCount));
The other problem in your model relates to this detail in the doc for
addRecombinant():
Also beginning in SLiM 4.1, in spatial models the spatial position of
the offspring will be inherited (i.e., copied) from parent1; more
specifically, the x property will be inherited in all spatial models
(1D/2D/3D), the y property in 2D/3D models, and the z property in 3D
models. Properties not inherited will be left uninitialized, as they
were prior to SLiM 4.1. The parent’s spatial position is probably not
desirable in itself; the intention here is to make it easy to model the
natal dispersal of all the new offspring for a given tick with a single
vectorized call to deviatePositions() / pointDeviated(). If parent1 is
NULL (the default), parent2 will be used; if it is also NULL, no spatial
position will be inherited.
You aren't specifying the parents of the offspring individuals in your
calls to addRecombinant(), so they are ending up being whatever
uninitialized memory contains – often zero, thus favoring the corner.
If you add appropriate parent information to your addRecombinant()
calls, your model should then work fine. :-> Perhaps this
particular situation ought to cause an error; I'll think about that.
Happy modeling!
Cheers,
-B.
Benjamin C. Haller
Messer Lab
Cornell University
Luca Soldini wrote on 6/7/24 5:33 PM: