Closed MrLocuace closed 6 years ago
I think this page has an example on how to use a demographic model. You only need to change model
to an instance of OutOfAfricaModel(...)
.
Hi Bo, I did it the way you suggested:
model = sim.demography.OutOfAfricaModel(8800, outcome=['AF'])
pop.evolve(
matingScheme=sim.RandomMating(
subPopSize=model ),
gen=100
)
However, when I try to export the genotypes in ms format:
sim.utils.export(pop, format='ms',output='mypop.txt')
I get an error:
2018-10-02 18:58:51.382 python[3825:536428] -[NSApplication _setup:]: unrecognized selector sent to instance 0x10ff2ee20
Traceback (most recent call last):
File "simupop_test11.py", line 134, in <module>
sim.utils.export(pop, format='ms',output='/path/mypop.txt')
File "~/miniconda2/lib/python2.7/site-packages/simuPOP/utils.py", line 3095, in export
Exporter(format, *args, **kwargs).apply(pop)
RuntimeError: Unknown runtime error happened.
In utils.py, line 3095:
def export(pop, format, *args, **kwargs):
'''Apply operator ``Exporter`` to population *pop* in format *format*.'''
Exporter(format, *args, **kwargs).apply(pop)
Do you know what is happening?
Thanks very much again
No,
unrecognized selector sent to instance 0x10ff2ee20
does not look familiar to me. Perhaps you can create a minimal example to demonstrate the problem? You can create for example a population with 1 locus and some random sex and genotype etc...
Hi Bo, thank you for your reply
model = sim.demography.OutOfAfricaModel(T0=8800, outcome=['AF'])
pop = sim.Population(size=[30], loci=10)
pop.evolve(initOps=[
sim.InitSex(),
sim.InitGenotype(freq=[0.5, 0.5])
],
matingScheme=sim.RandomMating(subPopSize=model),
gen=100
)
sim.utils.export(pop, format='ms',output='mypop.txt')
Perhaps it has something to do when importing matplotlib in a Mac OS computer. I remember it was working before I did "import matplotlib", but now even without "import matplotlib" I am unable to export in ms format because of this error
A complete script
import simuPOP as sim
from simuPOP import demography
model = demography.OutOfAfricaModel(T0=8800, outcome=['AF'])
pop = sim.Population(size=[30], loci=10)
pop.evolve(initOps=[
sim.InitSex(),
sim.InitGenotype(freq=[0.5, 0.5])
],
matingScheme=sim.RandomMating(subPopSize=model),
gen=100
)
sim.utils.export(pop, format='ms',output='mypop.txt')
works ok here, so it might be something wrong with your environment. I would suggest that you create a new conda environment just for simuPOP and try again.
Thank you Bo, I'll do it in that way
Dear Bo, I would like to use previously generated genotypes of a population A (n=7300; stored in an object "pop") and make these genotypes evolve under the class simuPOP.demography.OutOfAfricaModel, which has parameter N_A=7300. May I ask you how can I do this?
Many thanks, Luc