๐ŸŒณ Phylogenetic Trees
HOME

๐Ÿง  Phylogenetic Fundamentals

๐ŸŽฏ What is a Phylogenetic Tree?

A phylogenetic tree is a branching diagram showing the evolutionary relationships among biological entities (species, genes, populations). It consists of nodes (common ancestors), branches (evolutionary paths), and tips/leaves (extant taxa). Branch lengths represent evolutionary time or genetic change. Phylogenetics is the foundation of evolutionary biology, taxonomy, and molecular epidemiology.

Why Phylogenetics Matters

Evolution: Relationships. Taxonomy: Classification. Epidemiology: Outbreaks. Conservation: Diversity. Drug: Targets. Origins: SARS-CoV-2. Clinical: Pathogens.

๐Ÿ“Œ Tree of Life๐Ÿ“Œ Evolution๐Ÿ“Œ Common Ancestry๐Ÿ“Œ Branch Lengths
# Phylogenetic Trees โ€” the big picture # Reconstructing evolutionary history. # CONCEPTUAL OVERVIEW print(""" === Phylogenetic Trees === What it is: - Branching diagram - Evolutionary relationships - Nodes, branches, tips - Branch lengths Why it's powerful: - Common ancestry - Evolutionary time - Molecular clock - Classification Types of trees: - Cladogram: Branching only - Phylogram: Branch lengths = change - Chronogram: Branch lengths = time - Dendrogram: Any branching - Rooted vs unrooted Data types: - DNA sequences - Protein sequences - Morphology - SNPs - Gene presence/absence Methods: - Distance: NJ, UPGMA - Character: MP, ML - Bayesian: MrBayes, BEAST - Coalescent: SNAPP, BPP Workflow: 1. Sequence collection 2. MSA (MAFFT) 3. Trimming (Gblocks) 4. Model selection (ModelFinder) 5. Tree inference (IQ-TREE) 6. Support (bootstrap) 7. Visualization (FigTree) Applications: - Species trees - Gene trees - Viral epidemiology - Cancer evolution - Conservation - Drug discovery """) # WHY IT MATTERS print("=== Why It Matters ===") print(""" Biological questions: - How are species related? - When did lineages diverge? - What is the origin of an outbreak? - How do genes evolve? - What is the tree of life? Phylogenetics answers: - Tree topology - Branch lengths - Divergence times - Ancestral states - Rates of evolution """) # HISTORICAL CONTEXT print("=== Historical Context ===") print(""" 1859: Darwin's tree of life 1950s: Numerical taxonomy 1960s: Molecular phylogenetics 1967: Molecular clock (Zuckerkandl & Pauling) 1970s: Maximum parsimony 1981: Neighbor-Joining (Saitou & Nei) 1981: Maximum likelihood (Felsenstein) 1990s: Bayesian inference 2000s: RAxML, MrBayes 2010s: IQ-TREE, BEAST 2020s: SARS-CoV-2 phylogenetics """) # CHALLENGES print("=== Challenges ===") print(""" 1. ALIGNMENT - MSA quality - Trimming - Homology 2. MODEL SELECTION - Substitution model - Rate heterogeneity - Among-site variation 3. COMPUTATIONAL - Large datasets - Tree space - Time 4. SUPPORT - Bootstrap - Posterior - Confidence 5. INTERPRETATION - Gene vs species tree - Incomplete lineage sorting - Horizontal transfer """)

๐ŸŽฏ Why Phylogenetics Matters

๐ŸŽฏ The Value of Phylogenetics

Phylogenetics is the framework for understanding evolution, classifying biodiversity, and tracking pathogens.

Biological Insights

Evolution: History. Taxonomy: Classification. Epidemiology: Outbreaks. Conservation: Diversity. Genes: Families. Disease: Origins.

๐ŸŽฏ Evolution๐ŸŽฏ Taxonomy๐ŸŽฏ Epidemiology๐ŸŽฏ Conservation
# Why Phylogenetics Matters print("=== 1. Evolutionary Relationships ===") print(""" Evolution: - Common ancestry - Divergence times - Rates of evolution Examples: - Human evolution - Darwin's finches - Whale evolution - Plant evolution Output: - Species tree - Divergence times - Ancestral states """) print("\n=== 2. Taxonomy & Classification ===") print(""" Taxonomy: - Classification - Nomenclature - Species delimitation Examples: - Kingdom to species - DNA barcoding - Cryptic species Tools: - MEGA - BEAST - PTP (species delimitation) """) print("\n=== 3. Molecular Epidemiology ===") print(""" Epidemiology: - Outbreak tracking - Transmission - Origin Examples: - SARS-CoV-2 - Ebola - Influenza - HIV Workflow: 1. Sequence 2. Align 3. Tree 4. Phylodynamics 5. Report Tools: - Nextstrain - BEAST - IQ-TREE """) print("\n=== 4. Conservation ===") print(""" Conservation: - Genetic diversity - Evolutionarily Significant Units (ESUs) - Management units Examples: - Endangered species - Population structure - Connectivity Tools: - BEAST - DIYABC - Structure """) print("\n=== 5. Gene Family Evolution ===") print(""" Gene families: - Duplication - Loss - Orthologs vs paralogs Examples: - Olfactory receptors - Immune genes - Hox genes Tools: - OrthoFinder - CAFE - IQ-TREE """) print("\n=== 6. Cancer Evolution ===") print(""" Cancer: - Clonal evolution - Driver mutations - Metastasis Examples: - Leukemia - Breast cancer - Lung cancer Tools: - BEAST - PyClone - SciClone """) print("\n=== 7. Viral Phylodynamics ===") print(""" Phylodynamics: - Viral spread - Selection - Reassortment Examples: - Influenza - HIV - SARS-CoV-2 - Dengue Tools: - BEAST - Nextstrain - TreeTime """) print("\n=== 8. Drug Discovery ===") print(""" Drug discovery: - Target identification - Conservation - Resistance Examples: - Antibiotics - Antivirals - Cancer drugs Workflow: 1. Tree 2. Conserved targets 3. Drug design 4. Resistance """)

๐Ÿ“– Tree Terminology

๐ŸŽฏ Understanding Trees

Phylogenetic trees have their own vocabulary. Understanding the terminology is essential.

Terminology

Node: Ancestor. Branch: Path. Tip: Extant. Root: Common ancestor. Clade: Group. Topology: Shape. Monophyletic: All descendants.

