#note Population Genetics A Concise Guide (5)

Page 14

Problem 1.3 Hardy-Weinberg frequencies in dioecious species may be investigated in an entirely different way. Let the genotype frequencies in females be x11, x12, and x22, and in males, y11, y12, and y22. Enumerate all nine possible matings (A1A1 female by A1A1 male, A1A1 female by A1A2 male, etc.) and calculate the frequencies of genotypes produced by each one as a function of the x\’s and y\’s. Sum these frequencies, weighted by the frequencies of the matings, to obtain the genotype frequencies in the second generation. Now let these genotypes mate at random to produce the third generation, If all goes well, a morass of symbols will collapse into the satisfying simplicity of the Hardy-Weinberg law.

Note:

FemaleMaleFrequencyA1A1A1A2A2A2
A1A1A1A1x11y11100
A1A1A1A2x11y121/21/20
A1A1A2A2x11y22010
A1A2A1A1x12y111/21/20
A1A2A1A2x12y121/41/21/4
A1A2A2A2x12y2201/21/2
A2A2A1A1x22y11010
A2A2A1A2x22y1201/21/2
A2A2A2A2x22y22001

Write a Java program to simulate the random mating to check the first 5 generations:

package de.yanzhou;

import java.util.Arrays;
import java.util.List;

public class RandomMating {

  public static void main(String[] args){

    List<Double> frequenciesInFemale = Arrays.asList(0.65, 0.25, 0.1); //A1A1, A1A2, A2A2
    List<Double> frequenciesInMale = Arrays.asList(0.15, 0.35, 0.5);//A1A1, A1A2, A2A2
    List<Double> r = calculate(frequenciesInFemale, frequenciesInMale);
    System.out.println("2. Generation : " + r.get(0) + " " + r.get(1) + " " +r.get(2));
    int i = 3;
    while(i<=5){
      r = calculate(r,r);
      System.out.println(i + ". Generation" + " : " + r.get(0) + " " + r.get(1) + " " +r.get(2));
      i++;
    }
  }
  private static List<Double> calculate(List<Double> l1, List<Double> l2){
    List<Double> r =
            l1.stream()
                    .flatMap(i -> l2.stream()
                            .map(j -> i * j)
                    ).toList();
    double frequencyOfA1A1 = 1*r.get(0) + 0.5*r.get(1) + 0.5*r.get(3) + 0.25*r.get(4);
    double frequencyOfA1A2 = 0.5*r.get(1) + 1*r.get(2) + 0.5*r.get(3) + 0.5*r.get(4) + 0.5*r.get(5) + 1*r.get(6) + 0.5*r.get(7);
    double frequencyOfA2A2 = 0.25*r.get(4) + 0.5*r.get(5) + 0.5*r.get(7) + 1*r.get(8);
    return Arrays.asList(frequencyOfA1A1, frequencyOfA1A2, frequencyOfA2A2);
  }
}

Output:

2. Generation : 0.25187499999999996 0.59625 0.151875
3. Generation : 0.30249999999999994 0.49499999999999994 0.20249999999999996
4. Generation : 0.3024999999999999 0.49499999999999983 0.20249999999999996
5. Generation : 0.30249999999999977 0.4949999999999997 0.20249999999999985

So it will in the third generation reach equilibrium.

By input:

List<Double> frequenciesInFemale = Arrays.asList(0.25, 0.5, 0.25); //A1A1, A1A2, A2A2
List<Double> frequenciesInMale = Arrays.asList(0.25, 0.5, 0.25);//A1A1, A1A2, A2A2

It can reach equilibrium in the second generation (frequency of A1A1 is equal to the frequency of A2A2). Output:

2. Generation : 0.25 0.5 0.25
3. Generation : 0.25 0.5 0.25
4. Generation : 0.25 0.5 0.25
5. Generation : 0.25 0.5 0.25

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top