Hi Matthias! OK, so there are a variety of answers to this depending on what you're trying to do. One question is what the actual biology is that you're trying to model – *why*, biologically, do all copies of the beneficial allele have the same genetic background? Another question is how you plan to analyze the data afterwards; if you plan to use tree-sequence recording, then you might need the actual ancestry of that shared genetic background to be shared as well, whereas if you don't, then you don't need to worry about that. Here are some ideas:
- If this situation arises as the result of a hard selective sweep with hitchhiking, you might want to explicitly model that process. Section 9.3 of the manual shows an approach.
- If this situation arises through some kind of horizontal gene transfer, then you might want to explicitly model *that* process. Section 16.14 has an example of modeling HGT, in the context of haploid bacteria.
- Both of those approaches give you a sensible tree sequence, in which the shared region has a root in a common ancestor. If that is not important to you, then you can simply copy mutations from one individual to another, as your code snippet suggests:
target1 = sample(p1.genomes, 1);
target2 = sample(p1.genomes, 1);
if (target2 != target1)
{
target2.removeMutations();
target2.addMutations(target1.mutations);
}
That will work in either a nonWF or a WF model, but it will produce an ancestry in tree-sequence recording that makes no sense, since the biological process through which this genetic pattern arose was not modeled.
You say "haplotype"; I'm not sure whether you want to replace *all* the mutations in target2, or just those within some subset of the genome. If the latter, the code above is easy enough to modify; just remove/copy only the mutations within a given base position range.
I hope this helps; happy modeling!
Cheers,
-B.
Benjamin C. Haller
Messer Lab
Cornell University