same SpatialMap for two subpopulations

12 views
Skip to first unread message

Padovani, Giada

unread,
Jun 13, 2024, 6:49:32 AMJun 13
to slim-discuss
Hi Ben,

I'm trying to load a map and add two different subpopulations, one is expanding starting from the north and the other from the south, but I'm not able to display them on the same map. I only have errors or two different maps. Do you have any advice?
Latest try was this:

1 early() {

sim.addSubpop("p1", 50);

sim.addSubpop("p2", 50);


p1.setSpatialBounds(c(0.0, 0.0, 1198, 1046));

p2.setSpatialBounds(c(0.0, 0.0, 1198, 1046));

mapImage = Image("./map.png");

map = p1.defineSpatialMap("world", "xy", (1.0) - mapImage.floatK, valueRange=c(0.0, 1.0) , colors=c("black", "white"));

p2.addSpatialMap(map);

defineConstant("MAP", map);


for (ind in p1.individuals) {

px = runif(1, 900, 940);

py = runif(1, 50, 90);

p = (c(px, py));

ind.setSpatialPosition(p);}


for (ind in p2.individuals) {

px = runif(1, 450, 500);

py = runif(1, 990, 1110);

p = (c(px, py));

ind.setSpatialPosition(p);}


}



Thank you again for the great workshop in Ancona.

Best,
Giada

Ben Haller

unread,
Jun 13, 2024, 7:42:17 AMJun 13
to Padovani, Giada, slim-discuss
Hi Giada!

Well, I put your code into a simple 2D model, using a spatial map I had lying around, and it seemed to work fine.  So you need to provide more information.  Can you supply the complete code for your model, rather than just the 1 early() event?  And the input map file?  And what error is it that you are getting?  It's hard to guess what the problem might be; you certainly ought to be able to make a model in which two subpopulations share the same map.

Cheers,
-B.

Benjamin C. Haller
Messer Lab
Cornell University


Padovani, Giada wrote on 6/13/24 11:49 AM:
--
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 on the web visit https://groups.google.com/d/msgid/slim-discuss/f432d8c5-4226-4762-9bb8-84a76ff575a7n%40googlegroups.com.

Ben Haller

unread,
Jun 13, 2024, 7:59:24 AMJun 13
to Padovani, Giada, slim-discuss
Hi Giada!

Aha, so this is just about the display?  OK, in that case, try clicking on the p1 action button (gear icon) and selecting "Display Spatial (Unified)".  That will display the two subpops as a single display on top of the same map.  Happy modeling!


Cheers,
-B.

Benjamin C. Haller
Messer Lab
Cornell University


Padovani, Giada wrote on 6/13/24 12:51 PM:
Hi Ben,

Sure, here is the script and the map. With this code I don't get errors but two different maps, one with p1 and one with p2, instead of one with both populations.

best,
Giada

From: Ben Haller <bha...@mac.com>
Sent: Thursday, June 13, 2024 7:42 AM
To: Padovani, Giada <gi.pa...@ufl.edu>
Cc: slim-discuss <slim-d...@googlegroups.com>
Subject: Re: same SpatialMap for two subpopulations
 
[External Email]

Padovani, Giada

unread,
Jun 13, 2024, 8:56:12 AMJun 13
to Ben Haller, slim-discuss
Oohh I was missing that!
I'm sorry for the silly question!

Thank you,
Giada

From: Ben Haller <bha...@mac.com>
Sent: Thursday, June 13, 2024 7:59 AM

Ben Haller

unread,
Jun 13, 2024, 10:06:59 AMJun 13
to Padovani, Giada, slim-discuss
No worries, this feature is a bit hidden – probably somebody else just learned about it because of this thread, too.  :->


Cheers,
-B.

Benjamin C. Haller
Messer Lab
Cornell University


Padovani, Giada wrote on 6/13/24 1:56 PM:
Reply all
Reply to author
Forward
0 new messages