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_name="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
| key | lnL | nfp | DLC | unique_Q | 
|---|---|---|---|---|
| 'GN' | -6987.9632 | 22 | True | True | 
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
| A>C | A>G | A>T | C>A | C>G | C>T | G>A | G>C | G>T | T>A | T>C | 
|---|---|---|---|---|---|---|---|---|---|---|
| 0.87 | 3.66 | 0.91 | 1.59 | 2.12 | 6.02 | 8.22 | 1.23 | 0.63 | 1.25 | 3.42 | 
| edge | parent | length | 
|---|---|---|
| Galago | root | 0.17 | 
| HowlerMon | root | 0.04 | 
| Rhesus | edge.3 | 0.02 | 
| Orangutan | edge.2 | 0.01 | 
| Gorilla | edge.1 | 0.00 | 
| Human | edge.0 | 0.01 | 
| Chimpanzee | edge.0 | 0.00 | 
| edge.0 | edge.1 | 0.00 | 
| edge.1 | edge.2 | 0.00 | 
| edge.2 | edge.3 | 0.01 | 
| edge.3 | root | 0.01 | 
| A | C | G | T | 
|---|---|---|---|
| 0.38 | 0.17 | 0.21 | 0.24 |