CHAPTER 11

1

1a

Activate the game-theory package and define the appropriate payoff matrix.

<<GameTheory.m

A={{.5,0,0},{.8,.4,0},{.64,.64,.32}};
ESStrategy[A]

1b, c, d

These parts can be done in a similar way.

2

There are four genotypes, T1P1, T1P2, T2P1 and T2P2, which we denote as 1, 2, 3 and 4. Let x be the vector of their frequencies in a particular generation, which will be the same in males and females before viability selection acts on males. We first calculate the genotype frequencies in males after viability selection, remembering to standardize them to sum to unity:

xm[x_]:=Module[{temp},
	temp=Table[If[i<=2,x[[i]],(1-s) x[[i]]],{i,4}];
		temp/Apply[Plus,temp]]

Next find the frequencies of matings between an i female and a j male, remembering to make the total frequency of matings of type i females sum to xi:

matfreq[x_]:=Module[{m,temp},
			m=xm[x];
			temp=Table[x[[i]]*m[[j]]*If[EvenQ[i]&&j>=3,a,1],
				{i,4},{j,4}];
			Do[temp[[i]]*=x[[i]]/Apply[Plus,temp[[i]]],
					{i,4}];
			temp]

Finally, compute the frequencies of the four different types of offspring from these matings under Mendelian inheritance with recombination fraction r between the two loci:

mendel=Table[0,{4},{4},{4}];
Do[mendel[[i,j,i]]+=1/2;mendel[[i,j,j]]+=1/2,{i,4},{j,4}];
mendel[[1,4]]=mendel[[4,1]]={(1-r),r,r,(1-r)}/2;
mendel[[2,3]]=mendel[[3,2]]={r,(1-r),(1-r),r}/2;

The vector of frequencies in the next generation can now be calculated:

nextx[x_]:=Sum[matfreq[x][[i,j]] mendel[[i,j]],{i,4},{j,4}];

However, it is more informative to do the simulations in terms of the gene frequencies for T2, t=x3+x4, and for P2, p=x2+x4, and the coefficient of linkage disequilibrium, d=x1x4-x2x3. Note that x1=(1-t)(1-p)+d, x2=(1-t)p-d,x3=t(1-p)-d,x4=tp+d. We may therefore write the recurrence for y = {t, p ,d} as

next[{t_,p_,d_}]:=Module[{x1,x2,x3,x4},
	{x1,x2,x3,x4}=nextx[
		{(1-t)(1-p)+d,(1-t)p-d,t(1-p)-d,t*p+d}];
	{x3+x4,x2+x4,x1*x4-x2*x3}]

We now find the general formula for this recurrence relation, and simplify the explicit results for the changes in the two gene frequencies:

res=next[{t,p,d}];

deltat=Simplify[res[[1]]-t]

deltap=Simplify[res[[2]]-p]

Thus
										t'=t+t(1-t)A
										p'=p+dA
										d'=something complicated
where
										A=(linear function of p and t)/(quadratic function of t)
as discussed in the text.

3

Isolate A from Exercise 2 and evaluate it with the given parameter values. Set up a simulation using the results in Exercise 2 using NestList.

4

Adapt Exercises 2 and 3.

5

Suppose that P2 females have fitness 1-k relative to P1 females. This can be incorporated into the model by defining a function xf[x_] similar to xm[x_] and changing matfreq.

xf[x_]:=Module[{temp},
	temp=Table[If[OddQ[i],x[[i]],(1-k) x[[i]]],{i,4}];
		temp/Apply[Plus,temp]]

matfreq[x_]:=Module[{m,f,temp},
			m=xm[x];
			f=xf[x];
			temp=Table[f[[i]]*m[[j]]*If[EvenQ[i]&&j>=3,a,1],
				{i,4},{j,4}];
			Do[temp[[i]]*=f[[i]]/Apply[Plus,temp[[i]]],
					{i,4}];
			temp]