Extracting maximum likelihood estimates from a model_result
¶
If you want to get the stats out-of a fitted model, use the evo.tabulate_stats()
app.
We first fit a model.
[1]:
from cogent3.app import io, evo
loader = io.load_aligned(format="fasta", moltype="dna")
aln = loader("../data/primate_brca1.fasta")
model = evo.model("GN", tree="../data/primate_brca1.tree")
result = model(aln)
Create and apply tabulate_stats
app¶
[2]:
tabulator = evo.tabulate_stats()
tabulated = tabulator(result)
tabulated
[2]:
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), only the table only has entries for the branch scalar (denoted “length”).
[3]:
tabulated["edge params"]
[3]:
edge | parent | length |
---|---|---|
Galago | root | 0.1735 |
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 |
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¶
In this example, these are the elements of the rate matrix.
[4]:
tabulated["global params"]
[4]:
A>C | A>G | A>T | C>A | C>G | C>T | G>A | G>C | G>T | T>A |
---|---|---|---|---|---|---|---|---|---|
0.8700 | 3.6669 | 0.9111 | 1.5925 | 2.1264 | 6.0323 | 8.2178 | 1.2288 | 0.6294 | 1.2498 |
T>C |
---|
3.4136 |
1 rows x 11 columns
Motif parameters¶
In the current example, these are estimates of the nucleotide probabilities in the unobserved ancestor.
[5]:
tabulated["motif params"]
[5]:
A | C | G | T |
---|---|---|---|
0.3756 | 0.1768 | 0.2078 | 0.2398 |
1 rows x 4 columns