# Multiple Loci Selection with Multi-Way Epistasis in Coalescence with Recombination
## 2 Materials and Methods
### The Coalescent Simulator
#### 2.1.1 Selection Scenarios  
Effective population size is the reciprocal of the probability that two individuals will have the same parent--or that two chromosomes in the next generation will share the same parent chromosome. Fitness, in this case, would just be the ratio of the probability that the parent chromosome lineage with the allele will have an offspring chromosome to the probability that a parent chromosome lineage without the allele (neutral) will have an offspring chromosome [24]. The fitness, \(1+s\) is thus the expected number of copies that a copy of the allele gives rise to in generation \(t+1\), relative to the expected number that a neutral allele will give rise to. Thus, in infinitely large populations, the proportion of alleles under selection in a generation is related to the effective population size. Let \(N_{s}\) be the partially effective population size with the allele under selection and \(N_{s}\) (\(=N-N_{s}\)) is the partially effective population size with the reference or ancestral allele which is not under selection, giving:  
\[\frac{N_{s}}{N_{s}+N_{s}}:\frac{N_{s}}{N_{s}+N_{s}}=1+s:1\implies N_{s}=\frac{ 1+s}{2+s}N=f_{s}N. \tag{1}\]  
Thus \(-1<s\), extendable to multiple loci with or without epistasis and the fitness defined as  
\[f_{s}=\frac{1+s}{2+s}. \tag{2}\]  
The fitness coefficient is a representative average of the allele frequency of the selected alleles in a generation, \(p\). With the allele frequency, the effective population size with selection at a single locus would be \(\mathbb{E}[N_{s}]=\frac{(1+s)PN}{(1+ps)}\) where the fitness \(f_{s}=\frac{p(1+s)}{(1-p)}\). The effective population size is defined as \(N_{z}=2 Nf^{\prime}\) where \(f^{\prime}\) is the fitness for \(l_{z}\)-coalescence in the coalescent simulator and \(N_{z}\) is the effective population size for \(l_{z}\) lineage coalescence with alleles under selection.  
The \(f^{\prime}\) varies with neutral or epistatic scenarios for the loci under selection. For a neutral scenario with no selection \(f^{\prime}\) is defined as follows  
\[f^{\prime}=1-\sum_{i}f_{s_{i}}+\sum_{i,j}f_{s_{ij}}-f_{s_{i}p_{j}}, \tag{3}\]  
where we remove the fitness effects of odd sites under selection and add the effects from even sites in a simulation scenario with three Single Nucleotide Polymorphisms or SNPs (\(\alpha\), \(\beta\) and \(\gamma\)) are considered to be under selection. Alternatively, for a single locus (\(\alpha\)) under selection with no epistasis in effect \(f^{\prime}\) will be defined as follows with the signs reversed for even and odd sites under selection  
\[f^{\prime}=f_{s_{a}}-\sum_{i}f_{s_{ai}}+\sum_{i,j}f_{s_{aij}}. \tag{4}\]  
For two or multiple loci under selection there can be two cases with differing \(f_{s}\). We define it as follows:\[f_{s}=\begin{cases}f_{e_{s_{\theta},..}}&\text{with epistasis}\\ \prod_{i}^{\omega}f_{s_{i}}&\text{without epistasis},\end{cases}\]  
where \(e_{s}\) is the user defined epistatic coefficient when epistasis is in effect across all \(\omega\) sites. For a scenario with all three sites are under selection \(f^{\prime}=f_{s_{\theta}p}\).