@@ -58,24 +58,25 @@ def sharpen_preds(probs):
5858 return sharp_probs
5959
6060
61- def plot_preds (results , beg = 0 , end = - 1 , out_file = None ):
61+ def plot_preds (results , beg = 0 , end = - 1 , out_file = None , dpi = 300 ):
6262 """
6363 Helper function for plotting DeepCoil results
6464 :param results: results for given entry returned by DeepCoil
6565 :param beg: (optional) beginning aa of the range to use for plotting (useful for long sequences to see only subset of results)
6666 :param end: (optional) end aa of the range to use for plotting (useful for long sequences to see only subset of results)
6767 :param out_file: (optional) if specified results will also be dumped to file
68+ :param dpi: (optional) DPI of the resulting image
6869 :return:
6970 """
7071
7172 sharp_probs = sharpen_preds (results ['cc' ])[beg :end ]
7273 probs , hept = results ['cc' ][beg :end ], results ['hept' ][beg :end , :]
7374
74- fig , (ax2 , ax1 ) = plt .subplots (2 , gridspec_kw = {'height_ratios' : [1 , 9 ]}, figsize = (9 , 7 ))
75+ fig , (ax2 , ax1 ) = plt .subplots (2 , gridspec_kw = {'height_ratios' : [1 , 9 ]}, figsize = (9 , 5 ))
7576
7677 # Plot probs and sharpened probs
7778 ax1 .plot (probs , linewidth = 1 , c = 'gray' , linestyle = 'dashed' )
78- ax1 .plot (sharp_probs , linewidth = 3 , c = 'black' )
79+ ax1 .plot (sharp_probs , linewidth = 2 , c = 'black' )
7980
8081 # Set axis limits
8182 ax1 .set_ylim (0.01 , 1 )
@@ -89,12 +90,12 @@ def plot_preds(results, beg=0, end=-1, out_file=None):
8990 spacing = spacings [np .argmin ([abs (10 - len ([i for i in range (0 , len (probs ), spacing )])) for spacing in spacings ])]
9091 ticks = [i for i in range (0 , len (probs ), spacing )]
9192 labels = [i + beg for i in range (0 , len (probs ), spacing )]
92- labels [0 ] = ''
9393 ax1 .set_xticks (ticks )
9494 ax1 .set_xticklabels (labels )
9595 ax1 .set_yticks ([i / 10 for i in range (1 , 10 , 1 )])
9696 ax1 .xaxis .set_ticks_position ('none' )
97- ax1 .set_xlabel ('Sequence position' , fontsize = 16 )
97+ ax1 .set_xlabel ('Position in Sequence' )
98+ ax1 .set_ylabel ('Coiled Coil Probablity' )
9899
99100 # Parse a, d heptad annotations and plot
100101 a , d = [], []
@@ -120,13 +121,12 @@ def plot_preds(results, beg=0, end=-1, out_file=None):
120121 # Show the ticks corresponding to the bottom panel
121122 ax2 .xaxis .grid (linestyle = "dashed" , color = 'gray' , linewidth = 0.5 )
122123 ax2 .set_xticks ([i for i in range (0 , len (probs ), 50 )])
123- ax2 .set_yticklabels (['a' , 'd' ], rotation = 0 , fontsize = 12 )
124+ ax2 .set_yticks ([0.5 , 1.5 ])
125+ ax2 .set_yticklabels (['\' a\' core pos.' , '\' d\' core pos.' ], rotation = 0 )
124126 ax2 .set_xticks (ticks )
125- ax2 .set_xticklabels (labels )
126127 ax2 .xaxis .set_ticks_position ('none' )
127128
128- plt .tight_layout ()
129129 plt .subplots_adjust (hspace = 0 )
130130 if out_file :
131- plt .savefig (out_file , dpi = 300 )
131+ plt .savefig (out_file , dpi = dpi )
132132 plt .close ()
0 commit comments