Allele frequency
Allele frequency is a measure of the relative frequency of an allele at a genetic locus in a population. Usually it is expressed as a proportion or a percentage. In population genetics, allele frequencies are used to depict the amount of genetic diversity at the individual, population, or species level.
Given the following:
- a particular locus on a chromosome and the gene occupying that locus
- a population of individuals carrying n loci in each of their somatic cells (e.g. two loci in the cells of diploid species, which contain two sets of chromosomes)
- variants or alleles of the gene exist,
then the allele frequency is the fraction or percentage of times that a given allele is present at a locus within the population.
For example, if the frequency of an allele is 20% in a given population, then among population members, one in five chromosomes will carry that allele. Four out of five will be occupied by other variant(s) of the gene. Note that for diploid genes the fraction of individuals that carry this allele may be nearly two in five. If the allele distributes randomly, then the binomial theorem will apply: 32% of the population will be heterozygous for the allele (i.e. carry one copy of that allele and one copy of another in each somatic cell) and 4% will be homozygous (carrying two copies of the allele).  Together, this means that 36% of diploid individuals would be expected to carry an allele that has a frequency of 20%. However, alleles distribute randomly only under certain assumptions, including the absence of selection.  When these conditions apply, a population is said to be in Hardy-Weinberg equilibrium.
The frequencies of all the alleles of a given gene often are graphed together as an allele frequency distribution histogram, or allele frequency spectrum.   Population genetics studies the different "forces" that might lead to changes in the distribution and frequencies of alleles -- in other words, to evolution. Besides selection, these forces include genetic drift, mutation and migration.

# Calculation of allele frequencies from genotype frequencies
If f(AA), f(Aa), and f(aa) are the frequencies of the three genotypes at a locus with two alleles, then the frequency p of the A-allele and the frequency q of the a-allele are obtained by counting alleles. Because each homozygote AA consists only of A-alleles, and because half of the alleles of each heterozygote Aa are A-alleles, the total frequency p of A-alleles in the population is calculated as
Similarly, the frequency q of the a allele is given by
It would be expected that p and q sum to 1, since they are the frequencies of the only two alleles present.  Indeed they do:
and from this we get:
If there are more than two different allelic forms, the frequency for each allele is simply the frequency of its homozygote plus half the sum of the frequencies for all the heterozygotes in which it appears.
Allele frequency can always be calculated from genotype frequency, whereas the reverse requires that the Hardy-Weinberg conditions of random mating apply.  This is partly due to the three genotype frequencies and the two allele frequencies.  It is easier to reduce from three to two.

# An example population
Consider a population of ten individuals and a given locus with two possible alleles, A and a. Suppose that the genotypes of the individuals are as follows:
Then the allele frequencies of allele A and allele a are:
so if an individual is chosen at random there is a 70% chance it will carry that allele
and there is a 30% chance that an individual chosen at random will have the a-allele and everyone poops and carly likes cameron D

# The effect of mutation
Let u be the mutation rate from allele A to some other allele a ( the probability that a copy of gene A will become a during the DNA replication preceding meiosis).  If p_t is the frequency of the A allele in generation t, if q_t=1-p_t is the frequency of the a allele in generation t, and if there are no other causes of gene frequency change (no natural selection, for example), then the change in allele frequency in one generation is
\Delta p_t-p_{t-1}=\left(p_{t-1}-\acute{u}p_{t-1}\right)-p_{t-1}=-\acute{u}p_{t-1}
where p_{t-1} is the frequency of the preceding generation. This tells us that the frequency of A decreases (and the frequency of a increases) by an amount that is proportional to the mutation rate u and to the proportion p of all the genes that are still available to mutate. Thus \Delta p gets smaller as the frequency of p itself decreases, because there are fewer and fewer A alleles to mutate into a alleles.  We can make an approximation that, after n generations of mutation,
p_n=p_0e^{-n\acute{u}}