9 Phylonetworks Analysis - PhyloAI/Ortho2Web GitHub Wiki
9.1 SNaQ
Species Network Analysis with Quartets (SNaQ) is a method used in phylogenetics to infer reticulate evolutionary relationships, which include not only tree-like divergence but also hybridization events among lineages. Unlike traditional phylogenetic trees, which assume a branching-only process, SNaQ generates phylogenetic networks by adding hybridization edges to tree structures, capturing non-treelike evolutionary signals.
Step 1: Installation
conda install -c conda-forge julia
Step 2: Running hybrid network analysis
using PhyloNetworks
using PhyloPlots
# Load RAxML gene trees
raxmlCF = readTrees2CF("raxml/besttrees.tre", writeTab=false, writeSummary=false)
# Load ASTRAL species tree (using a specific topology)
astraltree = readMultiTopology("astral/astral.tre")[102]
using Distributed
addprocs(10) # Add processors for parallel computing
@everywhere using PhyloNetworks
# Estimate networks with increasing numbers of hybridization events
net0 = snaq!(astraltree, raxmlCF, hmax=0, filename="snaq/net0_raxml", seed=123, runs=50)
net1 = snaq!(net0, raxmlCF, hmax=1, filename="snaq/net1_raxml", seed=456, runs=50)
net2 = snaq!(net1, raxmlCF, hmax=2, filename="snaq/net2_raxml", seed=789, runs=50)
net3 = snaq!(net2, raxmlCF, hmax=3, filename="snaq/net3_raxml", seed=456, runs=50)
net4 = snaq!(net3, raxmlCF, hmax=4, filename="snaq/net4_raxml", seed=789, runs=50)
Step 3: Plotting results
using PhyloNetworks
using PhyloPlots
using RCall
# Root each estimated network at the specified outgroup
net0 = readSnaqNetwork("snaq/net0_raxml.out")
rootatnode!(net0, "Outgroup")
net1 = readSnaqNetwork("snaq/net1_raxml.out")
rootatnode!(net1, "Outgroup")
net2 = readSnaqNetwork("snaq/net2_raxml.out")
rootatnode!(net2, "Outgroup")
net3 = readSnaqNetwork("snaq/net3_raxml.out")
rootatnode!(net3, "Outgroup")
net4 = readSnaqNetwork("snaq/net4_raxml.out")
rootatnode!(net4, "Outgroup")
scores = [net0.loglik, net1.loglik, net2.loglik, net3.loglik, net4.loglik]
R"pdf"("score.pdf", width=9, height=9);
R"plot"(x=0:4, y=scores, type="o", xlab="number of hybridizations h", ylab="network score");
R"dev.off"();
R"pdf"("plot.pdf", width=28, height=12)
plot(net0, :R);
plot(net1, :R, showGamma=true, style=:majortree);
plot(net2, :R, showGamma=true, style=:majortree);
plot(net3, :R, showGamma=true, style=:majortree);
plot(net4, :R, showGamma=true, style=:majortree);
R"dev.off()";
9.2 PhyloNet
PhyloNet is an open-source software tool designed for evolutionary biology, particularly focused on analyzing reticulate evolutionary events like genome hybridization and gene flow. It is widely used in phylogenomic analyses to study complex evolutionary histories, hybridization events, and interspecies gene transfer.
Step 1: Installation
wget -c https://phylogenomics.rice.edu/media/PhyloNet.jar
Step 2: Preparing
Below is the script for running PhyloNet.
#NEXUS
BEGIN TREES;
Tree gt1 = ((C,((B,D),A)),E);
Tree gt2 = (B,(D,(C,(A,E))));
......
Tree gt200 = (D,((B,E),(C,A)));
END;
BEGIN PHYLONET;
MCMC_GT (all) -cl 1100000 -bl 100000 -sf 1000 -sd 12345678 -mr 3 -pl 5 -tp (1.0, 2.0, 3.0) -pseudo;
END;
Step 3: Running
java -jar PhyloNet.jar PhyloNet.nex > mcmc.txt