|
14 | 14 |
|
15 | 15 | Given: Three positive integers k, m, and n, representing a population containing k+m+n organisms: k individuals are homozygous dominant for a factor, m are heterozygous, and n are homozygous recessive. |
16 | 16 |
|
17 | | - Return: The probability that two randomly selected mating organisms will produce an individual possessing a dominant allele (and thus displaying the dominant phenotype). Assume that any two organisms can mate. |
| 17 | + Return: The probability that two randomly selected mating organisms will produce an individual possessing a dominant allele (and thus displaying the dominant phenotype). Assume that any two organisms can mate. |
| 18 | + |
| 19 | +There are two main ways we can solve this problem: deriving an algorithm or simulation. |
| 20 | + |
| 21 | +### Deriving an Algorithm |
| 22 | + |
| 23 | +Using the information above, we can derive an algorithm using the variables k, m, and n that will calculate the probability of a progeny possessing a dominant allele. We could either calculate the probability of a progeny having a dominant allele, but in this case, it is easier to calculate the likelihood of a progeny having a recessive allele. This is a relatively rarer event, and the calculation will be straightforward. We just have to subtract this probability from 1 to get the overall likelihood of having a progeny with a dominant trait. |
| 24 | + |
| 25 | +To demonstrate how to derive this algorithm, we can use H and h to signify dominant and recessive alleles. |
| 26 | + |
| 27 | +Out of all the possible combinations, we will only get a progeny with a recessive trait in three situations: Hh x Hh, Hh x hh, and hh x hh. For all of these situations, we must calculate the probability of these mating combinations occuring (based on k, m, and n), as well as the probability of these events leading to a progeny with a recessive trait. |
| 28 | + |
| 29 | +To calculate this, we must the probability of picking the first mating pair and then the second mating pair. |
| 30 | + |
| 31 | +For the combination Hh x Hh, this is $\frac{m}{(k+m+n)}$ multiplied by $\frac{(m-1)}{(k+m+n-1)}$. Selecting the second Hh individual is equal to the number of Hh individuals left after 1 was already picked (m-1) divided by the total individuals left in the population (k+m+n-1). |
| 32 | + |
| 33 | +A similar calculation is performed for the rest of the combinations. However, it is important to note that the probability of selecting Hh x hh as a mating pair is $\frac{2*m*n}{(k+m+n)(k+m+n-1)}$, as there are two ways to choose this combination. Hh x hh can be selected, as well as hh x Hh. Order matters! |
| 34 | + |
| 35 | +| Probability of combination occuring | Hh x Hh | Hh x hh | hh x hh | |
| 36 | +| --- |---|---|---| |
| 37 | +| | $\frac{m(m-1)}{(k+m+n)(k+m+n-1)}$ | $\frac{2*m*n}{(k+m+n)(k+m+n-1)}$| $\frac{n(n-1)}{(k+m+n)(k+m+n-1)}$| |
| 38 | + |
| 39 | + |
| 40 | + |
| 41 | +The probability of these combinations leading to a recessive trait can be calculated using Punnet Squares. |
| 42 | + |
| 43 | +| Probability of recessive trait | Hh x Hh | Hh x hh | hh x hh | |
| 44 | +| --- |---|---|---| |
| 45 | +| | 0.25 | 0.50 | 1 | |
| 46 | + |
| 47 | +Now, we just have to sum the multiply the probability of each combination occuring by the probability of this combination leading to a recessive trait. This leads to the following formula: |
| 48 | + |
| 49 | +Pr(recessive trait) = |
| 50 | +$\frac{m(m-1)}{(k+m+n)(k+m+n-1)}$ x 0.25 + $\frac{m*n}{(k+m+n)(k+m+n-1)}$ + $\frac{n(n-1)}{(k+m+n)(k+m+n-1)}$ |
| 51 | + |
| 52 | +Therefore, the probability of selecting an individual with a *dominant* trait is 1 - Pr(recessive trait). |
| 53 | + |
| 54 | +Now that we've derived this formula, let's turn this into code! |
| 55 | + |
| 56 | +```julia |
| 57 | +function mendel(k,m,n) |
| 58 | + |
| 59 | + total = (k+m+n)*(k+m+n-1) |
| 60 | + return 1-( |
| 61 | + (0.25*m*(m-1))/total + |
| 62 | + m*n/total + |
| 63 | + n*(n-1)/total) |
| 64 | +end |
| 65 | + |
| 66 | +mendel(2,2,2) |
| 67 | +``` |
| 68 | + |
| 69 | + |
| 70 | + |
| 71 | +### Simulation Method |
0 commit comments