File: evo-model-with-tree.rst

package info (click to toggle)
python-cogent 2024.5.7a1%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 74,600 kB
  • sloc: python: 92,479; makefile: 117; sh: 16
file content (53 lines) | stat: -rw-r--r-- 1,248 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
.. jupyter-execute::
    :hide-code:

    import set_working_directory

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

We analyse an alignment with sequences from 6 primates.

.. jupyter-execute::

    from cogent3 import get_app

    loader = get_app("load_aligned", format="fasta", moltype="dna")
    aln = loader("data/primate_brca1.fasta")
    aln.names

Specify the tree via a tree instance
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. jupyter-execute::

    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

Specify the tree via a path.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. jupyter-execute::

    gn = get_app("model", "GN", tree="data/primate_brca1.tree")
    gn

Apply the model to an alignment
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. jupyter-execute::

    fitted = gn(aln)
    fitted

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.

.. jupyter-execute::

    fitted.lf