Variation exists within all populations of organisms. This occurs partly because random mutations cause changes in the genome of an individual organism, and these mutations can be passed to offspring. Throughout the individuals' lives, their genomes interact with their environments to cause variations in traits. Individuals with certain variants of the traits may survive and reproduce more than individuals with other variants. Therefore the population evolves. The idea of natural selection predates the understanding of genetics. We now have a much better idea of the biology underlying heritability, which is the basis of natural selection.

Genotype and phenotype
Natural selection acts on an organism's phenotype, or physical characteristics. Phenotype is determined by an organism's genetic make-up (genotype) and the environment in which the organism lives. Often, natural selection acts on specific traits of an individual, and the terms phenotype and genotype are used narrowly to indicate these specific traits.
When different organisms in a population possess different versions of a gene for a certain trait, each of these versions is known as an allele. It is this genetic variation that underlies phenotypic traits. Some traits are governed by only a single gene, but most traits are influenced by the interactions of many genes. A variation in one of the many genes that contributes to a trait may have only a small effect on the phenotype; together, these genes can produce a continuum of possible phenotypic values.

Directionality of selection
When some component of a trait is heritable, selection will alter the frequencies of the different alleles, or variants of the gene that produces the variants of the trait. Selection can be divided into three classes, on the basis of its effect on allele frequencies.

Directional selection occurs when a certain allele has a greater fitness than others, resulting in an increase of its frequency. This process can continue until the allele is fixed and the entire population shares the fitter phenotype.

Far more common is stabilizing selection (which is commonly confused with purifying selection), which lowers the frequency of alleles that have a deleterious effect on the phenotype - that is, produce organisms of lower fitness. This process can continue until the allele is eliminated from the population. Purifying selection results in functional genetic features, such as protein-coding genes or regulatory sequences, being conserved over time due to selective pressure against deleterious variants.

Finally, a number of forms of balancing selection exist, which do not result in fixation, but maintain an allele at intermediate frequencies in a population. This can occur in diploid species (that is, those that have two pairs of chromosomes) when heterozygote individuals, who have different alleles on each chromosome at a single genetic locus, have a higher fitness than homozygote individuals that have two of the same alleles. This is called heterozygote advantage or overdominance, of which the best-known example is the malarial resistance observed in heterozygous humans who carry only one copy of the gene for sickle cell anemia. Maintenance of allelic variation can also occur through disruptive or diversifying selection, which favors genotypes that depart from the average in either direction (that is, the opposite of overdominance), and can result in a bimodal distribution of trait values. Finally, balancing selection can occur through frequency-dependent selection, where the fitness of one particular phenotype depends on the distribution of other phenotypes in the population.

Selection and genetic variation
A portion of all genetic variation is functionally neutral in that it produces no phenotypic effect or significant difference in fitness; the hypothesis that this variation accounts for a large fraction of observed genetic diversity is known as the neutral theory of molecular evolution and was originated by Motoo Kimura. When genetic variation does not result in differences in fitness, selection cannot directly affect the frequency of such variation. As a result, the genetic variation at those sites will be higher than at sites where variation does influence fitness. However, after a period with no new mutation, the genetic variation at these sites will be eliminated due to genetic drift.

Mutation selection balance
Natural selection results in the reduction of genetic variation through the elimination of maladapted individuals and consequently of the mutations that caused the maladaptation. At the same time, new mutations occur, resulting in a mutation-selection balance. The exact outcome of the two processes depends both on the rate at which new mutations occur and on the strength of the natural selection, which is a function of how unfavorable the mutation proves to be.

Genetic linkage
Genetic linkage occurs when the loci of two alleles are linked, or in close proximity to each other on the chromosome. During the formation of gametes, recombination of the genetic material results in reshuffling of the alleles. However, the chance that such a reshuffle occurs between two alleles depends on the distance between those alleles; the closer the alleles are to each other, the less likely it is that such a reshuffle will occur. Consequently, when selection targets one allele, this automatically results in selection of the other allele as well; through this mechanism, selection can have a strong influence on patterns of variation in the genome.

Selective sweeps occur when an allele becomes more common in a population as a result of positive selection. As the prevalence of one allele increases, linked alleles can also become more common, whether they are neutral or even slightly deleterious. This is called genetic hitchhiking. A strong selective sweep results in a region of the genome where the positively selected haplotype (the allele and its neighbors) are in essence the only ones that exist in the population.

Whether a selective sweep has occurred or not can be investigated by measuring linkage disequilibrium, or whether a given haplotype is overrepresented in the population. Normally, genetic recombination results in a reshuffling of the different alleles within a haplotype, and none of the haplotypes will dominate the population. However, during a selective sweep, selection for a specific allele will also result in selection of neighboring alleles. Therefore, the presence of a block of strong linkage disequilibrium might indicate that there has been a 'recent' selective sweep near the center of the block, and this can be used to identify sites recently under selection.

About Author / Additional Info: