I'm trying to simulate an admixed population and keep track of local ancestry of mutations in the admixed population, by which I mean the most recent population that contributed that mutation to the individual. The difficulty is that the mutations are shared between the mixing populations---so subpopID won't work, since I actually care if an individual got a given mutation from ancestral population A or ancestral population B, not which population it arose in. Hopefully that makes sense.Thanks!
--
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/c7c9ab1f-4405-48f6-8190-b6a26cfddf3dn%40googlegroups.com.
initialize() {
initializeTreeSeq();
// .... other parameters
}
1 late() {
sim.addSubpop("p1", 1000);
}
1:2000 late() {
// ... evolution I want to happen in the ancestral pop
}
2000 early() {
sim.addSubpopSplit("p2", 1000, p1);
}
2000:2050 late() {
// ... evolution I want to happen in the split pops
}
2050 late() {
sim.treeSeqRememberIndividuals(sim.subpopulations.individuals); //I'm trying to remember the parents of the migrants, I think?
sim.addSubpop("p3", 1000);
p3.setMigrationRates(c(p1, p2), c(0.7, 0.3));
}
2051 late() {
p3.setMigrationRates(c(p1, p2), c(0.0, 0.0));
p1.setSubpopulationSize(0);
p2.setSubpopulationSize(0);
}
2061 late() {
sim.treeSeqOutput("~/Desktop/test_trees.trees");
sim.simulationFinished();
}
Then I load this into python with tskit, and my intuition is that I can traverse up the tree from each sample to the first remembered individual, and that should indicate their ancestry at that position? My naive implementation here seems to give me something plausible, although maybe there's something easier/faster that can be done?
ancestry = [] #initialize ancestry array
for tree in trees.trees(): #loop over trees
ancestry.append([[] for i in range(1000)]) #For each tree, make an array of diploid ancestry for 1000 people
for sample in tree.samples(): #loop over samples in the tree
cur_ind = trees.node(sample).individual #get the individual index of the person
if trees.node(sample).population!=2: continue #skip over the remembered individuals
#traverse tree
node = sample
parent = tree.parent(node)
while trees.node(parent).population==2: #if the parent is in the admixed population, then keep going
node = parent
parent = tree.parent(node)
#add to my growing list
ancestry[-1][cur_ind].append(trees.node(parent).population)
It'd be great if I could get some feedback and make sure that my intuition is right!
Thanks!
Josh
To view this discussion on the web visit https://groups.google.com/d/msgid/slim-discuss/CAHitvMmsb4uLqGph5MJ1NOuOVAw1tso0EmZwTezBbqLTNriVsQ%40mail.gmail.com.
You received this message because you are subscribed to a topic in the Google Groups "slim-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/slim-discuss/0O4ynHxA8L4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to slim-discuss...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/slim-discuss/PH0PR10MB472747357653EF6087D0FA7CA5CAA%40PH0PR10MB4727.namprd10.prod.outlook.com.