This is the hypothesis test presented in Zhang et al . It evaluates the hypothesis that a set of sites have undergone positive natural selection on a pre-specified set of lineages.
For this model class, there are groups of branches for which all positions are evolving neutrally but some proportion of those neutrally evolving sites change to adaptively evolving on so-called foreground edges. For the current example, we’ll define the Chimpanzee and Human branches as foreground and everything else as background. The following table defines the parameter scopes.
<IPython.core.display.HTML object>
Our implementation is not as parametrically succinct as that of Zhang et al, we have 1 additional bin probability.
from cogent3 import get_app
loader = get_app("load_aligned" , format_name= "fasta" , moltype= "dna" )
aln = loader("data/primate_brca1.fasta" )
zhang_test = get_app("natsel_zhang" ,
"GNC" ,
tree= "data/primate_brca1.tree" ,
optimise_motif_probs= False ,
tip1= "Human" ,
tip2= "Chimpanzee" ,
)
result = zhang_test(aln)
result
Statistics
LR df pvalue
4.9647 3 0.1744
hypothesis key lnL nfp DLC unique_Q
null 'GNC-null' -6708.3129 24 True True
alt 'GNC-alt' -6705.8305 27 True True
GNC-alt
log-likelihood = -6705.8305
number of free parameters = 27
Global params
A>C A>G A>T C>A C>G C>T G>A G>C G>T T>A T>C
0.86 3.53 0.97 1.66 2.19 6.26 8.01 1.24 0.79 1.27 2.96
Bin params
bin bprobs
0 0.05
1 0.27
2a 0.04
2b 0.64
Edge params
edge parent length
Galago root 0.54
HowlerMon root 0.14
Rhesus edge.3 0.06
Orangutan edge.2 0.02
Gorilla edge.1 0.01
Human edge.0 0.02
Chimpanzee edge.0 0.01
edge.0 edge.1 0.00
edge.1 edge.2 0.01
edge.2 edge.3 0.04
edge.3 root 0.02
Edge bin params
edge bin omega
Galago 0 0.00
Galago 1 1.00
Galago 2a 0.00
Galago 2b 1.00
HowlerMon 0 0.00
HowlerMon 1 1.00
HowlerMon 2a 0.00
HowlerMon 2b 1.00
Rhesus 0 0.00
Rhesus 1 1.00
Rhesus 2a 0.00
Rhesus 2b 1.00
Orangutan 0 0.00
Orangutan 1 1.00
Orangutan 2a 0.00
Orangutan 2b 1.00
Gorilla 0 0.00
Gorilla 1 1.00
Gorilla 2a 0.00
Gorilla 2b 1.00
Human 0 0.00
Human 1 1.00
Human 2a 20.00
Human 2b 20.00
Chimpanzee 0 0.00
Chimpanzee 1 1.00
Chimpanzee 2a 20.00
Chimpanzee 2b 20.00
edge.0 0 0.00
edge.0 1 1.00
edge.0 2a 0.00
edge.0 2b 1.00
edge.1 0 0.00
edge.1 1 1.00
edge.1 2a 0.00
edge.1 2b 1.00
edge.2 0 0.00
edge.2 1 1.00
edge.2 2a 0.00
edge.2 2b 1.00
edge.3 0 0.00
edge.3 1 1.00
edge.3 2a 0.00
edge.3 2b 1.00
Motif params
AAA AAC AAG AAT ACA ACC ACG ACT AGA AGC AGG AGT ATA
0.06 0.02 0.03 0.06 0.02 0.00 0.00 0.03 0.02 0.03 0.01 0.04 0.02
continuation
ATC ATG ATT CAA CAC CAG CAT CCA CCC CCG CCT CGA CGC
0.01 0.01 0.02 0.02 0.01 0.02 0.02 0.02 0.01 0.00 0.03 0.00 0.00
continuation
CGG CGT CTA CTC CTG CTT GAA GAC GAG GAT GCA GCC GCG
0.00 0.00 0.01 0.01 0.01 0.01 0.08 0.01 0.03 0.03 0.02 0.01 0.00
continuation
GCT GGA GGC GGG GGT GTA GTC GTG GTT TAC TAT TCA TCC
0.01 0.02 0.01 0.01 0.01 0.01 0.01 0.01 0.02 0.00 0.01 0.02 0.01
continuation
TCG TCT TGC TGG TGT TTA TTC TTG TTT
0.00 0.03 0.00 0.00 0.02 0.02 0.01 0.01 0.02
Getting the posterior probabilities of site-class membership
bprobs = result.alt.lf.get_bin_probs()
bprobs[:, :20 ]
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
0 0.0756 0.0426 0.0000 0.0668 0.0584 0.0798 0.0428 0.0606 0.0517 0.0409 0.0391 0.0798 0.0478 0.0000 0.0794 0.2609 0.0409 0.0354 0.0584 0.0617
1 0.2550 0.2705 0.2934 0.2592 0.2632 0.2531 0.2703 0.2621 0.2662 0.2710 0.2720 0.2531 0.2680 0.2931 0.2532 0.1566 0.2710 0.2737 0.2632 0.2615
2a 0.0570 0.0330 0.0000 0.0506 0.0446 0.0600 0.0332 0.0462 0.0397 0.0319 0.0304 0.0600 0.0369 0.0000 0.0597 0.2032 0.0319 0.0277 0.0446 0.0471
2b 0.6123 0.6539 0.7066 0.6233 0.6339 0.6072 0.6536 0.6311 0.6424 0.6562 0.6585 0.6072 0.6473 0.7069 0.6076 0.3792 0.6562 0.6632 0.6339 0.6297