๐Ÿ“– Node๐Ÿ“– Branch๐Ÿ“– Tip๐Ÿ“– Clade
# Tree Terminology print("=== Basic Terms ===") print(""" Node: - Branching point - Common ancestor - Internal (ancestral) or external (extant) Branch (edge): - Line connecting nodes - Length = evolutionary change or time Tip (leaf): - Terminal node - Extant taxon - Species, gene, individual Root: - Common ancestor of all - Oldest node - Rooted vs unrooted Clade: - Ancestor + all descendants - Monophyletic group Topology: - Branching pattern - Shape of tree """) print("\n=== Tree Types ===") print(""" 1. Cladogram: - Branching only - No branch lengths - Shows relationships 2. Phylogram: - Branch lengths = change - Substitutions per site - Evolutionary distance 3. Chronogram: - Branch lengths = time - Time-calibrated - Divergence times 4. Dendrogram: - Any branching diagram - Generic term 5. Ultrametric: - All tips at same time - Molecular clock - Time tree """) print("\n=== Rooting ===") print(""" Rooted: - Direction of evolution - Common ancestor - Outgroup required Unrooted: - No direction - Relationships only - Topology only Outgroup: - Distantly related - Used for rooting - Should be monophyletic Rooting methods: - Outgroup - Midpoint - Molecular clock """) print("\n=== Group Types ===") print(""" Monophyletic: - Ancestor + all descendants - Clade - Valid group Paraphyletic: - Ancestor + some descendants - Excludes some - Invalid group Polyphyletic: - Multiple ancestors - Convergent - Invalid group Example: - Mammals: Monophyletic - Reptiles (excluding birds): Paraphyletic - Warm-blooded: Polyphyletic """) print("\n=== Branch Length ===") print(""" Branch length: - Substitutions per site - Evolutionary distance - Time (chronogram) Scale: - 0.1 = 10% change - 1.0 = 100% change - Time: MYA Long branch: - Fast evolution - Saturation - Long-branch attraction Short branch: - Slow evolution - Conserved """) print("\n=== Newick Format ===") print(""" Newick: - Text format - Parentheses - Commas - Semicolon Example: ((A:0.1,B:0.2):0.3,(C:0.15,D:0.25):0.2); Meaning: A,B sister C,D sister (A,B) and (C,D) sister Branch lengths after : Nexus: - Extended format - Blocks - Metadata """) print("\n=== Best Practices ===") print(""" 1. Use correct terminology 2. Root trees properly 3. Check monophyly 4. Interpret branch lengths 5. Check support values 6. Consider gene vs species trees 7. Report parameters """)

๐Ÿ“ Distance Methods

๐ŸŽฏ Fast Tree Building

Distance methods compute a pairwise distance matrix and build a tree from it. Fast but discards character information.

Distance

UPGMA: Clock-like. NJ: Standard. Distance: Matrix. Correction: Multiple hits. Fast: Large datasets. Initial: For ML.

๐Ÿ“ UPGMA๐Ÿ“ NJ๐Ÿ“ Distance matrix๐Ÿ“ Fast
# Distance Methods print("=== Distance Matrix ===") print(""" Distance: - Pairwise differences - Substitutions per site - Correction for multiple hits Models: - p-distance: Raw differences - Jukes-Cantor (JC69): Equal rates - Kimura 2-parameter (K2P): Transitions/transversions - HKY: Base frequencies + ts/tv - GTR: Most general Example: Seq A: ACGTACGT Seq B: ACGTTCGT p-distance: 1/8 = 0.125 JC69: -3/4 * ln(1 - 4/3 * 0.125) = 0.135 """) print("\n=== UPGMA ===") print(""" UPGMA (Unweighted Pair Group Method with Arithmetic mean): - Assumes molecular clock - Sequential clustering - Ultrametric tree Algorithm: 1. Distance matrix 2. Find closest pair 3. Merge 4. Update distances (average) 5. Repeat Pros: - Simple - Fast - Ultrametric Cons: - Assumes clock - Not for rate variation - Rarely appropriate Tools: - MEGA - PHYLIP """) print("\n=== Neighbor-Joining (NJ) ===") print(""" Neighbor-Joining (Saitou & Nei, 1987): - Most popular distance method - No clock assumption - Fast - Good for large datasets Algorithm: 1. Distance matrix 2. Compute Q matrix 3. Find pair with min Q 4. Merge 5. Update distances 6. Repeat Q matrix: Q(i,j) = (n-2)d(i,j) - ฮฃd(i,k) - ฮฃd(j,k) Pros: - Fast - No clock - Good accuracy - Standard for initial trees Cons: - Distance-based - Loses character info - Not statistically optimal Tools: - MEGA - PHYLIP - SplitsTree """) print("\n=== Distance Correction ===") print(""" Why correct? - Multiple hits - Saturation - Underestimate distance Models: - p-distance: No correction - JC69: Equal rates - K2P: Transitions/transversions - HKY: Base freq + ts/tv - GTR: General Example (saturation): p-distance = 0.75 JC69 = infinity โ†’ Saturated """) print("\n=== When to Use Distance ===") print(""" Use distance: โœ“ Large datasets โœ“ Quick initial tree โœ“ Exploratory โœ“ Many sequences (> 1000) โœ“ Closely related Avoid: โœ— Rate variation โœ— Divergent sequences โœ— Statistical inference โœ— Publication-quality Recommendation: โ†’ NJ for initial tree โ†’ ML for final analysis """) print("\n=== Tools ===") print(""" 1. MEGA - GUI - NJ, UPGMA - Easy 2. PHYLIP - CLI - Classic - Many methods 3. SplitsTree - Networks - NJ - Visualization 4. RapidNJ - Fast NJ - Large datasets """) print("\n=== Best Practices ===") print(""" 1. Use corrected distances 2. Check saturation 3. Use NJ for initial tree 4. Use ML for final 5. Bootstrap support 6. Check tree topology 7. Report model """)

๐Ÿงฌ Character Methods

๐ŸŽฏ Using the Data Directly

Character methods use the actual sequence characters (A, C, G, T) and evaluate trees based on an evolutionary model. More accurate but slower.

Character

MP: Minimum changes. ML: Maximum likelihood. Model: Substitution. Score: Likelihood. Search: Heuristic. Accurate: Statistical.

