File: evo-natsel_sitehet.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 (41 lines) | stat: -rw-r--r-- 1,377 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
.. jupyter-execute::
    :hide-code:

    import set_working_directory

``natsel_sitehet`` – a test of site heterogeneity
-------------------------------------------------

This app evaluates evidence for whether sites differ in their mode of
natural selection (`Nielsen and Yang
1998 <https://www.ncbi.nlm.nih.gov/pubmed/9539414>`__).

.. jupyter-execute::

    from cogent3 import get_app

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

    sites_differ = get_app("natsel_sitehet",
        "GNC", tree="data/primate_brca1.tree", optimise_motif_probs=False
    )

    result = sites_differ(aln)
    result

The models have been constructed such that site-class bins have names indicating the mode of natural selection: -ve is purifying (oomega<1); neutral (omega=1); and +ve is positive natural selection (omega>1). The two parameters of interest relating to these are the ``bprobs`` (the maximum likelihood estimate of the frequency of the site-class) and the corresponding value of omega.

.. jupyter-execute::

    result.alt.lf

Getting the individual site posterior probabilities
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

I’m just displaying the posterior-probabilities from the first 20 positions only.

.. jupyter-execute::

    bprobs = result.alt.lf.get_bin_probs()
    bprobs[:, :20]