# Solving Hardy Weinberg problems

I really fail to understand Hardy-Weinberg equilibrium and can't find an easy enough source of information.

Can you help me to understand Hardy-Weinberg equilibrium?

My goal is to be able to solve the following kind of problem

In a population with two alleles for a certain locus, B and b, the allele frequency of B is 0.7. What is the frequency of heterozygotes if the population is in Hardy-Weinberg equilibrium?

• Homework questions are off-topic, so I rephrased your question to make it more general and ask for a tutorial rather than asking for the answer to a specific question. Feel free to roll back if you don't like the edit but the post will likely be closed if you do – Remi.b Apr 9 '17 at 15:28
• Do you want a method to solve the questions or you want to understand the mechanism? – YAHB Apr 9 '17 at 15:39
• That's perfectly fine with me! – Thomas Apr 9 '17 at 19:52
• The one thing about Hardy-Weinberg Equilibrium you should understand; this is the null-hypothesis for evolution. It's important not when it's correct, but when and how it's incorrect for a population. Deviations from HW are how populations genetics are measured. As such, it's a simple mathematical model for the random distribution of alleles. – Artem Apr 12 '17 at 19:09

Here is a tutorial to perfectly understand Hardy-Weinberg Rule! If you feel like you just need a brief reminder, you can skip the text until the section In short... and try out the exercises just to check your understanding.

# Terms you should know a priori

I will not define the following terms, so make sure you understand them

# What is the Hardy-Weinberg rule?

Hardy-Weinberg rule (HWr) describes a relationship between allele frequency and genotype frequencies. I will present the maths later.

# Alleles and Genotypes frequency

Let's assume we have a bi-allelic (two alleles) locus. The possible alleles are called A and B.

Notation for genotype frequencies

Note that I will use a slightly unusual notation on purpose.

Let $$f_{AA}$$ be the frequency of the homozygous individual caring the allele A on both haplotype (both chromosome). Let $$f_{BB}$$ be the frequency other homozygote. Let $$F_{AB}$$ be the frequency of heterozygote which inherited the A allele from the mother and the B allele from the father. Finally, $$F_{BA}$$ is the frequency of heterozygotes which inherited the B allele from the mother and the A allele from the father.

Most of the time people write $$f_{AB}$$ (or similar notation) to designate all heterozygotes irrespective of whether the A allele comes from the father or the mother. In this answer, I make the difference of which parent gave which allele. I will instead note $$f_{het}$$ the frequency of all heterozygotes. Therefore $$f_{het} = f_{AB} + f_{BA}$$. Similarly, I will note $$f_{hom}$$ the frequency of all homozygotes. Therefore, $$f_{hom} = f_{AA} + f_{BB}$$.

Notation for allele frequency

Unlike the above, I will use a class notation here.

Let the frequency of the A allele be $$p$$ and the frequency of the B allele be $$q$$.

All genotype frequencies must sum to 1

Of course, if you add up the frequency of all types of individuals in a population, you should reach 1 (or 100% if you prefer). Per consequence,

$$f_{AA} + f_{AB} + f_{BA} + f_{BB} = f_{hom} + f_{het} = 1$$

is our first important result.

Problem 1

There is 20% of heterozygote in the population, what fraction of the population is homozygote?

$$f_{hom}=0.8$$ (or $$f_{hom}=$$80%)

Problem 2

There are 10% of AA individuals and 15% of BB individuals in the population, what fraction of individuals are heterozygotes

$$f_{het} = 0.75$$ (or $$f_{het} =$$ 75% )

All allele frequencies must sum to one

The same is true for the allele frequency, they must sum to one. This is even easier than before. Using the above notation it means:

$$p + q = 1$$

You will note that an obvious consequence of this result is that $$1-p = q$$ is also true. This is the second important result.

Problem 3

The frequency of alleles which are the A allele is 0.3. What is the frequency of the B allele?

$$q = 0.7$$

# Hardy-Weinberg equilibrium

HWr assumptions

HWr makes a number of assumptions that I will not detail them here. Please have a look at the post Assumptions of Hardy-Weinberg rule for more information.

HWr exercice without explanations

Here are exercises that one may consider they come too early in my explanations. Don't worry too much if you can't solve them but please take the time to try solving them. Please do not try to apply known formulas about HWr, only use your logic and the above formulas (allele frequencies must sum to 1 and genotype frequencies must sum to 1)

Problem 4

In a population, one observes that 20% of the population is homozygote for the A allele and that there are no heterozygous individuals at all. What is the frequency of the A allele?

$$f_{A} = 0.2$$

Below is a drawing of the population (assuming N=20 individuals) to help understand the answer.

AA | AA | AA | AA | BB | BB | BB | BB | BB | BB | BB | BB | BB | BB | BB | BB | BB | BB | BB | BB

Problem 5

In a population, one observes that all B alleles are present in heterozygote only. The frequency of heterozygotes is 0.1. What is the frequency of the A allele?

$$f_{A} = 0.95$$

The hard part here is to first calculate $$f_{B} = 0.05$$. Let's draw the population (assuming only N=20 individuals) and that will likely help you out.

AA | AB | AA | AA | AA | AA | AA | AA | AA | AA | AA | AB | AA | AA | AA | AA | AA | AA | AA | AA

HWr formula

As said above, HWr describes a relationship between allele frequency and genotype frequency

Without much explanations, here are these relationships

$$f_{AA} = p^2$$

$$f_{AB} = pq$$

$$f_{BA} = pq$$

$$f_{BB} = q^2$$

Therefore,

$$f_{hom} = p^2 + q^2$$

$$f_{het} = 2pq$$

To build your intuition, you should try to consider for yourself extreme cases where one allele is fixed (fixed=reached a frequency of one). For example, what are the expected genotype frequencies when

• $$p=1$$ and $$q=0$$?
• $$p=q=0.5$$?
• $$p=0$$ and $$q=1$$?

How HWr is often expressed

Mixing up the idea of the above relationships and the fact that all genotype frequencies must sum up to one, one can also write

$$p^2 + 2pq + q^2 = 1$$

As by definition $$q = 1-p$$, it is also common to replace write

$$p^2 + 2p(1-p) + (1-p)^2 = 1$$

Why do these relationships make sense?

Problem 6

Imagine you are drawing alleles in a population of alleles like you would draw cards from a deck of cards! You draw a single allele. If the frequency of A allele is $$p$$, what is the probability of drawing an A allele?

$$p$$

Similarly, the probability of picking a B allele is $$q=1-p$$.

Problem 7

Ok, now. Assuming that the fact that you already drew an allele does not change the allele frequency in the population (because the population is very large), what is the probability of drawing two A alleles in a row?

It is $$p$$ for the first draw and $$p$$ for the second draw. The overall probability is therefore $$p \cdot p = p^2$$

Here we go! You just solved why $$f_{AA} = p^2$$. You can apply the exact same logic to find out $$f_{BB} = q^2$$.

Now the probability to first draw a A allele and then a B allele is $$pq$$. Therefore, $$f_{AB} = pq$$. The probability to first draw a B allele and then a A allele is $$qp=pq$$ as well. Therefore, $$f_{BA} = pq$$.

Exercise

Problem 8

In a population with two alleles for a certain locus, A and B, the allele frequency of A is 0.7. What is the frequency of heterozygotes if the population is in Hardy-Weinberg equilibrium?

(You will note I renamed the alleles to match my above notation)

Try to solve this problem yourself now!

It is a given that $$p=0.7$$. The question is what does $$f_{het}$$ equals to?

Let's start by calculating $$q$$.

$$q=1-p=0.3$$.

Then, let's calculate the the genotype frequencies.

$$f_{AA} = p^2 = 0.49$$.
$$f_{BB} = q^2 = 0.09$$.
$$f_{het} = 2pq = 0.42$$.

Here we go! We've got the answer. Let's make sure the answer makes sense by summing up the genotype frequencies to ensure we get 1.

$$f_{hom} = f_{AA} + f_{BB} = 0.58$$
$$f_{hom} + f_{het} = 0.42 + 0.58 = 1$$

All good!

Problem 9

At a bi-allelic locus, the allele A is dominant over the allele a. The phenotype associated with the dominant allele is present in 10% of the individuals of the population. What is the frequency of the allele A?

The genotypes coding for the phenotype associated with the dominant alleles are AA and Aa. Therefore, $$f_{AA} + f_{Aa} = 0.1$$ and therefore, $$f_{aa} = 0.9$$. The frequency of the allele a is $$p = \sqrt{f_{aa}} = \sqrt{0.9} ≈ 0.95$$. To conclude the frequency of the allele A is $$q = 1 - p = 1 - \sqrt{0.9} ≈ 0.05$$

Problem 10

You will find a HW problem involving selection at this post.

Problem 11

You will find a HW problem involving a population of triploids individuals at this post.

Problem 12

You will find a HW problem for sex-linked loci at this post

# In short...

Here is a summary for a bi-allelic locus

Allele freqs sum up to one

$$p + q = 1$$

Genotype freqs sum up to one

$$f_{AA} + f_{AB} + f_{BA} + f_{BB} = f_{hom} + f_{het} = 1$$

You will note that most often when people write $$f_{AB}$$, they just mean $$f_{het}$$ and therefore don't make the distinction between $$f_{AB}$$ and $$f_{BA}$$.

Hardy-Weinberg rule

Note that Hardy-Weinberg rule holds only under a number of assumptions (such as random mating, panmictic population, no selection, ...) that I have not detailed here (see Assumptions of Hardy-Weinberg rule for more information).

$$f_{AA} = p^2$$

$$f_{AB} = pq$$

$$f_{BA} = pq$$

$$f_{BB} = q^2$$

Therefore,

$$f_{hom} = p^2 + q^2$$

$$f_{het} = 2pq$$

Putting all together

The whole thing put together is often expressed as

$$p^2 + 2p(1-p) + (1-p)^2 = 1$$

• Has anyone else explained it so nicely ever on this site? Awesome answer, +1! I read once that if allele frequency changes over time, it means evolution is taking place. And thats where this rule is used. Would you explain it a bit too? :) – another 'Homo sapien' Apr 12 '17 at 18:01
• @another'Homosapien'  if allele frequency changes over time, it means evolution is taking place yes, this is true by definition of evolution.  And thats where this rule is used. I don't fully understand what you mean. Actually in the assumptions for HWr to hold perfectly (and not just as an approximation), it is required that there is no selection and no drift (infinite population size) which pretty much mean no evolution. I think it would be worth to make a post on the assumptions underlying HWr. I'll be happy to start (but not tonight!). – Remi.b Apr 13 '17 at 1:35
• I meant this is the application of this rule: making population studies at different times to measure change in allele frequency. I think I can ask a question about that...surely not tonight! But I'll ping you there :) – another 'Homo sapien' Apr 13 '17 at 6:07
• I see for the first time someone used spoil-protection (a great feature indeed ! ) out of puzzling.se :O – Always Confused Apr 13 '17 at 14:55
• Yes, it is a relative frequency, also called proportion, very often (always in population genetics) just called frequency. It indeed has nothing to do with the definition of frequency as used in wave physics. – Remi.b Apr 24 '17 at 20:44

Lets say there are 2 alleles. One of them is represented by B and other by b. Both will have some frequency at a specific time in a population. Now, frequency is number of that allele divided by total alleles. So, if frequency of B is, say X, the frequency of b is Y=(1-x). It would be because whatever alleles are not B are, for sure, b.

That gives us our first equation,

X+Y=1

Now, let us consider all the genotypes. There is BB, Bb and bb. Now, considering each of the 2 homologous chromosomes, there can be any 2 randomly selected alleles in a population. Here we are selecting an organism randomly. There can be no bias in selecting. This is one of the essential features of HW equilibrium. There is no selection pressure.

So, for B to be on the first chromosome (of the 2), the probability is x. So is for the second chromosome. So to have B on both, that is BB genotype, the probability is X x X = X^2.

Similarly for bb genotype, it would be Y^2.

Now, for heterozygous, there are 2 possible scenarios, bB and Bb.

For case 1: probability would be X x Y

For case 2: probability would be X x Y

So in both cases it is same, that is XY. So total would be 2XY.

So, lets add all the genotypes. The total should be 1 if all are included.

So,

X^2 + 2XY + Y^2 = 1

That gives our second equation. Now, whatever you have to find, you must find either X or Y first.

When you find one, you will get other by subtraction. When you have that, you can find whatever frequency is asked by putting values in second equation.

Allele B's frequency is 0.7. So allele b will be 0.3 (1-0.7).

By this you get the value of B (frequency of dominant allele) and b (frequency of recessive allele).

Now we put the values in the formula B^2+2Bb+b^2=1.

Here 2Bb is the frequency of heterozygous. So 2x0.7x0.3=0.42.

• @cell0 watch the use of articles here. This does need editing, but be careful. Because "frequency" is a term in a mathematical expression, the use of articles is not going to be standard. – De Novo Mar 19 '19 at 2:04