๐Ÿงฌ Parsimony๐Ÿงฌ Maximum Likelihood๐Ÿงฌ Substitution model๐Ÿงฌ Accurate
# Character Methods print("=== Maximum Parsimony (MP) ===") print(""" Parsimony: - Minimum number of changes - No explicit model - Simple Algorithm: 1. Score tree 2. Count changes (Fitch) 3. Find tree with min changes 4. Search tree space Pros: - Simple - No model - Fast for small data Cons: - No statistical model - Long-branch attraction - Not optimal - Slow for large data Tools: - PAUP* - TNT - MEGA """) print("\n=== Maximum Likelihood (ML) ===") print(""" Maximum Likelihood (Felsenstein, 1981): - Statistical - Explicit model - Standard Algorithm: 1. Choose model 2. Compute likelihood 3. Search tree space 4. Find ML tree Likelihood: L = P(data | tree, model) lnL = log likelihood Steps: 1. Model selection (ModelFinder) 2. Tree search 3. Branch length optimization 4. Bootstrap Pros: - Statistical - Explicit model - Accurate - Handles rate variation Cons: - Slow - Computationally intensive - Model choice critical Tools: - IQ-TREE - RAxML - PhyML - MEGA """) print("\n=== ML Workflow ===") print(""" 1. ALIGNMENT - MSA (MAFFT) - Trim (Gblocks) 2. MODEL SELECTION - ModelFinder - jModelTest - Modeltest-NG - AIC/BIC 3. TREE INFERENCE - IQ-TREE - RAxML - PhyML 4. SUPPORT - Bootstrap (1000) - SH-aLRT - aBayes 5. VISUALIZATION - FigTree - iTOL """) print("\n=== Model Selection ===") print(""" Substitution models: - JC69: Equal - K80: ts/tv - F81: Base freq - HKY85: Base + ts/tv - GTR: General Rate heterogeneity: - +G: Gamma - +I: Invariant - +I+G: Both ModelFinder: iqtree -s alignment.fa -m MFP -B 1000 Output: Best model: GTR+F+I+G4 BIC: 12345.67 """) print("\n=== Tree Search ===") print(""" Search algorithms: - NNI: Nearest neighbor interchange - SPR: Subtree pruning and regrafting - TBR: Tree bisection and reconnection Heuristics: - Starting tree (NJ) - Stepwise addition - Random addition - Local optimization IQ-TREE: iqtree -s alignment.fa -m MFP -B 1000 -T 8 RAxML: raxmlHPC -s alignment.fa -m GTRGAMMA -p 12345 -b 12345 -# 1000 """) print("\n=== Advantages & Disadvantages ===") print(""" ADVANTAGES: โœ“ Statistical โœ“ Explicit model โœ“ Accurate โœ“ Rate variation โœ“ Branch lengths DISADVANTAGES: โœ— Slow โœ— Model dependence โœ— Computational cost โœ— Long-branch attraction """) print("\n=== Best Practices ===") print(""" 1. Good MSA 2. Trim alignment 3. Model selection 4. Multiple starting trees 5. Bootstrap 1000+ 6. Check convergence 7. Compare with NJ 8. Report model """)

๐ŸŽฒ Bayesian Inference

๐ŸŽฏ Posterior Probabilities

Bayesian inference estimates the posterior distribution of trees using MCMC. It provides posterior probabilities and handles complex models.

Bayesian

Prior: Before data. Likelihood: Data. Posterior: After data. MCMC: Sampling. PP: Posterior probability. MrBayes: Standard.

๐ŸŽฒ Prior๐ŸŽฒ Posterior๐ŸŽฒ MCMC๐ŸŽฒ MrBayes
# Bayesian Inference print("=== Bayes' Theorem ===") print(""" Bayes: P(tree | data) = P(data | tree) * P(tree) / P(data) Where: P(tree | data): Posterior P(data | tree): Likelihood P(tree): Prior P(data): Marginal likelihood Goal: - Sample from posterior - Estimate tree distribution """) print("\n=== MCMC ===") print(""" MCMC (Markov Chain Monte Carlo): - Sample tree space - Propose new trees - Accept/reject - Converge to posterior Steps: 1. Start tree 2. Propose change 3. Compute likelihood 4. Accept/reject 5. Repeat Chains: - Multiple chains - Heated chains - Swap - Convergence (ESS, PSRF) """) print("\n=== MrBayes ===") print(""" MrBayes: - Most popular - MCMC - Many models - Standard Nexus input: #NEXUS begin data; dimensions ntax=10 nchar=1000; format datatype=dna; matrix taxon1 ACGT... taxon2 ACGT... ; end; begin mrbayes; lset nst=6 rates=gamma; mcmc ngen=1000000 samplefreq=1000; sump burnin=250; sumt burnin=250; end; Command: mb input.nexus Output: input.nexus.con.tre input.nexus.p input.nexus.t """) print("\n=== BEAST ===") print(""" BEAST: - Bayesian - Time-calibrated - Coalescent - Phylodynamics Input: - XML (BEAUti) - Alignment - Calibration - Model Output: - MCC tree - Divergence times - Skyline plot Tools: - BEAUti - Tracer - TreeAnnotator - FigTree """) print("\n=== Convergence ===") print(""" Check: - ESS (Effective Sample Size) - PSRF (Potential Scale Reduction Factor) - Trace plots - Autocorrelation Tracer: - ESS > 200 - PSRF ~ 1.0 - Trace: stationary - Burn-in: first 25% If not converged: - Run longer - More chains - Better proposals - Check model """) print("\n=== Posterior Probability ===") print(""" PP: - Frequency in posterior - PP > 0.95: Strong - PP > 0.99: Very strong - PP vs bootstrap Interpretation: - PP is not p-value - PP can be inflated - Compare with ML bootstrap """) print("\n=== Advantages & Disadvantages ===") print(""" ADVANTAGES: โœ“ Posterior probabilities โœ“ Complex models โœ“ Time-calibrated โœ“ Uncertainty โœ“ Prior knowledge DISADVANTAGES: โœ— Slow โœ— Computationally intensive โœ— Prior sensitivity โœ— Convergence issues โœ— Model complexity """) print("\n=== Best Practices ===") print(""" 1. Multiple runs (4+) 2. Long enough (ESS > 200) 3. Check convergence 4. Appropriate burn-in 5. Prior sensitivity 6. Compare with ML 7. Report parameters 8. Tracer for diagnostics """)

โš™๏ธ Evolutionary Models

๐ŸŽฏ Modeling Evolution

Evolutionary models describe how sequences change over time. Choosing the right model is critical for accurate phylogenies.

Models

JC69: Simplest. K80: ts/tv. HKY: Base freq. GTR: General. +G: Gamma. +I: Invariant. ModelFinder: Selection.

โš™๏ธ JC69โš™๏ธ HKYโš™๏ธ GTRโš™๏ธ +G
# Evolutionary Models print("=== DNA Substitution Models ===") print(""" JC69 (Jukes-Cantor, 1969): - Equal base frequencies - Equal rates - Simplest K80 (Kimura 2-parameter, 1980): - Equal base frequencies - Different ts/tv F81 (Felsenstein, 1981): - Different base frequencies - Equal rates HKY85 (Hasegawa-Kishino-Yano): - Different base frequencies - Different ts/tv TN93 (Tamura-Nei): - Different base frequencies - Different ts/tv rates GTR (General Time Reversible): - Different base frequencies - Different rates - Most general """) print("\n=== Model Parameters ===") print(""" Base frequencies: - ฯ€A, ฯ€C, ฯ€G, ฯ€T - Equal or estimated Substitution rates: - a, b, c, d, e, f - 6 rates (GTR) Rate heterogeneity: - +G: Gamma distribution - +I: Invariant sites - +I+G: Both Alpha (ฮฑ): - Shape parameter - ฮฑ < 1: High variation - ฮฑ > 1: Low variation """) print("\n=== Protein Models ===") print(""" Amino acid models: - Poisson: Equal rates - JTT: Jones-Taylor-Thornton - WAG: Whelan & Goldman - LG: Le & Gascuel - Dayhoff - Blosum62 - mtMAM: Mitochondrial Model selection: - ModelFinder - ProtTest """) print("\n=== Model Selection ===") print(""" ModelFinder (IQ-TREE): iqtree -s alignment.fa -m MFP Output: Best model: GTR+F+I+G4 BIC: 12345.67 AIC: 12340.12 Criteria: - AIC: Akaike Information Criterion - BIC: Bayesian Information Criterion - AICc: Corrected AIC jModelTest: - Java - GUI - Many models Modeltest-NG: - Fast - Many models """) print("\n=== Partition Models ===") print(""" Partitioning: - Different genes - Different codons - Different regions Example: Gene 1: GTR+G Gene 2: HKY+I Gene 3: GTR+I+G Tools: - PartitionFinder - IQ-TREE (-p) - RAxML (-q) Command: iqtree -s alignment.fa -p partition.txt -m MFP """) print("\n=== Best Practices ===") print(""" 1. Always select model 2. Use ModelFinder 3. Consider partitioning 4. Check parameter estimates 5. Compare models (AIC/BIC) 6. Report model 7. Consider rate variation 8. Check for saturation """)

