As pointed out by Tianzhu Xiong in the SLiM mailing list, ts.individual_locations gets its information from nodes, and is therefore the birth location; while individual metadata contains the "current" population; these differ if the individual is a migrant.
alive = ts.individuals_alive_at(0)
adults = alive[ts.individual_ages[alive] > 2]
pops = [np.where(
ts.individual_populations[adults] == k)[0] for k in [1, 2]]
but if we want to sample individuals from where they currently (at the end of the simulation) are, which is probably what the user would want, then we would instead do something like (not tested!):
pops = [
[i for i in adults if ts.individual(i).metadata['subpopulation'] == k]
for k in [1, 2]
]
Probably individual_locations should be renamed individual_birth_locations or something?
As pointed out by Tianzhu Xiong in the SLiM mailing list,
ts.individual_locations
gets its information from nodes, and is therefore the birth location; while individual metadata contains the "current" population; these differ if the individual is a migrant.So, the tutorial currently has
but if we want to sample individuals from where they currently (at the end of the simulation) are, which is probably what the user would want, then we would instead do something like (not tested!):
Probably
individual_locations
should be renamedindividual_birth_locations
or something?