Extracting maximum likelihood estimates from a model_result#

Note

These docs now use the new_type core objects via the following setting.

import os

# using new types without requiring an explicit argument
os.environ["COGENT3_NEW_TYPE"] = "1"

If you want to get the stats from a fitted model, use the tabulate_stats app.

We demonstrate this by first fitting a model.

from cogent3 import get_app

loader = get_app("load_aligned", format="fasta", moltype="dna")
aln = loader("data/primate_brca1.fasta")
model = get_app("model", "GN", tree="data/primate_brca1.tree")
result = model(aln)

Create and apply tabulate_stats app#

tabulator = get_app("tabulate_stats")
tabulated = tabulator(result)
tabulated
3x tabular_result('global params': Table, 'edge params': Table, 'motif params': Table)

tabulated is a tabular_result instance which, like other result types, has dict like behaviour. It also contains key/value pairs for each model parameter type.

Edge parameters#

These are all parameters that differ between edges. Since the current model is time-homogeneous (a single rate matrix), the table only has entries for the branch scalar (denoted “length”).

tabulated["edge params"]
edge params
edgeparentlength
Galagoroot0.17
HowlerMonroot0.04
Rhesusedge.30.02
Orangutanedge.20.01
Gorillaedge.10.00
Humanedge.00.01
Chimpanzeeedge.00.00
edge.0edge.10.00
edge.1edge.20.00
edge.2edge.30.01
edge.3root0.01

11 rows x 3 columns

Note

Unless the model is time-reversible, the lengths in that table are not ENS (Kaehler et al). As we used a non-stationary nucleotide model in this example, the length values are a scalar used to adjust the matrices during optimisation.

Global parameters#

These are the elements of the rate matrix.

tabulated["global params"]
global params
A>CA>GA>TC>AC>GC>TG>AG>CG>TT>AT>C
0.873.660.911.592.126.028.221.230.631.253.42

1 rows x 11 columns

Motif parameters#

These are estimates of the nucleotide probabilities in the unobserved ancestor.

tabulated["motif params"]
motif params
ACGT
0.380.170.210.24

1 rows x 4 columns