Multilocus genotype frequencies

Published results using this notebook should cite:
Hospital, F., Dillmann, C. and Melchinger, A.E. (1996) A general algorithm to compute multilocus genotype frequencies under various mating systems. Comput. Appl. Biosci, 12(6):455-462.

Random Mating

Initialization

ClearAll["Global`*"];

Number of loci

n=3

General definitions

<<"definitions.ma"

Initial genotype frequencies

Tables

General recursion for gamete frequencies

Definitions

gamrec[x_]:=
Sum[
P[i,j][[x]]*2^delta[i,j]*q[t,i]*q[t,j],
{i,1,ngam},{j,i,ngam}]

ruleq[k_]:=Sum[q[t,k]q[t,j],{j,1,ngam}]->q[t,k]

Format[q[t_,x_]]:=Subscripted[q[t,x],{2}];
Format[q[t_,x_],TeXForm]:=Subscripted[q[x]][t];
Format[q[t,x_],TeXForm]:=Subscripted[q[x]]

Format[z[x_,y_]]:=q[t,x]q[t,y];
Format[z[x_,y_],TeXForm]:=q[t,x]q[t,y]

ligne[k_]:=
Collect[Together[gamrec[k]]/.ruleq[k]/.
r[1]r[2]->zz,{r[1],r[2],zz}]/.
zz->r[1]r[2]/.
q[t,x_]q[t,y_]->z[x,y]

Visual Output

Table[{q["t+1",i],
"=",ligne[i]},
{i,1,ngam}]//ColumnForm

TeX Output

tabtex=Table[{q["t+1",i],
"=",ligne[i]},
{i,1,ngam}]//TableForm//TeXForm

Genotype frequencies at any generation

Definition

f[t_,x_,y_]:=f[t,x,y]=
2^delta[x,y]*
Sum[P[i,j][[x]]*f[t-1,i,j],{i,1,ngam},{j,i,ngam}]*
Sum[P[i,j][[y]]*f[t-1,i,j],{i,1,ngam},{j,i,ngam}]//Simplify

Initialization

Define all initial frequencies below:

Do[f[1,i,j]=f1[i,j],{i,1,ngam},{j,i,ngam}]

Output

f[3,1,2];