Figure 1, indel parameters


In [4]:
from __future__ import division, print_function
%run shared_setup.ipynb
%run plotting_setup.ipynb
# %run fig_indel_size.ipynb
%run fig_indel_amino_acids.ipynb
# %run fig_indel_core_promoters.ipynb


2014-12-10 11:09:08.594012 :: 3d7_hb3
2014-12-10 11:09:29.531142 :: hb3_dd2
2014-12-10 11:09:53.478330 :: 7g8_gb4
---------------------------------------------------------------------------
LinAlgError                               Traceback (most recent call last)
<ipython-input-4-b7e987ee4a46> in <module>()
      3 fig, ax = plt.subplots(figsize=(width, height))
      4 plot_indel_aa_frequencies(ax)
----> 5 fig.tight_layout()
      6 fig.savefig('../artwork/main/fig1B.jpg', dpi=1200, jpeg_quality=100);

/home/aliman/pyenv/science/local/lib/python2.7/site-packages/matplotlib/figure.pyc in tight_layout(self, renderer, pad, h_pad, w_pad, rect)
   1652                                          renderer,
   1653                                          pad=pad, h_pad=h_pad, w_pad=w_pad,
-> 1654                                          rect=rect)
   1655 
   1656         self.subplots_adjust(**kwargs)

/home/aliman/pyenv/science/local/lib/python2.7/site-packages/matplotlib/tight_layout.pyc in get_tight_layout_figure(fig, axes_list, subplotspec_list, renderer, pad, h_pad, w_pad, rect)
    350                                      subplot_list=subplot_list,
    351                                      ax_bbox_list=ax_bbox_list,
--> 352                                      pad=pad, h_pad=h_pad, w_pad=w_pad)
    353 
    354     if rect is not None:

/home/aliman/pyenv/science/local/lib/python2.7/site-packages/matplotlib/tight_layout.pyc in auto_adjust_subplotpars(fig, renderer, nrows_ncols, num1num2_list, subplot_list, ax_bbox_list, pad, h_pad, w_pad, rect)
    129         tight_bbox_raw = union([ax.get_tightbbox(renderer) for ax in subplots])
    130         tight_bbox = TransformedBbox(tight_bbox_raw,
--> 131                                      fig.transFigure.inverted())
    132 
    133         row1, col1 = divmod(num1, cols)

/home/aliman/pyenv/science/local/lib/python2.7/site-packages/matplotlib/transforms.pyc in inverted(self)
   1686             if self._shorthand_name:
   1687                 shorthand_name = '(%s)-1' % self._shorthand_name
-> 1688             self._inverted = Affine2D(inv(mtx), shorthand_name=shorthand_name)
   1689             self._invalid = 0
   1690         return self._inverted

/home/aliman/pyenv/science/local/lib/python2.7/site-packages/numpy/linalg/linalg.pyc in inv(a)
    518     signature = 'D->D' if isComplexType(t) else 'd->d'
    519     extobj = get_linalg_error_extobj(_raise_linalgerror_singular)
--> 520     ainv = _umath_linalg.inv(a, signature=signature, extobj=extobj)
    521     return wrap(ainv.astype(result_t))
    522 

/home/aliman/pyenv/science/local/lib/python2.7/site-packages/numpy/linalg/linalg.pyc in _raise_linalgerror_singular(err, flag)
     88 
     89 def _raise_linalgerror_singular(err, flag):
---> 90     raise LinAlgError("Singular matrix")
     91 
     92 def _raise_linalgerror_nonposdef(err, flag):

LinAlgError: Singular matrix
<matplotlib.figure.Figure at 0x7f6ad80f57d0>

In [16]:
fig = plt.figure(figsize=(8, 5))

import matplotlib.gridspec as gridspec

gs = gridspec.GridSpec((2, 20))

# plot coding indel size distribution
ax = fig.add_subplot(gs[])
plot_indel_size_stacked_hist(ax, coding=True, major_step=10, minor_step=1, minsize=-33, maxsize=33)
ax.set_ylabel('coding indels')

p = plt.Rectangle((0, 0), 1, 1, fc="k")
q = plt.Rectangle((0, 0), 1, 1, fc="w")
ax.legend([p, q], ['STR', 'non-STR'], 
          ncol=2, loc='upper center', bbox_to_anchor=(0.5, -.17))

# plot non-coding indel size distribution
ax = fig.add_subplot(2, 3, 4)
plot_indel_size_stacked_hist(ax, coding=False, major_step=10, minor_step=1, minsize=-33, maxsize=33)
ax.set_xlabel('indel size')
ax.set_ylabel('non-coding indels')

# plot coding insertion mutations
ax = plt.subplot2grid((2, 3), (0, 1), rowspan=1, colspan=2)
plot_indel_aa_frequencies(ax)

# plot STR indel diversity relative to core promoters
ax = fig.add_subplot(2, 3, 5)
#plot_indel_cp_diversity(ax, is_str=True)
ax.set_title('intergenic indels (STR)')
ax.set_ylabel('diversity (bp$^{-1}$)')
ax.set_xlabel('distance to core promoter')

# plot non-STR indel diversity relative to core promoters
ax = fig.add_subplot(2, 3, 6)
#plot_indel_cp_diversity(ax, is_str=False)
ax.set_yticks([])
ax.set_ylabel('')
ax.set_title('intergenic indels (non-STR)')
ax.set_xlabel('distance to core promoter')

# tidy up
fig.tight_layout(h_pad=1.8, w_pad=1.8);

ax = fig.add_axes([0, 0, 1, 1])
ax.set_axis_off()
ax.axvline(.28, lw=1, color='k')
ax.axhline(.53, xmin=.28, xmax=1, lw=1, color='k')
ax.text(.25, .97, 'A', fontsize=12, fontweight='bold', ha='right', va='top');
ax.text(.7, .97, 'B', fontsize=12, fontweight='bold', ha='center', va='top');
ax.text(.7, .52, 'C', fontsize=12, fontweight='bold', ha='center', va='top');

fig.savefig('../artwork/main/fig_indels_lores.jpeg', jpeg_quality=100, dpi=200)



In [ ]:


In [ ]: