initializeRecombinationRate(1e-7);
initializeGeneConversion(1.0,500,1.0); //only gene conversion, mean 500 and only simple gc events.
//mutation rate
initializeMutationRate(1e-7);
// m1 mutation type: neutral
initializeMutationType("m1", 0.5, "f", 0.0);
// g1 genomic element type: uses m1 for all mutations
initializeGenomicElementType("g1", m1, 1.0);
// chromosome of length 1 Mb with uniform gene conversion
initializeGenomicElement(g1, 0, 999999);
initializeRecombinationRate(1e-7);
initializeGeneConversion(1.0,500,1.0);
}
recombination() {
n_new_breakpoints=rpois(1,2*1e-7*1e6);
new_breakpoints=asInteger(runif(n_new_breakpoints,0,999999));
//breakpoints=sort(new_breakpoints);
breakpoints=sort(breakpoints);
return T;
}
// create a population of 1000 individuals
1 early() {
sim.addSubpop("p1", 1000);
}
//end
10000 late() {
sim.simulationFinished();
}
the pattern of frequencies is very linked:

Instead, If I use new breakpoints with the same rate and the same average number of events, the pattern is completely different:
//mutation rate
initializeMutationRate(1e-7);
// m1 mutation type: neutral
initializeMutationType("m1", 0.5, "f", 0.0);
// g1 genomic element type: uses m1 for all mutations
initializeGenomicElementType("g1", m1, 1.0);
// chromosome of length 1 Mb with uniform gene conversion
initializeGenomicElement(g1, 0, 999999);
initializeRecombinationRate(1e-7);
initializeGeneConversion(1.0,500,1.0);
}
recombination() {
n_new_breakpoints=rpois(1,2*1e-7*1e6);
new_breakpoints=asInteger(runif(n_new_breakpoints,0,999999));
breakpoints=sort(new_breakpoints);
//breakpoints=sort(breakpoints);
return T;
}
// create a population of 1000 individuals
1 early() {
sim.addSubpop("p1", 1000);
}
//end
10000 late() {
sim.simulationFinished();
}

