File: plot_aln-coevolution.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 (50 lines) | stat: -rw-r--r-- 1,567 bytes parent folder | download | duplicates (2)
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
.. jupyter-execute::
    :hide-code:

    import set_working_directory

Coevolution analysis
====================

A method on the alignment provides an interface to the simpler (and yet robust and fast) methods for estimating coevolution. The default measure is normalised mutual information (NMI).

.. todo:: add citation for NMI

Display coevolution as a heatmap
--------------------------------

Using the ``drawable`` argument causes the returned object to have a ``drawable`` attribute (type ``Drawable`` which has ``show()`` and ``write()`` methods), for the corresponding plot types -- a heatmap in this case.

.. jupyter-execute::

    from cogent3 import load_aligned_seqs

    aln = load_aligned_seqs("data/brca1.fasta", moltype="dna")
    aln = aln.no_degenerates(motif_length=3)
    aln = aln.get_translation()
    aln = aln[:100]  # for compute speed in testing the documentation
    coevo = aln.coevolution(show_progress=False, drawable="heatmap")
    coevo.drawable.show()

.. jupyter-execute::
    :hide-code:

    outpath = set_working_directory.get_thumbnail_dir() / "plot_aln-coevolution.png"

    coevo.drawable.write(outpath)

Display coevolution scores as a Violin plot
-------------------------------------------

.. jupyter-execute::

    coevo = aln.coevolution(show_progress=False, drawable="violin")
    coevo.drawable.show(width=300)

Display coevolution scores as a Boxplot
---------------------------------------

.. jupyter-execute::

    coevo = aln.coevolution(show_progress=False, drawable="box")
    coevo.drawable.show(width=300)