๐Ÿ“Š Branch Support

๐ŸŽฏ How Confident Are We?

Branch support measures confidence in tree branches. Bootstrap and posterior probabilities are the standard methods.

Support

Bootstrap: Resampling. PP: Posterior. SH-aLRT: Fast. aBayes: Approximate. Threshold: 70% / 0.95. Interpret: Confidence.

๐Ÿ“Š Bootstrap๐Ÿ“Š Posterior๐Ÿ“Š SH-aLRT๐Ÿ“Š Threshold
# Branch Support print("=== Bootstrap ===") print(""" Bootstrap: - Resampling columns - With replacement - 1000 replicates - Count branch frequency Steps: 1. Original alignment 2. Resample columns (n) 3. Build tree 4. Repeat 1000x 5. Count branch Interpretation: - > 95%: Strong - 70-95%: Moderate - 50-70%: Weak - < 50%: Not supported Command (IQ-TREE): iqtree -s alignment.fa -m MFP -B 1000 -T 8 Command (RAxML): raxmlHPC -s alignment.fa -m GTRGAMMA -p 12345 -b 12345 -# 1000 """) print("\n=== Posterior Probability ===") print(""" PP: - Bayesian - Frequency in posterior - MrBayes, BEAST Interpretation: - > 0.95: Strong - 0.90-0.95: Moderate - < 0.90: Weak PP vs Bootstrap: - PP often higher - Bootstrap more conservative - Both should be reported """) print("\n=== SH-aLRT ===") print(""" SH-aLRT (Shimodaira-Hasegawa approximate likelihood ratio test): - Fast - IQ-TREE - Alternative to bootstrap Command: iqtree -s alignment.fa -m MFP -alrt 1000 -B 1000 Interpretation: - > 80%: Strong - 70-80%: Moderate - < 70%: Weak """) print("\n=== aBayes ===") print(""" aBayes: - Approximate Bayes - Fast - PhyML, IQ-TREE Command: iqtree -s alignment.fa -m MFP -abayes Interpretation: - > 0.95: Strong - 0.90-0.95: Moderate """) print("\n=== Ultrafast Bootstrap ===") print(""" UFBoot: - IQ-TREE - Fast - 1000 replicates - Recommended Command: iqtree -s alignment.fa -m MFP -B 1000 -T 8 Interpretation: - > 95%: Strong - 70-95%: Moderate - < 70%: Weak """) print("\n=== Support Comparison ===") print(f"{'Method':<20} {'Threshold':<20} {'Speed':<15} {'Tool':<15}") print("-" * 70) print(f"{'Bootstrap':<20} {'70-95%':<20} {'Slow':<15} {'RAxML':<15}") print(f"{'UFBoot':<20} {'95%':<20} {'Fast':<15} {'IQ-TREE':<15}") print(f"{'SH-aLRT':<20} {'80%':<20} {'Fast':<15} {'IQ-TREE':<15}") print(f"{'aBayes':<20} {'0.95':<20} {'Fast':<15} {'PhyML':<15}") print(f"{'Posterior':<20} {'0.95':<20} {'Slow':<15} {'MrBayes':<15}") print("\n=== Best Practices ===") print(""" 1. Use 1000 bootstrap 2. Use UFBoot for speed 3. Report support values 4. Use multiple methods 5. Check support distribution 6. Collapse low support 7. Don't overinterpret 8. Consider gene trees """)

๐Ÿ› ๏ธ Tools (MEGA, RAxML, MrBayes)

๐ŸŽฏ Ready-to-Use Phylogenetic Tools

Many high-quality phylogenetic tools exist. Each has strengths and is suited to different analyses.

Tools

MEGA: GUI. RAxML: ML. IQ-TREE: ML. MrBayes: Bayesian. BEAST: Time. PhyML: ML.

๐Ÿ› ๏ธ MEGA๐Ÿ› ๏ธ RAxML๐Ÿ› ๏ธ IQ-TREE๐Ÿ› ๏ธ MrBayes
# Tools print("=== MEGA ===") print(""" MEGA (Molecular Evolutionary Genetics Analysis): - GUI - Windows/Mac/Linux - Free - Comprehensive Features: - MSA editor - Model selection - NJ, MP, ML - Bootstrap - Tree visualization - Divergence times Workflow: 1. Import sequences 2. Align (ClustalW) 3. Model test 4. Build tree 5. Bootstrap 6. Export Web: www.megasoftware.net """) print("\n=== IQ-TREE ===") print(""" IQ-TREE: - Fast ML - ModelFinder - UFBoot - Partition models - Standard Command (basic): iqtree -s alignment.fa -m MFP -B 1000 -T 8 Command (partitioned): iqtree -s alignment.fa -p partition.txt -m MFP -B 1000 Options: -m MFP: ModelFinder -B 1000: UFBoot -alrt 1000: SH-aLRT -T 8: Threads -pre: Prefix Output: alignment.fa.treefile alignment.fa.iqtree alignment.fa.log """) print("\n=== RAxML ===") print(""" RAxML: - ML - Fast - Standard - Many models Command: raxmlHPC-PTHREADS-SSE3 \ -T 8 \ -s alignment.fa \ -n result \ -m GTRGAMMA \ -p 12345 \ -x 12345 \ -# 1000 \ -f a Options: -m: Model -p: Parsimony seed -x: Bootstrap seed -#: Replicates -f a: ML + bootstrap Output: RAxML_bestTree.result RAxML_bipartitions.result """) print("\n=== RAxML-NG ===") print(""" RAxML-NG: - Next generation - Faster - Better Command: raxml-ng \ --all \ --msa alignment.fa \ --model GTR+G \ --tree pars{10},rand{10} \ --bs-trees 1000 \ --threads 8 Output: alignment.fa.raxml.bestTree alignment.fa.raxml.support """) print("\n=== MrBayes ===") print(""" MrBayes: - Bayesian - MCMC - Standard Nexus input: #NEXUS begin data; dimensions ntax=10 nchar=1000; format datatype=dna; matrix taxon1 ACGT... ; end; begin mrbayes; lset nst=6 rates=gamma; mcmc ngen=1000000 samplefreq=1000; sump burnin=250; sumt burnin=250; end; Command: mb input.nexus Output: input.nexus.con.tre input.nexus.p """) print("\n=== BEAST ===") print(""" BEAST: - Bayesian - Time-calibrated - Phylodynamics Workflow: 1. BEAUti (XML) 2. BEAST (MCMC) 3. Tracer (convergence) 4. TreeAnnotator (MCC) 5. FigTree (visualize) Command: beast input.xml Output: input.xml.trees input.xml.log """) print("\n=== PhyML ===") print(""" PhyML: - ML - Fast - GUI + CLI Command: phyml -i alignment.phy -d nt -m GTR -a e -b 1000 Options: -d: Data type -m: Model -a: Gamma -b: Bootstrap """) print("\n=== Other Tools ===") print(""" 1. FastTree - Very fast - Large datasets 2. PAUP* - Classic - Many methods 3. TNT - Parsimony - Fast 4. SplitsTree - Networks - Visualization 5. ModelFinder - Model selection 6. PartitionFinder - Partitioning 7. TreeTime - Time trees - Phylodynamics 8. Nextstrain - Real-time - Viral """) print("\n=== Installation ===") print(""" # Conda conda install -c bioconda iqtree raxml raxml-ng mrbayes beast phyml # Docker docker pull quay.io/biocontainers/iqtree # From source git clone https://github.com/iqtree/iqtree2 """)

โฐ Time Trees

๐ŸŽฏ When Did Lineages Diverge?

Time trees (chronograms) estimate divergence times using molecular clocks and calibration points.

Dating

Clock: Rate. Calibration: Fossil. BEAST: Standard. Relaxed: Rate variation. MCMC: Posterior. HPD: Intervals.

โฐ Molecular clockโฐ Calibrationโฐ BEASTโฐ HPD
# Time Trees print("=== Molecular Clock ===") print(""" Molecular clock: - Rate of substitution - Constant over time - Zuckerkandl & Pauling (1962) Strict clock: - Constant rate - Simple - Rarely true Relaxed clock: - Rate variation - Log-normal - Exponential - Better Calibration: - Fossil - Geological - Molecular - Tip dates """) print("\n=== BEAST Workflow ===") print(""" 1. BEAUti: - Import alignment - Set model - Set clock - Set priors - Set calibration - Generate XML 2. BEAST: - Run MCMC - Log parameters - Log trees 3. Tracer: - Check convergence - ESS > 200 - Burn-in 4. TreeAnnotator: - MCC tree - Mean heights - HPD intervals 5. FigTree: - Visualize - Node bars - Labels """) print("\n=== Calibration ===") print(""" Fossil calibration: - Oldest fossil - Minimum age - Log-normal prior Example: - Mammal split: 100 MYA - Primate split: 65 MYA - Human-chimp: 6 MYA Tips: - Multiple calibrations - Secondary calibrations - Geological events """) print("\n=== Relaxed Clock ===") print(""" Uncorrelated log-normal: - Rate independent - Log-normal distribution - Standard Uncorrelated exponential: - Rate independent - Exponential distribution Autocorrelated: - Rate correlated - Brownian motion Selection: - Compare models - Path sampling - Stepping stone """) print("\n=== Divergence Times ===") print(""" Output: - Node ages - HPD intervals (95%) - Posterior distribution Example: Human-Chimp: 6.5 MYA (5.5-7.5) Human-Gorilla: 8.5 MYA (7.5-9.5) Human-Orangutan: 15 MYA (13-17) Interpretation: - Mean age - HPD interval - Uncertainty """) print("\n=== Phylodynamics ===") print(""" Phylodynamics: - Viral spread - Population size - Selection Skyline plot: - Population size over time - Bayesian skyline Tools: - BEAST - Tracer - TreeTime - Nextstrain Example: - SARS-CoV-2 - HIV - Influenza """) print("\n=== Best Practices ===") print(""" 1. Multiple calibrations 2. Appropriate priors 3. Relaxed clock 4. Long MCMC 5. Check convergence 6. Report HPD 7. Sensitivity analysis 8. Compare models """)

๐Ÿ Python Integration

๐ŸŽฏ Phylogenetics from Python

You can run phylogenetic tools from Python using subprocess and analyze trees with Biopython, ete3, and DendroPy.

Python

subprocess: Run CLI. Biopython: Trees. ete3: Analysis. DendroPy: Trees. Toytree: Visualization. Pipeline: Automate.