--
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 visit https://groups.google.com/d/msgid/slim-discuss/21B3FC08-D8B6-4114-82D7-0945344E070C%40gmail.com.
Thank you very much! I hope you have a fast recovery!
Simplifying:
1. The recombination() callback only provides new crossover breakpoints. Once the callback finishes, any new breakpoints that were not initially defined by SLiM will result in crossover events.
2. I don’t fully understand how to implement the following: "If you want more control over gene conversion than SLiM provides, you can implement any gene conversion algorithm you want in your recombination() callback."
Could you provide a small example or some help? It is unclear to me how this callback interacts with SLiM's functions. It seems that the only modifiable value inside recombination() is breakpoints. I don’t see a way to implement gene conversion within it. For example, functions like removeMutations() or addMutations(), which could be useful for transferring mutations between strands, are not allowed inside the recombination() callback.
Thanks!
Sebastian
<image.png>
<image.png>
Additionally, I would like to know (i) if there is a possibility to know (in the case of having a proportion of crossing-overs and gene conversion events) what position suffers gene conversion and what suffers recombination, and (ii) if there is a possibility to assign to a position a gene conversion and not a recombination event (or the inverse).Best,Sebastian
To view this discussion visit https://groups.google.com/d/msgid/slim-discuss/6B6F7DAE-3FCB-4516-BF50-08A51FD93FC6%40gmail.com.
// set up a simple neutral simulation
initialize() {
setSeed(123456);
defineConstant("L",1e6);
defineConstant("mut_rate",1e-6);
defineConstant("gc_rate",1e-7);
defineConstant("gc_rate_genome",gc_rate*L);
defineConstant("mean_len_gc",500);
defineConstant("Ne1",500);
initializeSLiMOptions(nucleotideBased=T);
initializeAncestralNucleotides(randomNucleotides(L));
// m1 mutation type: neutral
initializeMutationTypeNuc("m1", 0.5, "f", 0.0);
// g1 genomic element type: uses m1 for all mutations
initializeGenomicElementType("g1", m1, 1.0, mmJukesCantor(mut_rate/3));
// uniform chromosome of length 100 kb with uniform recombination
initializeGenomicElement(g1, 0, L-1);
//rec map separated in three regions: high-no-high recombination
rates = c(1e-7,0,1e-7);
ends = c(25e4,75e4,10e5-1);
initializeRecombinationRate(rates, ends);
initializeGeneConversion(0,0,1.0);
//writeFile(filePath="breakpoints_v4.txt",contents=(""),append=F);
//writeFile(filePath="gene_conversion_v4.txt", contents=(""), append=F);
}
function (void)do_uniform_gene_conversion(numeric Nep) {
//calculate the number of possible gene conversion events per generation
num_gc_events = rpois(Nep,2*gc_rate_genome); //number of simple gc events at each individual
ngc_no0=which(num_gc_events>0); //Look only at individuals that have gc events
//look at gene conversion per individual
for(i in ngc_no0) {
// code to check that gc positions are not overlapping (assuming threshold 10x mean len)
if(num_gc_events[i]>1) {
ml=0;
do {
pos_gc_events_sort = sort( asInteger(runif(num_gc_events[i],0,L))); // sorted positions of gc/individual
x=0;
ml = pos_gc_events_sort[x+1]-pos_gc_events_sort[x] <= mean_len_gc*10; //1 means overlapped
while(x<num_gc_events[i]-1 & ml == 0) {
ml = pos_gc_events_sort[x+1]-pos_gc_events_sort[x] <= mean_len_gc*10 ;
x=x+1;
}
}
while(ml==1);
}
else pos_gc_events_sort = sort(asInteger(runif(num_gc_events[i],0,L))); // sorted positions of gc/individual
//define length of gc events (simply one step, only forward), define donor and receptor genomes
len_gc = rgeom(num_gc_events[i],1/mean_len_gc);//lengths gc events
dc = asInteger(rbinom(num_gc_events[i],1,0.5)); //donor chain for each gc event
ndc=1-dc; //receptor
//writeFile(filePath="gene_conversion_v4.txt", contents=(paste(asInteger(pos_gc_events_sort),sep="\n")),append=T);
//replace mutations from one chain to another. Look at each gc event (and per individual)
//This is many times slower than recombination() callback!
//But, how to separate rec from gc using recombination()?
for( x in 0:(num_gc_events[i]-1)) {
//find donor and receptor, mutations and positions:
donor=sim.subpopulations.individuals[i].genomes[dc[x]]; //very slow!
receptor=sim.subpopulations.individuals[i].genomes[ndc[x]]; //very slow!
mut_donor=donor.mutations;
mut_receptor=receptor.mutations;
mut_donor_position=mut_donor.position;
mut_receptor_position=mut_receptor.position;
init_position=pos_gc_events_sort[x];
max_position=pos_gc_events_sort[x] + len_gc[x];
//positions of mutations implicated in gc from donor //very slow!
mut_gc_donor = mut_donor[mut_donor_position>=init_position & mut_donor_position < max_position];
//positions of mutations implicated in gc from receptor //very slow!
mut_gc_receptor = mut_receptor[mut_receptor_position >=init_position & mut_receptor_position < max_position];
if(length(mut_gc_receptor)) {
receptor.removeMutations(mut_gc_receptor);
}
if(length(mut_gc_donor)) {
receptor.addMutations(mut_gc_donor);
}
}
}
}
//recombination() {
// breakpoints=sort(c(breakpoints));
// writeFile(filePath="breakpoints_v4.txt", contents=(paste(asInteger(breakpoints),sep="\n")),append=T);
// return T;
//}
// create a population of Ne1 individuals
1 early() {
sim.addSubpop("p1", Ne1);
}
// add ONLY uniform gene conversion and not recombination
1:2000 early() {
do_uniform_gene_conversion(Ne1);
}
2000 late() {
sim.simulationFinished();
}
To view this discussion visit https://groups.google.com/d/msgid/slim-discuss/37085576-0BB5-4DF7-A225-397EB6ACAAF2%40gmail.com.