1. Deconstruct the User's Request:
* Topic: Bayesian phylogenetics using BEAST (Bayesian Evolutionary Analysis Sampling Trees).
* Key Components:
* Priors (Selection, justification).
* Clock Models (Strict vs. Relaxed).
* Convergence Checks (ESS, Tracer, etc.).
* Reporting Standards (What to include in a paper).
* Goal: "Teach me." This implies a need for a structured, educational overview, moving from concepts to practical application, not just a list of definitions.
-
Determine the Scope and Structure:
- Since this is a complex topic, I should structure it logically, mimicking a workflow:
- Introduction: What is it and why use it?
- Part 1: The Priors (The "Bayesian" part): Explain what they are, common ones for trees, dates, and substitutions.
- Part 2: Clock Models (The "Time" part): Strict vs. Relaxed.
- Part 3: Running BEAST (Brief mention of the setup).
- Part 4: Convergence (The "Sanity Check"): ESS, Tracer, TreeAnnotator.
- Part 5: Reporting Standards (The "Publication" part): What reviewers look for.
-
Drafting Content - Section by Section:
-
Introduction: Briefly define Bayesian inference (P(H∣D)∝P(D∣H)×P(H)). It's about the probability of the hypothesis (tree) given the data.
-
Part 1: Priors:
- Concept: Pre-existing beliefs. "The price of admission" to the Bayesian party.
- Tree Prior (Coalescent vs. Birth-Death): This is crucial.
- Coalescent: Good for within-species (viruses, populations). Mention Skyline vs. Constant.
- Birth-Death: Good for between-species (macroevolution).
- Substitution Model: HKY, GTR (usually uninformative or flat).
- Molecular Clock Rate: Uniform vs. LogNormal. Explain why we usually don't know the rate exactly.
- Key advice: Don't use "default" blindly.
-
Part 2: Clock Models:
- Strict Clock: Rate is constant. Good for rapidly evolving viruses or low divergence.
- Relaxed Clock (Uncorrelated Lognormal - UCLD): Rates vary across branches. The standard for most modern analyses.
- Random Local Clock: Less common, but worth a footnote. Focus on UCLD as the go-to alternative to Strict.
-
Part 3: Convergence Checks (MCMC diagnostics):
- Concept: Did the chain mix well? Did it explore the parameter space?
- ESS (Effective Sample Size): The magic number (usually > 200).
- Tools: Tracer (visualizing distributions), LogCombiner (burn-in), TreeAnnotator (MCC tree).
- Visuals: Trace plots should look like "fuzzy caterpillars," not trends.
-
Part 4: Reporting Standards (Best Practices):
- This is often neglected. I should base this on current standards (like the Bayesian phylogenetics checklist papers).
- Model selection (how did you pick GTR?).
- Prior justification (why Skyline?).
- Run details (chain length, sampling frequency).
- ESS values (report the min).
- Software versions (BEAST v1.10 vs v2.x).
-
Refining and Polishing:
- Tone: Educational, authoritative but accessible. Use analogies where helpful (e.g., "fuzzy caterpillar" for MCMC traces).
- Formatting: Use bolding, lists, and code blocks for readability.
- Caveats: Mention that BEAST is not the only tool (MrBayes, RevBayes), but stick to the user's request about BEAST. Distinguish BEAST 1 vs. BEAST 2 briefly.
-
Self-Correction/Review during drafting:
- Initial thought: Should I explain how to create an XML file?
- Correction: No, that's too technical for a "Teach me the concepts" request. Focus on the theory and decisions made in the XML (BEAUti) stage, not the file syntax.
- Check: Did I explain why priors matter? Yes, sensitivity analysis.
- Check: Did I cover clock models clearly? Ensure the distinction between "uncorrelated" and "autocorrelated" is clear, though UCLD is the standard default. Let's stick to UCLD to avoid overwhelming the user.
-
Final Output Generation: (This matches the provided good response.)
- Structure:
- The Bayesian Philosophy (Brief).
- Step 1: Priors (The most critical user choice).
- Step 2: Clock Models (Time-calibration).
- Step 3: Assessing Convergence (MCMC diagnostics).
- Step 4: Reporting (How to write it up).
- Add a "Pro-Tips" section for common pitfalls.
-
Final Polish: Ensure terms like "Burn-in," "MCC Tree," and "HPD" are defined. (Self-correction: Ensure I explain HPD - Highest Posterior Density).
-
(Produces output based on these steps.)
This guide provides a comprehensive overview of Bayesian phylogenetics using BEAST (Bayesian Evolutionary Analysis Sampling Trees).
Unlike maximum likelihood (which gives you the single "best" tree), Bayesian inference estimates the probability distribution of trees and parameters. It combines your data (the likelihood) with your prior beliefs (the priors) to produce a posterior distribution.
Here is the workflow, from setting priors to publishing your results.
1. The Philosophy: Priors (P(H))
The "Bayesian" in BEAST comes from Bayes' Theorem. You are calculating the Posterior probability of the tree.
Posterior∝Likelihood×Prior
The Prior is your knowledge about the evolutionary process before looking at the specific sequence data. If you choose bad priors (e.g., a tree age prior that contradicts the fossil record), your results will be wrong ("Garbage In, Garbage Out").
Key Priors you must select in BEAUti (the BEAST setup tool):
A. The Tree Prior (Demographic Model)
How did your taxa population grow or change over time?
- Coalescent (Constant Size): Good for a set of genes from a single species (intraspecific) where the population isn't changing.
- Coalescent (Bayesian Skyline/ Skygrid): The standard for "phylodynamics" (e.g., virus outbreaks). It allows population size to change over time, reconstructing epidemic history.
- Yule Process (Birth-Only): The standard for macro-evolution (speciation across different species). It assumes lineages split but never go extinct.
- Birth-Death Process: For macro-evolution where extinction is possible.
B. The Substitution Model
- Nucleotide models: HKY, GTR, etc. (Similar to Maximum Likelihood).
- Site Model: Gamma (+G) and Invariant sites (+I).
- Note: BEAST usually sets "empirical" base frequencies by default, which is fine.
C. The Clock Prior (Rate of Evolution)
- See the "Clock Models" section below.
2. Clock Models: Time vs. Rate
BEAST is famous for being a molecular clock method. It simultaneously estimates the tree topology and the timing of divergences.
A. Strict Clock
- Assumption: The mutation rate is exactly the same across every branch of the tree.
- Use case: Very closely related taxa (e.g., HIV transmission pairs), intraspecific data, or simulated data. Rarely holds true for deep evolutionary timescales.
B. Relaxed Clock (Uncorrelated Lognormal - UCLD)
- Assumption: The mutation rate varies from branch to branch. Rates are drawn from a lognormal distribution.
- Use case: The standard for almost all real-world data analysis. It allows for "rate heterogeneity."
- Interpretation: If the Coefficient of Variation (ucld.stdev) in the logs is near 0, the data is "clock-like." If it is > 0.1, you definitely need a relaxed clock.
C. Tip-Dating (Sampling Dates)
To estimate time, BEAST needs dates.
- Tip Dates: You usually provide the year of collection (e.g., 2020, 2021). BEAST calculates the "height" of the tree in units of time (usually years or millions of years).
- Calibration: If you lack tip dates (e.g., all fossils collected at once), you must calibrate the root using a fossil (e.g., "Root age is Normal(10my, stdev 1)").
3. Convergence Checks: Did it work?
BEAST uses MCMC (Markov Chain Monte Carlo). It doesn't calculate the answer directly; it wanders around the parameter space looking for the highest probability areas. You must ensure the chain ran long enough to find the true distribution.
You use the program Tracer to check this.
A. The "Fuzzy Caterpillar"
- Open your
.log file in Tracer.
- Look at the trace plots (the parameter values over state number).
- Good: A flat, fuzzy line with no trends (upward/downward slope).
- Bad: The line is still climbing or bouncing wildly (the chain hasn't settled).
B. ESS (Effective Sample Size)
- This is the most important number.
- Rule of Thumb: ESS must be > 200.
- If ESS is low (red in Tracer), BEAST hasn't sampled the parameter enough. You need to run the chain longer (e.g., 100 million steps instead of 10 million).
C. Burn-in
- The first 10% (usually) of the chain is the "warm-up" where the chain is moving from the random starting tree to the high-probability area. You must discard this.
- In Tracer, ensure the "Burn-in" setting removes the early erratic part of the trace.
4. Summarizing Trees (TreeAnnotator)
You have thousands of trees from the posterior. How do you draw one?
- Burn-in: Discard the first 10% of trees.
- Target Tree: usually the Maximum Clade Credibility (MCC) Tree.
- This is the tree that has the highest product of clade probabilities across the posterior set.
- Node Heights: Set to "Mean Heights" (averaging the age of that node across all trees where it exists).
Result: A single tree file you can view in FigTree. The nodes will have probability values (0 to 1).
5. Reporting Standards
When publishing a BEAST analysis, you must be transparent so others can replicate it. Here is a checklist of what to include in your Methods section:
The "Methods" Checklist:
- Software Versions: "Analyses were performed using BEAST v2.7.6..."
- Substitution Model: "We used a GTR+G+I substitution model."
- Clock Model: "An uncorrelated relaxed lognormal clock (UCLD) was employed."
- Tree Prior: "A Coalescent Bayesian Skyline prior was used with 5 groups."
- MCMC Settings: "The MCMC chain was run for 100 million steps, sampling every 10,000 steps."
- Convergence: "Convergence was assessed in Tracer v1.7. All parameters achieved ESS values > 200."
- Calibration/Priors: "The root height was constrained with a Normal prior (Mean=5.0, Sigma=0.5) based on the fossil X. albus."
Summary Workflow
- BEAUti: Load FASTA → Set Priors (Yule/Skyline) → Set Clock (Relaxed) → Set Dates → Generate XML.
- BEAST: Run the XML (Compute).
- Tracer: Check ESS > 200.
- TreeAnnotator: Summarize trees into MCC tree.
- FigTree: Visualize and annotate posterior probabilities.