MimicrEE2 implements two mating functions, that is functions that randomly pick two individuals which perform one mating (the lucky couple). Every individual may participate in multiple matings.
With the fecundity mating function, mating success linearly scales with fitness and with the random function all individuals have an equal probability of engaging in mating (e.g after truncating selection).
Fecundity mating requires that the mating success of individuals linearly scales with fitness. For example an individual with fitness 1.0 will mate twice as often as an individual with fitness 0.5.
To test the fecundity mating function we generated a population of 100 individuals having a fitness ranging from 0.0 to 2.0 using an increment of 0.02.
We than simulated 100.000 matings and counted the number of times each individual mated.
In the above graph, the histogram shows the observed matings and the dashed line the expected matings.
This graphic demonstrates that fecunditiy mating is correctly implemented in MimicrEE2
Random mating requires that all individuals have an equal chance of mating, irrespective of their genotype/phenotype/fitness. Random mating is, for example, used after truncating selection. Based on phenotypic values some individuals are removed from the population during truncating selection, but the remaining individuals have an equal chance of engaging in mating.
To test the random mating function we generated a population of 100 individuals having a fitness ranging from 0.0 to 2.0 using an increment of 0.02.
We than simulated 100.000 matings and counted how often each individual mated.
In the above graph, the histogram shows the observed matings and the dashed line the expected matings. This graphic demonstrates that random mating is correctly implemented in MimicrEE2
:::java
package mim2.test.matingFunctionTester;
import mim2.test.recombinationTest.RecombinationWriter;
import mimcore.data.MatePair;
import mimcore.data.Population;
import mimcore.data.Specimen;
import mimcore.data.gpf.mating.MatingFunctionFecundity;
import mimcore.data.gpf.mating.MatingFunctionRandomMating;
import mimcore.data.misc.Tuple;
import java.util.ArrayList;
import java.util.Random;
/**
* Created by robertkofler on 23/11/2017.
*/
public class MatingTester {
public static void testFecundity()
{
ArrayList<Specimen> spec=new ArrayList<Specimen>();
for(double i=0.0; i<2.01; i+=0.02)
{
Specimen s=new Specimen(1.0,1.0,i,null);
spec.add(s);
}
MatingFunctionFecundity mfec=new MatingFunctionFecundity(new Population(spec));
ArrayList<Tuple<Double,Integer>> tuples = new ArrayList<Tuple<Double, Integer>>();
Random rand = new Random();
for(int i=0; i<100000; i++)
{
MatePair couple= mfec.getCouple(rand);
Specimen male=couple.getMale();
Specimen female=couple.getFemale();
tuples.add(new Tuple<Double,Integer>(male.fitness(),1));
tuples.add(new Tuple<Double,Integer>(female.fitness(),1));
}
# RecombinationWriter is a misleading name; should be called TupleWriter
RecombinationWriter rw=new RecombinationWriter("/Users/robertkofler/dev/mimicree2/theoreyvalidation/mating/mating-fecundity.txt");
rw.write(tuples);
}
public static void testRandom()
{
ArrayList<Specimen> spec=new ArrayList<Specimen>();
for(double i=0.0; i<2.01; i+=0.02)
{
Specimen s=new Specimen(1.0,1.0,i,null);
spec.add(s);
}
MatingFunctionRandomMating mfec=new MatingFunctionRandomMating(new Population(spec));
ArrayList<Tuple<Double,Integer>> tuples = new ArrayList<Tuple<Double, Integer>>();
Random rand = new Random();
for(int i=0; i<100000; i++)
{
MatePair couple= mfec.getCouple(rand);
Specimen male=couple.getMale();
Specimen female=couple.getFemale();
tuples.add(new Tuple<Double,Integer>(male.fitness(),1));
tuples.add(new Tuple<Double,Integer>(female.fitness(),1));
}
# RecombinationWriter is a misleading name; should be called TupleWriter
RecombinationWriter rw=new RecombinationWriter("/Users/robertkofler/dev/mimicree2/theoreyvalidation/mating/mating-random.txt");
rw.write(tuples);
}
}
The following R script was used to generate the above graphic for the fecundity mating function.
library(ggplot2)
theme_set(theme_bw())
rec<-read.table("/Users/robertkofler/dev/mimicree2/theoreyvalidation/mating/mating-fecundity.txt")
names(rec)<-c("fitness","shit")
lin<-data.frame(x=c(0,2.0),y=c(0,3960.396))
g<-ggplot(rec,aes(x=fitness))+geom_histogram(breaks=seq(0.01,2.01,0.02),fill="grey",col="darkgrey")+
geom_line(data=lin,aes(x=x,y=y),linetype=2,col="black")+xlim(0,2.1)+ylab("matings [count]")
pdf("/Users/robertkofler/dev/mimicree2/theoreyvalidation/mating/mating-fecundity.pdf",width=5,height=5)
plot(g)
dev.off()
The following R script was used to generate the above graphic for the random mating function.
library(ggplot2)
theme_set(theme_bw())
rec<-read.table("/Users/robertkofler/dev/mimicree2/theoreyvalidation/mating/mating-random.txt")
names(rec)<-c("fitness","shit")
lin<-data.frame(x=c(0,2.0),y=c(1980.198,1980.198))
g<-ggplot(rec,aes(x=fitness))+geom_histogram(breaks=seq(0.01,2.01,0.02),fill="grey",col="darkgrey")+
geom_line(data=lin,aes(x=x,y=y),linetype=2,col="black")+xlim(0,2.1)+ylab("matings [count]")
pdf("/Users/robertkofler/dev/mimicree2/theoreyvalidation/mating/mating-random.pdf",width=5,height=5)
plot(g)
dev.off()