-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
documentation and clarity edited for examples and scripts
- Loading branch information
Felix Simkovic
committed
Feb 1, 2017
1 parent
fa7e8d1
commit 2c4e09d
Showing
11 changed files
with
238 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
""" | ||
Simple contact map plotting 2 | ||
============================= | ||
This script contains a simple example of how you can plot | ||
contact maps with a reference structure using ConKit | ||
""" | ||
|
||
import conkit | ||
|
||
# Define the input variables | ||
sequence_file = "toxd/toxd.fasta" | ||
sequence_format = "fasta" | ||
contact_file = "toxd/toxd.mat" | ||
contact_format = "ccmpred" | ||
|
||
# Create ConKit hierarchies | ||
# Note, we only need the first Sequence/ContactMap | ||
# from each file | ||
seq = conkit.io.read(sequence_file, sequence_format).top_sequence | ||
conpred = conkit.io.read(contact_file, contact_format).top_map | ||
|
||
# Assign the sequence register to your contact prediction | ||
conpred.sequence = seq | ||
conpred.assign_sequence_register() | ||
|
||
# We need to tidy our contact prediction before plotting | ||
conpred.remove_neighbors(inplace=True) | ||
conpred.sort('raw_score', reverse=True, inplace=True) | ||
|
||
# Finally, we don't want to plot all contacts but only the top-L, | ||
# so we need to slice the contact map | ||
map = conpred[:conpred.sequence.seq_len] | ||
|
||
# ==================================================== | ||
# The code above is identical to the previous example | ||
# Now we need to compare it to our reference structure | ||
pdb_file = "toxd/toxd.pdb" | ||
pdb = conkit.io.read(pdb_file, "pdb").top_map | ||
# The two keywords do the following: | ||
# - remove_unmatched : remove contacts absent from the pdb_file | ||
# - renumber : match the numbering to the pdb_file | ||
map_matched = map.match(pdb, remove_unmatched=True, renumber=True) | ||
|
||
# Then we can plot the map | ||
contact_plot = "toxd/toxd.png" | ||
conkit.plot.contact_map(map_matched, reference=pdb, file_name=contact_plot) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
""" | ||
Simple contact map plotting 1 | ||
============================= | ||
This script contains a simple example of how you can plot | ||
contact maps using ConKit | ||
""" | ||
|
||
import conkit | ||
|
||
# Define the input variables | ||
sequence_file = "toxd/toxd.fasta" | ||
sequence_format = "fasta" | ||
contact_file = "toxd/toxd.mat" | ||
contact_format = "ccmpred" | ||
|
||
# Create ConKit hierarchies | ||
# Note, we only need the first Sequence/ContactMap | ||
# from each file | ||
seq = conkit.io.read(sequence_file, sequence_format).top_sequence | ||
conpred = conkit.io.read(contact_file, contact_format).top_map | ||
|
||
# Assign the sequence register to your contact prediction | ||
conpred.sequence = seq | ||
conpred.assign_sequence_register() | ||
|
||
# We need to tidy our contact prediction before plotting | ||
conpred.remove_neighbors(inplace=True) | ||
conpred.sort('raw_score', reverse=True, inplace=True) | ||
|
||
# Finally, we don't want to plot all contacts but only the top-L, | ||
# so we need to slice the contact map | ||
map = conpred[:conpred.sequence.seq_len] | ||
|
||
# Then we can plot the map | ||
contact_plot = "toxd/toxd.png" | ||
conkit.plot.contact_map(map, file_name=contact_plot) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,92 @@ | ||
.. _example_plotting_a_map: | ||
|
||
Contact Map Plotting | ||
==================== | ||
|
||
To plot contacts in form of a contact map using ConKit, you need a contact prediction file. | ||
-------------------- | ||
|
||
.. warning:: | ||
You require the `Matplotlib <http://matplotlib.org/>`_ package to use this functionality. If you are unsure if it is installed on your system, refer to the :ref:`installation` documentation | ||
You require the `Matplotlib <http://matplotlib.org/>`_ package to use this script. If you are unsure if it is installed on your system, refer to the :ref:`installation` documentation | ||
|
||
Using a script | ||
^^^^^^^^^^^^^^ | ||
|
||
If you would like to plot a contact map using ConKit without the overhead of using Python, you can simply use the ``conkit.plot_map`` script. | ||
|
||
-------------------------------------------------------------- | ||
|
||
.. code-block:: bash | ||
$> conkit.plot_map toxd/toxd.fasta fasta toxd/toxd.mat ccmpred | ||
The call above uses the contact prediction file ``toxd.mat`` file, which is in ``ccmpred`` format, and plots the following 2D contact map stored in the file ``toxd/toxd.png`` | ||
|
||
.. _Toxd Simple Contact Map: | ||
|
||
.. image:: images/toxd_cmap_simple.png | ||
:alt: Toxd CMap Simple | ||
|
||
-------------------------------------------------------------- | ||
|
||
You can also add a reference structure to determine which contacts are true and false positive contacts. By default, all contacts are identified in the reference structure by measuring the distance between Cβ atoms, whereby all atoms closer than 8Å are considered to be in contact. | ||
|
||
.. code-block:: bash | ||
$> conkit.plot_map -p toxd/toxd.pdb toxd/toxd.fasta fasta toxd/toxd.mat ccmpred | ||
The call above produces a contact map plot looking like this. The gray points are the reference contacts, green show true positive contacts in your prediction and red false positive ones. | ||
|
||
.. _Toxd Reference Contact Map: | ||
|
||
.. image:: images/toxd_cmap_reference.png | ||
:alt: Toxd CMap Reference | ||
|
||
-------------------------------------------------------------- | ||
|
||
Finally, you could also add a second contact prediction file to the call to compare two maps against each other. | ||
|
||
.. code-block:: bash | ||
$> conkit.plot_map -e toxd/toxd.psicov -ef psicov -p toxd/toxd.pdb toxd/toxd.fasta fasta toxd/toxd.mat ccmpred | ||
The call above produces a contact map plot looking like this. The gray points are the reference contacts, green show true positive contacts in your prediction and red false positive ones. The top triangle is the second contact map from file ``toxd/toxd.psicov`` whereas the bottom one is from ``toxd/toxd.mat``. | ||
|
||
.. image:: images/toxd_cmap_advanced.png | ||
:alt: Toxd CMap Advanced | ||
|
||
.. note:: | ||
ConKit provides a script that allows you to plot contact maps from the command line. The script is called ``conkit.plot_map`` and installed automatically. | ||
|
||
You can use the last example also **without** a reference structure! | ||
|
||
-------------------------------------------------------- | ||
|
||
Using Python | ||
^^^^^^^^^^^^ | ||
|
||
Two simplified versions of the ``conkit.plot_map`` script is shown below to illustrate how you can plot your own contact map using Python. | ||
|
||
-------------------------------------------------------------- | ||
|
||
.. only:: html | ||
|
||
To start, you need to read the file into its hierarchy. | ||
.. note:: | ||
|
||
.. code-block:: python | ||
You can download this script :download:`here <code/map_plotting_simple.py>`. | ||
|
||
>>> import conkit | ||
>>> contact_h = conkit.io.read('pathto/contact.file', 'contact_format') | ||
.. literalinclude:: /../docs/examples/code/map_plotting_simple.py | ||
:language: python | ||
:linenos: | ||
|
||
With the code above, we created a :obj:`conkit.core.ContactFile` hierarchy. This allows you to store contact maps in a single hierarchy. Here, we are only interested in the first, and thus we can remove the rest. | ||
This will produce the `Toxd Simple Contact Map`_ plot. | ||
|
||
.. code-block:: python | ||
-------------------------------------------------------------- | ||
|
||
>>> contact_map = contact_h.top_map | ||
.. only:: html | ||
|
||
Finally, to plot the contact map, all we need to do is invoke the relevant function. | ||
.. note:: | ||
|
||
.. code-block:: python | ||
You can download this script :download:`here <code/map_plotting_reference.py>`. | ||
|
||
>>> contact_map.plot_map() | ||
.. literalinclude:: /../docs/examples/code/map_plotting_reference.py | ||
:language: python | ||
:linenos: | ||
|
||
This will create a contact map plot that will be saved to your disk. | ||
This will produce the `Toxd Reference Contact Map`_ plot. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters