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
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 |
---|---|---|---|---|---|---|---|---|---|
0.8699 | 3.6640 | 0.9110 | 1.5907 | 2.1246 | 6.0241 | 8.2213 | 1.2295 | 0.6296 | 1.2502 |
T>C |
---|
3.4168 |
edge | parent | length |
---|---|---|
Galago | root | 0.1734 |
HowlerMon | root | 0.0450 |
Rhesus | edge.3 | 0.0215 |
Orangutan | edge.2 | 0.0078 |
Gorilla | edge.1 | 0.0025 |
Human | edge.0 | 0.0061 |
Chimpanzee | edge.0 | 0.0028 |
edge.0 | edge.1 | 0.0000 |
edge.1 | edge.2 | 0.0033 |
edge.2 | edge.3 | 0.0121 |
edge.3 | root | 0.0077 |
A | C | G | T |
---|---|---|---|
0.3757 | 0.1742 | 0.2095 | 0.2406 |