Apply a non-stationary nucleotide model to an alignment with a tree#

We analyse an alignment with sequences from 6 primates.

from cogent3 import get_app

loader = get_app("load_aligned", format="fasta", moltype="dna")
aln = loader("data/primate_brca1.fasta")
aln.names
['Galago',
 'HowlerMon',
 'Rhesus',
 'Orangutan',
 'Gorilla',
 'Human',
 'Chimpanzee']

Specify the tree via a tree instance#

from cogent3 import load_tree
from cogent3 import get_app

tree = load_tree("data/primate_brca1.tree")
gn = get_app("model", "GN", tree=tree)
gn
model(sm='GN',
tree=Tree("(Galago,HowlerMon,(Rhesus,(Orangutan,(Gorilla,(Human,Chimpanzee)))));"),
unique_trees=False, tree_func=None, name=None, optimise_motif_probs=False,
sm_args=None, lf_args=None, time_het=None, param_rules=None, opt_args=None,
lower=1e-06, upper=50, split_codons=False, show_progress=False, verbose=False)

Specify the tree via a path.#

gn = get_app("model", "GN", tree="data/primate_brca1.tree")
gn
model(sm='GN', tree='data/primate_brca1.tree', unique_trees=False,
tree_func=None, name=None, optimise_motif_probs=False, sm_args=None,
lf_args=None, time_het=None, param_rules=None, opt_args=None, lower=1e-06,
upper=50, split_codons=False, show_progress=False, verbose=False)

Apply the model to an alignment#

fitted = gn(aln)
fitted
GN
keylnLnfpDLCunique_Q
'GN'-6987.963222TrueTrue

In the above, no value is shown for unique_Q. This can happen because of numerical precision issues.

Note

in the display of the lf below, the “length” parameter is not the ENS. It is, instead, just a scalar.

fitted.lf

GN

log-likelihood = -6987.9632

number of free parameters = 22

Global params
A>CA>GA>TC>AC>GC>TG>AG>CG>TT>A
0.86993.66400.91101.59072.12466.02418.22131.22950.62961.2502
continuation
T>C
3.4168
Edge params
edgeparentlength
Galagoroot0.1734
HowlerMonroot0.0450
Rhesusedge.30.0215
Orangutanedge.20.0078
Gorillaedge.10.0025
Humanedge.00.0061
Chimpanzeeedge.00.0028
edge.0edge.10.0000
edge.1edge.20.0033
edge.2edge.30.0121
edge.3root0.0077
Motif params
ACGT
0.37570.17420.20950.2406