๐Ÿ subprocess๐Ÿ Biopython๐Ÿ ete3๐Ÿ DendroPy
# Python Integration print("=== Run IQ-TREE ===") print(""" import subprocess def run_iqtree(alignment, model="MFP", bootstrap=1000, threads=8, prefix="iqtree"): \"\"\"Run IQ-TREE.\"\"\" cmd = [ 'iqtree', '-s', alignment, '-m', model, '-B', str(bootstrap), '-T', str(threads), '-pre', prefix ] result = subprocess.run(cmd, capture_output=True, text=True) if result.returncode != 0: raise RuntimeError(f"IQ-TREE failed: {result.stderr}") return f"{prefix}.treefile" # Use # tree = run_iqtree("alignment.fa") """) print("\n=== Run RAxML ===") print(""" def run_raxml(alignment, model="GTRGAMMA", bootstrap=1000, threads=8): \"\"\"Run RAxML.\"\"\" cmd = [ 'raxmlHPC-PTHREADS-SSE3', '-T', str(threads), '-s', alignment, '-n', 'result', '-m', model, '-p', '12345', '-x', '12345', '-#', str(bootstrap), '-f', 'a' ] result = subprocess.run(cmd, capture_output=True, text=True) if result.returncode != 0: raise RuntimeError(f"RAxML failed: {result.stderr}") return "RAxML_bipartitions.result" # Use # tree = run_raxml("alignment.fa") """) print("\n=== Parse Trees with Biopython ===") print(""" from Bio import Phylo import io def parse_tree(tree_file): \"\"\"Parse Newick tree.\"\"\" tree = Phylo.read(tree_file, "newick") print(f"Tree: {tree}") print(f"Terminals: {len(tree.get_terminals())}") print(f"Non-terminals: {len(tree.get_nonterminals())}") # Branch lengths for clade in tree.find_clades(): if clade.branch_length: print(f"{clade.name}: {clade.branch_length:.4f}") return tree # Use # tree = parse_tree("tree.nwk") """) print("\n=== Analyze Tree ===") print(""" from Bio import Phylo def analyze_tree(tree_file): \"\"\"Analyze tree structure.\"\"\" tree = Phylo.read(tree_file, "newick") # Total tree length total = sum(c.branch_length for c in tree.find_clades() if c.branch_length) print(f"Total tree length: {total:.4f}") # Find clades for clade in tree.find_clades(): if clade.is_terminal(): print(f"Tip: {clade.name}") # Distance between taxa dist = tree.distance("taxon1", "taxon2") print(f"Distance: {dist:.4f}") # Common ancestor mrca = tree.common_ancestor("taxon1", "taxon2") print(f"MRCA: {mrca}") return tree # Use # tree = analyze_tree("tree.nwk") """) print("\n=== ete3 ===") print(""" from ete3 import Tree def analyze_ete(tree_file): \"\"\"Analyze tree with ete3.\"\"\" t = Tree(tree_file) # Basic info print(f"Leaves: {len(t.get_leaves())}") print(f"Nodes: {len(t.get_descendants())}") # Root print(f"Root: {t.get_tree_root()}") # Traverse for node in t.traverse(): print(f"Node: {node.name}, dist: {node.dist}") # Distance print(f"Distance: {t.get_distance('taxon1', 'taxon2')}") # Prune t.prune(["taxon1", "taxon2", "taxon3"]) # Write t.write(outfile="pruned.nwk") return t # Use # t = analyze_ete("tree.nwk") """) print("\n=== DendroPy ===") print(""" import dendropy def analyze_dendropy(tree_file): \"\"\"Analyze tree with DendroPy.\"\"\" tree = dendropy.Tree.get( path=tree_file, schema="newick" ) # Basic info print(f"Taxa: {len(tree.taxon_namespace)}") print(f"Nodes: {len(tree.nodes())}") # Traverse for node in tree.preorder_node_iter(): print(f"Node: {node.taxon}, dist: {node.edge_length}") # Distance dist = tree.phylogenetic_distance( tree.find_node_with_taxon_label("taxon1"), tree.find_node_with_taxon_label("taxon2") ) print(f"Distance: {dist}") return tree # Use # tree = analyze_dendropy("tree.nwk") """) print("\n=== Compare Trees ===") print(""" from Bio import Phylo from Bio.Phylo.TreeConstruction import DistanceCalculator def compare_trees(tree1_file, tree2_file): \"\"\"Compare two trees.\"\"\" tree1 = Phylo.read(tree1_file, "newick") tree2 = Phylo.read(tree2_file, "newick") # Robinson-Foulds distance from Bio.Phylo.Consensus import _BitString # Get clades clades1 = set() for clade in tree1.find_clades(): if not clade.is_terminal(): clades1.add(frozenset(c.name for c in clade.get_terminals())) clades2 = set() for clade in tree2.find_clades(): if not clade.is_terminal(): clades2.add(frozenset(c.name for c in clade.get_terminals())) # RF distance rf = len(clades1.symmetric_difference(clades2)) print(f"RF distance: {rf}") return rf # Use # rf = compare_trees("tree1.nwk", "tree2.nwk") """) print("\n=== Complete Pipeline ===") print(""" import subprocess from Bio import AlignIO, Phylo def phylo_pipeline(sequences, output_dir="phylo_output", threads=8): \"\"\"Complete phylogenetic pipeline.\"\"\" import os os.makedirs(output_dir, exist_ok=True) # 1. Align print("Aligning...") subprocess.run([ 'mafft', '--auto', sequences ], stdout=open(f'{output_dir}/aligned.fa', 'w'), check=True) # 2. Trim print("Trimming...") subprocess.run([ 'trimal', '-in', f'{output_dir}/aligned.fa', '-out', f'{output_dir}/trimmed.fa', '-automated1' ], check=True) # 3. Model selection + Tree print("Building tree...") tree_file = run_iqtree(f'{output_dir}/trimmed.fa', prefix=f'{output_dir}/tree') # 4. Parse tree = Phylo.read(tree_file, "newick") print(f"Tree: {len(tree.get_terminals())} taxa") return tree_file # Use # tree = phylo_pipeline("sequences.fa") """)

๐ŸŽจ Visualization

๐ŸŽฏ Seeing the Tree

Tree visualization is essential for interpretation and publication. FigTree, iTOL, and ggtree are the standard tools.

Visualization

FigTree: GUI. iTOL: Web. ggtree: R. Dendroscope: Networks. Toytree: Python. Evolview: Web.

๐ŸŽจ FigTree๐ŸŽจ iTOL๐ŸŽจ ggtree๐ŸŽจ Toytree
# Visualization print("=== FigTree ===") print(""" FigTree: - GUI - Free - Standard - Java Features: - Load Newick/Nexus - Root - Branch lengths - Support values - Node labels - Colors - Export PDF/SVG Workflow: 1. Open tree 2. Root (outgroup) 3. Adjust layout 4. Color clades 5. Export """) print("\n=== iTOL ===") print(""" iTOL (Interactive Tree Of Life): - Web - Free - Interactive - Publication Features: - Drag and drop - Annotations - Colors - Heatmaps - Metadata - Export Workflow: 1. Upload tree 2. Annotate 3. Customize 4. Export Web: itol.embl.de """) print("\n=== ggtree (R) ===") print(""" ggtree: - R package - ggplot2-based - Flexible - Publication R code: library(ggtree) library(treeio) # Load tree <- read.tree("tree.nwk") # Plot ggtree(tree) + geom_tiplab() + geom_nodelab() + theme_tree2() # Annotate ggtree(tree) + geom_tiplab() + geom_text2(aes(label=label), color="red") # Heatmap gheatmap(p, data, width=0.5) """) print("\n=== Toytree (Python) ===") print(""" toytree: - Python - Interactive - Publication Python code: import toytree # Load tree = toytree.tree("tree.nwk") # Plot tree.draw() # Customize tree.draw( tip_labels=True, node_labels=True, edge_widths=2, tip_labels_colors="blue" ) # Save tree.draw().save("tree.png") """) print("\n=== Dendroscope ===") print(""" Dendroscope: - Networks - Trees - Large datasets Features: - Interactive - Tanglegram - Networks - Export """) print("\n=== Evolview ===") print(""" Evolview: - Web - Free - Annotations Features: - Upload tree - Annotate - Colors - Heatmaps - Export Web: www.evolgenius.info/evolview """) print("\n=== Comparison ===") print(f"{'Tool':<20} {'Platform':<15} {'Best For':<25}") print("-" * 60) print(f"{'FigTree':<20} {'GUI':<15} {'Standard':<25}") print(f"{'iTOL':<20} {'Web':<15} {'Interactive':<25}") print(f"{'ggtree':<20} {'R':<15} {'Publication':<25}") print(f"{'Toytree':<20} {'Python':<15} {'Python users':<25}") print(f"{'Dendroscope':<20} {'GUI':<15} {'Networks':<25}") print(f"{'Evolview':<20} {'Web':<15} {'Annotations':<25}") print("\n=== Best Practices ===") print(""" 1. Root properly 2. Show support values 3. Use scale bar 4. Colorblind-friendly 5. High resolution 6. Vector format 7. Annotate metadata 8. Document parameters """)

โš–๏ธ Method Comparison

๐ŸŽฏ Which Method?

Choosing the right phylogenetic method depends on data size, desired accuracy, and research questions.

Comparison

NJ: Fast. MP: Simple. ML: Accurate. Bayesian: Posterior. Distance: Initial. Character: Final.

