File: draw_dotplot.rst

package info (click to toggle)
python-cogent 1.4.1-1.2
  • links: PTS, VCS
  • area: non-free
  • in suites: squeeze
  • size: 13,260 kB
  • ctags: 20,087
  • sloc: python: 116,163; ansic: 732; makefile: 74; sh: 9
file content (36 lines) | stat: -rw-r--r-- 1,064 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
Drawing a dotplot
=================

.. sectionauthor:: Gavin Huttley

.. doctest::

    >>> from cogent import LoadSeqs
    >>> from cogent.core import annotation
    >>> from cogent.draw import dotplot

Load the alignment for illustrative purposes, I'll make one sequence a different length than the other and introduce a custom sequence annotation for a miscellaneous feature. Normally, those annotations would be on the unaligned sequences.

.. doctest::

    >>> aln = LoadSeqs("data/test.paml")
    >>> feature = aln.addAnnotation(annotation.Feature, "misc_feature",
    ...                             "pprobs", [(38, 55)])
    >>> seq1 = aln.getSeq('NineBande')[10:-3]
    >>> seq2 = aln.getSeq('DogFaced')

Write out the dotplot as a pdf file in the current directory note that seq1 will be the x-axis, and seq2 the y-axis.

.. doctest::

    >>> dp = dotplot.Display2D(seq1,seq2)
    >>> filename = 'dotplot_example.pdf'
    >>> dp.drawToPDF(filename)

.. clean up

.. doctest::
    :hide:
    
    >>> import os
    >>> os.remove('dotplot_example.pdf')