| name | evolution |
| description | Study of biological evolution, natural selection, speciation, and phylogenetics |
| category | biology |
| keywords | ["evolution","natural selection","phylogenetics","speciation","adaptation","evolutionary biology"] |
Evolution
What I Do
Evolutionary biology studies the origin and descent of species, natural selection, and the processes that generate biological diversity. I cover natural selection, genetic drift, gene flow, mutation, speciation, phylogenetics, and evolutionary genetics. I help analyze phylogenetic relationships, calculate selection pressures, and understand adaptation.
When to Use Me
- Building and interpreting phylogenetic trees
- Calculating natural selection and dN/dS ratios
- Understanding mechanisms of speciation
- Analyzing population genetic variation
- Studying adaptive evolution and convergence
- Dating evolutionary events (molecular clocks)
- Understanding coevolution and host-pathogen dynamics
Core Concepts
- Natural Selection: Directional, stabilizing, disruptive selection
- Genetic Drift: Founder effect, bottleneck, random sampling
- Gene Flow: Migration, admixture, population structure
- Mutation: Source of genetic variation, mutation rates
- Speciation: Allopatric, sympatric, parapatric mechanisms
- Phylogenetics: Clades, monophyly, parsimony, likelihood methods
- Molecular Evolution: dN/dS, positive selection, purifying selection
- Adaptive Radiation: Ecological opportunity, character displacement
- Coevolution: Predator-prey, host-parasite, mutualistic arms races
- Molecular Clock: Mutation rate calibration, divergence dating
Code Examples
import numpy as np
from typing import List, Dict, Tuple
from collections import Counter
class NaturalSelection:
def __init__(self, species: str):
self.species = species
def calculate_fitness(self, phenotype_value: float,
optimum: float,
omega: float) -> float:
return np.exp(-0.5 * ((phenotype_value - optimum) / omega)**2)
def directional_selection_gradient(self, mean_phenotype: float,
optimum: float,
heritability: float,
selection_strength: float) -> float:
return heritability * selection_strength * (optimum - mean_phenotype)
def calculate_response_to_selection(self, s: float,
h2: float) -> float:
R = s * h2
return R
def equilibrium_allele_frequency(self, s: ,
h: ) -> :
s / (s + h * s)
() -> :
selection_coefficient == :
initial_freq
s = selection_coefficient
N = population_size
( - np.exp(- * s * N * initial_freq)) / \
( - np.exp(- * s * N))
:
():
.alignment_file = alignment_file
() -> :
mismatches = ( a, b (seq1, seq2) a != b)
mismatches / (seq1)
() -> :
K = - * np.log( - *P - Q) - * np.log( - *Q)
P = transitions / sites
Q = transversions / sites
K
() -> :
clusters = {i: [i] i ((distances))}
current_distances = distances.copy()
tree = {}
(clusters) > :
min_pair = (current_distances.keys(),
key= x: current_distances[x])
cluster1, cluster2 = min_pair
distance = current_distances[min_pair]
new_cluster =
tree[new_cluster] = {
: [cluster1, cluster2],
: distance /
}
clusters[new_cluster] = clusters[cluster1] + clusters[cluster2]
clusters[cluster1]
clusters[cluster2]
tree
() -> :
d / ( * mutation_rate)
() -> :
lr = * (alt_likelihood - null_likelihood)
df =
p_value = - stats.chi2.cdf(lr, df)
{: lr, : p_value}
:
():
.gene_name = gene_name
() -> :
dn / ds ds > ()
() -> :
codon_table = {
: , : , : , : ,
: , : , : , : ,
: , : , : , : ,
: , : , : , : ,
: , : , : , : ,
: , : , : , : ,
: , : , : , : ,
: , : , : , : ,
: , : , : , : ,
: , : , : , : ,
: , : , : , : ,
: , : , : , : ,
: , : , : , : ,
: , : , : , : ,
: , : , : , : ,
: , : , : , :
}
syn_sites =
i (, (sequence), ):
codon = sequence[i:i+]
(codon) == :
syn_sites += codon_table.get(codon, )
syn_sites
() -> :
omega > :
omega < :
selection = NaturalSelection()
fitness = selection.calculate_fitness(, optimum=, omega=)
()
phylo = Phylogenetics()
dist = phylo.calculate_pairwise_distance(, )
()
Best Practices
- Use appropriate molecular clock calibration points
- Account for rate heterogeneity among sites and lineages
- Validate phylogenetic methods with known relationships
- Consider substitution model complexity vs. data support
- Use proper outgroups for root placement
- Apply bootstrap resampling for clade support
- Consider population structure in evolutionary analysis
- Distinguish between orthologs and paralogs in gene trees
- Use multiple methods to test for selection
- Consider fossil evidence for divergence dating