โš–๏ธ NJโš–๏ธ MPโš–๏ธ MLโš–๏ธ Bayesian
Method Type Speed Accuracy Best For
UPGMADistanceFastPoorClock-like data
Neighbor-JoiningDistanceFastGoodInitial tree, large data
Maximum ParsimonyCharacterMediumGoodMorphology, similar sequences
Maximum LikelihoodCharacterSlowExcellentStandard, publication
Bayesian (MrBayes)BayesianSlowExcellentPosterior probabilities
BEASTBayesianVery slowExcellentTime trees, phylodynamics
FastTreeML-likeVery fastGoodVery large datasets
IQ-TREEMLFastExcellentBest ML, model selection
RAxMLMLFastExcellentStandard ML
# Decision Guide print("=== Choose Method by Data Size ===") print(""" < 50 taxa: โ†’ ML (IQ-TREE) โ†’ Bayesian (MrBayes) โ†’ Best accuracy 50-500 taxa: โ†’ ML (IQ-TREE, RAxML) โ†’ Fast enough 500-5000 taxa: โ†’ FastTree โ†’ RAxML โ†’ NJ (initial) > 5000 taxa: โ†’ FastTree โ†’ Very fast โ†’ Large data Time-calibrated: โ†’ BEAST โ†’ TreeTime โ†’ MCMCtree """) print("\n=== Choose Method by Purpose ===") print(""" Initial tree: โ†’ NJ โ†’ Fast Publication: โ†’ ML (IQ-TREE) โ†’ Bayesian (MrBayes) Time tree: โ†’ BEAST โ†’ MCMCtree Phylodynamics: โ†’ BEAST โ†’ Nextstrain Species tree: โ†’ ASTRAL โ†’ SVDquartets โ†’ BPP Gene tree: โ†’ IQ-TREE โ†’ RAxML """) print("\n=== Speed Comparison ===") print(f"{'Method':<20} {'10 taxa':<15} {'100 taxa':<15} {'1000 taxa':<15}") print("-" * 65) print(f"{'NJ':<20} {'< 1s':<15} {'1s':<15} {'10s':<15}") print(f"{'MP':<20} {'1s':<15} {'1 min':<15} {'Hours':<15}") print(f"{'ML (IQ-TREE)':<20} {'10s':<15} {'10 min':<15} {'Hours':<15}") print(f"{'ML (RAxML)':<20} {'30s':<15} {'30 min':<15} {'Days':<15}") print(f"{'Bayesian':<20} {'1 min':<15} {'Hours':<15} {'Days':<15}") print(f"{'FastTree':<20} {'< 1s':<15} {'1s':<15} {'1 min':<15}") print("\n=== When to Use Which ===") print(""" USE NJ: โœ“ Initial tree โœ“ Large datasets โœ“ Quick look USE MP: โœ“ Morphology โœ“ Similar sequences โœ“ Teaching USE ML: โœ“ Publication โœ“ Accurate โœ“ Standard USE Bayesian: โœ“ Posterior probabilities โœ“ Complex models โœ“ Time trees USE BEAST: โœ“ Divergence times โœ“ Phylodynamics โœ“ Viral USE FastTree: โœ“ Very large datasets โœ“ Quick โœ“ Metagenomics """)

๐Ÿ’ผ Use Cases

๐ŸŽฏ Where Phylogenetics Is Used

Phylogenetics is used in virtually every area of biology: evolution, epidemiology, conservation, and more.

Use Cases

Evolution: Relationships. Epidemiology: Outbreaks. Conservation: Diversity. Taxonomy: Species. Genes: Families. Cancer: Clonal.

๐Ÿ’ผ Evolution๐Ÿ’ผ Epidemiology๐Ÿ’ผ Conservation๐Ÿ’ผ Taxonomy
# Use Cases print("=== 1. Species Phylogeny ===") print(""" Use case: - Evolutionary relationships - Classification - Divergence times Workflow: 1. Collect sequences 2. MSA (MAFFT) 3. Trim (Gblocks) 4. Model selection 5. Tree (IQ-TREE) 6. Dating (BEAST) 7. Visualize (FigTree) Examples: - Human evolution - Darwin's finches - Mammals - Plants Tools: - IQ-TREE - BEAST - FigTree """) print("\n=== 2. Viral Epidemiology ===") print(""" Use case: - Outbreak tracking - Transmission - Origin Workflow: 1. Sequence 2. Align 3. Tree 4. Phylodynamics 5. Report Examples: - SARS-CoV-2 - Ebola - Influenza - HIV Tools: - Nextstrain - BEAST - TreeTime - IQ-TREE """) print("\n=== 3. Conservation Genetics ===") print(""" Use case: - Genetic diversity - ESUs - Management Workflow: 1. Sample populations 2. Sequence 3. Tree 4. Diversity 5. Management Examples: - Endangered species - Population structure - Connectivity Tools: - BEAST - Structure - DIYABC """) print("\n=== 4. DNA Barcoding ===") print(""" Use case: - Species identification - Cryptic species - Biodiversity Workflow: 1. Sequence COI 2. Align 3. Tree 4. Identify 5. Barcode Examples: - Animals - Plants - Fungi - Microbes Tools: - MEGA - BOLD - IQ-TREE """) print("\n=== 5. Gene Family Evolution ===") print(""" Use case: - Gene duplication - Orthologs - Paralogs Workflow: 1. Identify genes 2. Align 3. Tree 4. Reconcile 5. Analyze Examples: - Olfactory receptors - Immune genes - Hox genes Tools: - OrthoFinder - IQ-TREE - CAFE """) print("\n=== 6. Cancer Evolution ===") print(""" Use case: - Clonal evolution - Driver mutations - Metastasis Workflow: 1. Sequence tumor 2. Variants 3. Tree 4. Clonal 5. Treatment Examples: - Leukemia - Breast cancer - Lung cancer Tools: - BEAST - PyClone - SciClone """) print("\n=== 7. Horizontal Gene Transfer ===") print(""" Use case: - HGT - Microbial evolution - Antibiotic resistance Workflow: 1. Sequence 2. Tree 3. Compare 4. HGT 5. Analyze Examples: - Antibiotic resistance - Pathogenicity islands - Symbiosis Tools: - IQ-TREE - RANGER-DTL - Notung """) print("\n=== 8. Drug Discovery ===") print(""" Use case: - Target identification - Conservation - Resistance Workflow: 1. Tree 2. Conserved targets 3. Drug design 4. Resistance Examples: - Antibiotics - Antivirals - Cancer drugs Tools: - IQ-TREE - MEGA """) print("\n=== Comparison ===") print(f"{'Use Case':<25} {'Tool':<20} {'Output':<20}") print("-" * 65) print(f"{'Species phylogeny':<25} {'IQ-TREE + BEAST':<20} {'Time tree':<20}") print(f"{'Viral epidemiology':<25} {'Nextstrain':<20} {'Spread':<20}") print(f"{'Conservation':<25} {'BEAST':<20} {'ESUs':<20}") print(f"{'DNA barcoding':<25} {'MEGA':<20} {'Species ID':<20}") print(f"{'Gene family':<25} {'OrthoFinder':<20} {'Orthologs':<20}") print(f"{'Cancer':<25} {'PyClone':<20} {'Clones':<20}") print(f"{'HGT':<25} {'RANGER-DTL':<20} {'Transfers':<20}") print(f"{'Drug discovery':<25} {'IQ-TREE':<20} {'Targets':<20}")

โ“ FAQ

๐ŸŽฏ Frequently Asked Questions

Answers to common questions about phylogenetic analysis.

What is a phylogenetic tree?

A phylogenetic tree is a branching diagram showing the evolutionary relationships among biological entities (species, genes, populations). It consists of nodes (common ancestors), branches (evolutionary paths), and tips/leaves (extant taxa). Branch lengths represent evolutionary time or genetic change.

What is the difference between distance-based and character-based methods?

Distance-based methods (NJ, UPGMA) first compute a pairwise distance matrix and then build a tree from it โ€” fast but discards character information. Character-based methods (MP, ML, Bayesian) use the actual sequence characters (A, C, G, T) and evaluate trees based on an evolutionary model โ€” slower but more accurate.

Which phylogenetic method should I use?

Use Neighbor-Joining (NJ) for a quick initial tree, Maximum Likelihood (ML) via IQ-TREE or RAxML for robust inference, and Bayesian inference via MrBayes or BEAST when you need posterior probabilities and time-calibrated trees. For large datasets, FastTree or RAxML-NG are excellent choices.

What is bootstrapping in phylogenetics?

Bootstrapping is a resampling technique used to assess confidence in tree branches. It involves creating many pseudo-replicate datasets by sampling columns with replacement, building a tree for each, and counting how often each branch appears. Bootstrap values > 70% indicate strong support.

What is the difference between a cladogram, phylogram, and chronogram?

A cladogram shows only branching order (no branch lengths). A phylogram has branch lengths proportional to genetic change (substitutions per site). A chronogram (time tree) has branch lengths proportional to time, calibrated using fossil or molecular clock information.

How do I choose the right substitution model?

Use ModelFinder (IQ-TREE), jModelTest, or Modeltest-NG to select the best model based on AIC/BIC. For DNA, start with GTR+F+I+G4; for protein, use LG or WAG. Always report the selected model and consider partitioning for multi-gene datasets.

What is the difference between gene trees and species trees?

A gene tree shows the evolutionary history of a single gene, which may differ from the species tree due to incomplete lineage sorting, gene duplication, or horizontal transfer. Use coalescent methods (ASTRAL, BPP) or concatenation (IQ-TREE) to estimate species trees from multiple genes.

What is a molecular clock?

A molecular clock assumes that substitutions accumulate at a roughly constant rate over time. Strict clocks assume a constant rate; relaxed clocks allow rate variation. Time trees are calibrated using fossil dates, geological events, or tip dates (for viruses). BEAST is the standard tool.

How do I root a phylogenetic tree?

Use an outgroup (a distantly related taxon) to root the tree, or use midpoint rooting if no outgroup is available. For time trees, rooting is determined by the molecular clock and calibration. Always check that the outgroup is monophyletic and not too divergent.

What is long-branch attraction?

Long-branch attraction (LBA) is an artifact where rapidly evolving lineages are incorrectly grouped together because they share many convergent changes. It affects parsimony and distance methods more than ML. Mitigate by using ML with appropriate models, adding taxa, or removing fast-evolving sites.

# Quick Reference print("=== Quick Answers ===") print(""" Q: What is a phylogenetic tree? A: Branching diagram of evolutionary relationships. Q: Best method? A: ML (IQ-TREE) for most, Bayesian for time. Q: Distance vs character? A: Distance fast; character accurate. Q: Bootstrap? A: Resampling for branch support. Q: Model selection? A: ModelFinder, jModelTest. Q: Gene vs species tree? A: Gene tree may differ; use coalescent. Q: Molecular clock? A: Constant rate; BEAST for time trees. Q: Rooting? A: Outgroup or midpoint. Q: Long-branch attraction? A: Fast lineages group incorrectly. Q: Visualization? A: FigTree, iTOL, ggtree. Q: Free tools? A: Yes โ€” all major tools are free. """)

๐Ÿš€ Future

๐ŸŽฏ Where Phylogenetics Is Going

The future is genome-scale, AI-augmented, real-time, coalescent, and integrative.

Future Directions

Phylogenomics: Whole genomes. AI: Deep learning. Real-time: Epidemiology. Coalescent: Species trees. Integration: Multi-omics. Networks: HGT.

๐Ÿš€ Phylogenomics๐Ÿš€ AI๐Ÿš€ Real-time๐Ÿš€ Coalescent
# Future of Phylogenetics print("=== 1. Phylogenomics ===") print(""" Trend: Whole genomes Current: - Few genes - Concatenation Phylogenomics: - Whole genomes - Thousands of genes - Coalescent methods Examples: - 10K genomes - Bird phylogeny - Mammal phylogeny Tools: - ASTRAL - IQ-TREE - RAxML-NG - PhyloBayes """) print("\n=== 2. AI-Augmented Phylogenetics ===") print(""" Trend: Deep learning Ideas: - Learned models - Neural networks - Transformer - Graph neural networks Examples: - PhyloNet - Deep learning for tree inference - CNN for model selection Future: - Learned representations - Faster - More accurate - Complex models """) print("\n=== 3. Real-Time Phylogenetics ===") print(""" Trend: Real-time Current: - Batch - Slow Real-time: - During outbreak - Continuous - Dashboard Examples: - Nextstrain - GISAID - COVID-19 Tools: - Nextstrain - TreeTime - BEAST """) print("\n=== 4. Coalescent Methods ===") print(""" Trend: Species trees Current: - Concatenation - Gene trees Coalescent: - Incomplete lineage sorting - Species tree - Multi-species coalescent Tools: - ASTRAL - BPP - SNAPP - StarBEAST """) print("\n=== 5. Phylogenetic Networks ===") print(""" Trend: Networks Current: - Trees - Bifurcating Networks: - Hybridization - HGT - Recombination - Polyploidy Tools: - SplitsTree - PhyloNet - Dendroscope - Network Future: - Reticulate evolution - Complex histories """) print("\n=== 6. Integration ===") print(""" Trend: Integrate everything Current: - Single data type - Separate analysis Future: - Multi-omics - Integration - Systems biology Examples: - Genomics + transcriptomics - Proteomics + phylogenetics - Metabolomics + evolution Tools: - BEAST - RevBayes - MrBayes """) # TIMELINE print("\n=== Timeline ===") print(""" Past: 1859: Darwin 1962: Molecular clock 1981: NJ, ML 1990s: Bayesian 2000s: RAxML 2010s: IQ-TREE, BEAST 2020: SARS-CoV-2 Present: 2025: Phylogenomics 2026: AI-augmented Future: 2030: Real-time? 2035: Networks? 2040: Predictive phylogenetics? """) print("\n=== Final Thoughts ===") print(""" Phylogenetics is: - Fundamental to evolution - Needed for epidemiology - Needed for conservation - Rapidly improving The future is: - Phylogenomics - AI-augmented - Real-time - Coalescent - Networks - Integrative "Nothing in biology makes sense except in the light of evolution." โ€” Theodosius Dobzhansky Keep exploring. Keep building. """)