RAxML
RAxML (Randomized Axelerated Maximum Likelihood) is a tool for large-scale maximum likelihood phylogenetic analysis.
Basic Usage
# Standard analysis with automatic model selection
raxml-ng --all --msa alignment.fasta --model GTR+G --prefix output --threads 4
# With bootstrapping
raxml-ng --all --msa alignment.fasta --model GTR+G \
--prefix output --threads 4 --bs-trees 100
Nucleotide Models
# Common DNA models
raxml-ng --msa alignment.fasta --model GTR+G # General Time Reversible + Gamma
raxml-ng --msa alignment.fasta --model GTR+I+G # + Invariant sites
raxml-ng --msa alignment.fasta --model HKY+G # Hasegawa-Kishino-Yano
raxml-ng --msa alignment.fasta --model JC # Jukes-Cantor
raxml-ng --msa alignment.fasta --model K80 # Kimura 2-parameter
# Automatic model selection
raxml-ng --msa alignment.fasta --model GTR+G --all \
--tree pars{25},rand{25} --prefix output
Protein Models
# Protein analysis
raxml-ng --msa protein_alignment.fasta --model LG+G --prefix protein_tree
# Other protein models
raxml-ng --msa alignment.fasta --model WAG+G # Whelan and Goldman
raxml-ng --msa alignment.fasta --model JTT+G # Jones-Taylor-Thornton
raxml-ng --msa alignment.fasta --model DAYHOFF+G # Dayhoff
raxml-ng --msa alignment.fasta --model LG+G+F # + Empirical frequencies
Bootstrap Analysis
# Rapid bootstrap analysis
raxml-ng --bootstrap --msa alignment.fasta --model GTR+G \
--prefix boot --threads 4 --bs-trees 1000
# Map bootstrap values to best tree
raxml-ng --support --tree best_tree.tree --bs-trees boot.raxml.bootstraps \
--prefix final
# Automatic bootstrap convergence
raxml-ng --all --msa alignment.fasta --model GTR+G \
--prefix output --bs-trees autoMRE --threads 4
Partitioned Analysis
# Create partition file (partitions.txt):
# GTR+G, part1 = 1-500
# GTR+G, part2 = 501-1000
# LG+G, part3 = 1001-1300
# Run with partitions
raxml-ng --msa alignment.fasta --model partitions.txt \
--prefix partitioned --threads 4
Tree Search Strategies
# Multiple starting trees
raxml-ng --msa alignment.fasta --model GTR+G \
--tree pars{10},rand{10} --prefix multi_start
# Starting from specific tree
raxml-ng --msa alignment.fasta --model GTR+G \
--tree starting_tree.nwk --prefix from_tree
# Tree evaluation (no search)
raxml-ng --evaluate --msa alignment.fasta --model GTR+G \
--tree input_tree.nwk --prefix eval
Python Interface
import subprocess
import os
def run_raxml(alignment_file, model='GTR+G', bootstraps=100,
threads=4, prefix='raxml_output'):
"""Run RAxML-NG analysis."""
cmd = [
'raxml-ng', '--all',
'--msa', alignment_file,
'--model', model,
'--prefix', prefix,
'--threads', str(threads),
'--bs-trees', str(bootstraps)
]
result = subprocess.run(cmd, capture_output=True, text=True)
if result.returncode == 0:
# Parse results
tree_file = f'{prefix}.raxml.bestTree'
support_file = f'{prefix}.raxml.support'
return {
'best_tree': tree_file if os.path.exists(tree_file) else None,
'support_tree': support_file if os.path.exists(support_file) else None,
'log': f'{prefix}.raxml.log'
}
else:
raise RuntimeError(f"RAxML failed: {result.stderr}")
# Run analysis
results = run_raxml('alignment.fasta', model='GTR+G', bootstraps=100)
print(f"Best tree: {results['best_tree']}")
Model Selection with ModelTest-NG
# Find best model
modeltest-ng -i alignment.fasta -d nt -p 4
# Use selected model in RAxML
raxml-ng --msa alignment.fasta --model <selected_model> --prefix final
Output Files
| File |
Description |
| .raxml.bestTree |
Best ML tree |
| .raxml.support |
Tree with bootstrap support |
| .raxml.bootstraps |
Bootstrap trees |
| .raxml.log |
Analysis log |
| .raxml.mlTrees |
All ML trees |
| .raxml.bestModel |
Optimized model parameters |
Tips for Large Datasets
- Use
--threads auto for automatic thread detection
- For very large alignments, use
--redo to resume interrupted runs
- Consider using site repeats:
--site-repeats on
- Use binary MSA format for faster I/O:
--parse first