Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if idf.opt['plotLegend']:
handles, labels = ax.get_legend_handles_labels()
if idf.opt['outputAs'] == 'html':
#TODO: show legend properly (see mpld3 bug #274)
#leg = fig.legend(handles, labels, loc='upper right', fancybox=True, fontsize=10, title='')
leg = axes[0].legend(handles, labels, loc='upper right', fancybox=True, fontsize=10, title='', prop={'size': 8})
else:
leg = plt.figlegend(handles, labels, loc='upper right', fancybox=True,
fontsize=font_size, title='', prop={'size': font_size-3})
leg.draggable()
fig.subplots_adjust(hspace=2)
fig.set_tight_layout(True)
if idf.opt['outputAs'] == 'html':
plugins.clear(fig)
plugins.connect(fig, plugins.Reset(), plugins.BoxZoom(), plugins.Zoom(enabled=False),
plugins.MousePosition(fontsize=14, fmt=".5g"))
figures.append(mpld3.fig_to_html(fig))
elif idf.opt['outputAs'] == 'interactive':
plt.show(block=False)
elif idf.opt['outputAs'] == 'pdf':
pp.savefig(plt.gcf())
elif idf.opt['outputAs'] == 'tikz':
from matplotlib2tikz import save as tikz_save
tikz_save('{}_{}_{}.tex'.format(filename,
group['dataset'][0]['title'].replace('_','-'), ds // idf.model.num_dofs),
figureheight = '\\figureheight', figurewidth = '\\figurewidth', show_info=False)
if idf.opt['outputAs'] == 'html':
path = os.path.dirname(os.path.abspath(__file__))
template_environment = Environment(autoescape=False,
_plot_event(options, event_info, fig, axes, gs, xlim)
### we only need to adapt the xoom for one axis object - as we share the x
zoom_x = [float(x) for x in options.zoom_x.split(',')]
xlim = axes[0].get_xlim()
xdiff = xlim[1] - xlim[0]
axes[0].set_xlim([xlim[0] + (zoom_x[0] * xdiff), xlim[0] + (zoom_x[1] * xdiff)])
for ax in axes:
vax.clean_axis(ax)
plt.tight_layout()
### save plot into file
if options.format == 'd3':
out_fname = os.path.join(dirname, 'plots', 'gene_overview_C%i_%s%s%s.html' % (options.confidence, gene.name, event_tag, log_tag))
plugins.clear(fig)
plugins.connect(fig, plugins.Zoom(enabled=True))
mpld3.save_html(fig, open(out_fname, 'w'))
else:
if options.test_result > 0:
out_fname = os.path.join(dirname, 'plots', 'gene_overview_C%i_%s%s%s.%s' % (options.confidence, gene.name, event_tag, log_tag, options.format))
else:
out_fname = os.path.join(dirname, 'plots', 'gene_overview_C%i_%s%s%s.%s' % (options.confidence, gene.name, event_tag, log_tag, options.format))
plt.savefig(out_fname, format=options.format, bbox_inches='tight')
plt.close(fig)
highlight_scaffold_ids : d[scaffold_id] -> color
Scaffolds in genome to highlight.
link_scaffold_ids : list of scaffold pairs
Pairs of scaffolds to link together.
mean_signature : float
Mean tetranucleotide signature of genome.
td_dist : d[length][percentile] -> critical value
TD distribution.
percentiles_to_plot : iterable
Percentile values to mark on plot.
"""
# Set size of figure
self.fig.clear()
mpld3.plugins.clear(self.fig)
mpld3.plugins.connect(self.fig, mpld3.plugins.Reset(), mpld3.plugins.BoxZoom(), mpld3.plugins.Zoom())
mpld3.plugins.connect(self.fig, mpld3.plugins.MousePosition(fontsize=12, fmt='.1f'))
self.fig.set_size_inches(self.options.width, self.options.height)
axes_hist = self.fig.add_subplot(121)
axes_scatter = self.fig.add_subplot(122)
self.plot_on_axes(self.fig,
genome_scaffold_stats,
highlight_scaffold_ids,
link_scaffold_ids,
mean_signature, td_dist, percentiles_to_plot,
axes_hist, axes_scatter, True)
self.fig.tight_layout(pad=1, w_pad=1)
gc_dist : d[gc][length][percentile] -> critical value
GC distribution.
td_dist : d[length][percentile] -> critical value
TD distribution.
gc_perc : float
GC percentile value to mark on plot.
td_perc : float
TD percentile value to mark on plot.
cov_perc : float
Mean percent deviation to mark on plot.
"""
# Set size of figure
self.fig.clear()
mpld3.plugins.clear(self.fig)
mpld3.plugins.connect(self.fig, mpld3.plugins.Reset(), mpld3.plugins.BoxZoom(), mpld3.plugins.Zoom())
mpld3.plugins.connect(self.fig, mpld3.plugins.MousePosition(fontsize=12, fmt='.1f'))
self.fig.set_size_inches(self.options.width, self.options.height)
# create subplots depending on availability of coverage information
if len(genome_stats.mean_coverage) >= 1:
# note: the ordering here is specific and ensures
# proper linked brushing
axes_gc_dist = self.fig.add_subplot(241)
axes_tetra_dist = self.fig.add_subplot(242)
axes_coverage_dist = self.fig.add_subplot(243)
axes_td_cov = self.fig.add_subplot(246)
axes_pc1_cov = self.fig.add_subplot(247)
axes_tetra_pc1_pc3 = self.fig.add_subplot(248)
axes_gc_coverage = self.fig.add_subplot(245)
@property
def fig(self):
""" Returns figure with plugins attached."""
mpld3.plugins.clear(self._fig)
for p in self._plugins.values():
if p in LABELPLUGINS:
for idx, line in enumerate(self.lines):
mpld3.plugins.connect(self._fig, p(*self.lines))
else:
mpld3.plugins.connect(self._fig, p())
# except TypeError:
# mpld3.plugins.connect(self._fig, p(*self.lines))
return self._fig
genome_scaffold_stats: d[scaffold_id] -> namedtuple of scaffold stats
Statistics for scaffolds in genome.
highlight_scaffold_ids : d[scaffold_id] -> color
Scaffolds in genome to highlight.
link_scaffold_ids : list of scaffold pairs
Pairs of scaffolds to link together.
mean_coverage : float
Mean coverage profile of genome.
cov_corrs : iterable
Coverage correlation values to mark on plot.
"""
# Set size of figure
self.fig.clear()
mpld3.plugins.clear(self.fig)
mpld3.plugins.connect(self.fig, mpld3.plugins.Reset(), mpld3.plugins.BoxZoom(), mpld3.plugins.Zoom())
mpld3.plugins.connect(self.fig, mpld3.plugins.MousePosition(fontsize=12, fmt='.1f'))
self.fig.set_size_inches(self.options.width, self.options.height)
axes_hist = self.fig.add_subplot(121)
axes_scatter = self.fig.add_subplot(122)
self.plot_on_axes(self.fig, genome_scaffold_stats,
highlight_scaffold_ids,
link_scaffold_ids,
mean_coverage, cov_corrs,
axes_hist, axes_scatter, True)
self.fig.tight_layout(pad=1, w_pad=1)
self.draw()
genome_scaffold_stats: d[scaffold_id] -> namedtuple of scaffold stats
Statistics for scaffolds in genome.
highlight_scaffold_ids : d[scaffold_id] -> color
Scaffolds in genome to highlight.
link_scaffold_ids : list of scaffold pairs
Pairs of scaffolds to link together.
mean_coverage : list of float
Mean coverage profile of genome.
cov_percs : iterable
Coverage percentile values to mark on plot.
"""
# Set size of figure
self.fig.clear()
mpld3.plugins.clear(self.fig)
mpld3.plugins.connect(self.fig, mpld3.plugins.Reset(), mpld3.plugins.BoxZoom(), mpld3.plugins.Zoom())
mpld3.plugins.connect(self.fig, mpld3.plugins.MousePosition(fontsize=12, fmt='.1f'))
self.fig.set_size_inches(self.options.width, self.options.height)
axes_hist = self.fig.add_subplot(121)
axes_scatter = self.fig.add_subplot(122)
self.plot_on_axes(self.fig, genome_scaffold_stats,
highlight_scaffold_ids,
link_scaffold_ids,
mean_coverage, cov_percs,
axes_hist, axes_scatter, True)
self.fig.tight_layout(pad=1, w_pad=1)
self.draw()
gc_dist : d[gc][length][percentile] -> critical value
GC distribution.
td_dist : d[length][percentile] -> critical value
TD distribution.
gc_perc : float
GC percentile value to mark on plot.
td_perc : float
TD percentile value to mark on plot.
cov_perc : float
Mean percent deviation to mark on plot.
"""
# Set size of figure
self.fig.clear()
mpld3.plugins.clear(self.fig)
mpld3.plugins.connect(self.fig, mpld3.plugins.Reset(), mpld3.plugins.BoxZoom(), mpld3.plugins.Zoom())
mpld3.plugins.connect(self.fig, mpld3.plugins.MousePosition(fontsize=12, fmt='.1f'))
self.fig.set_size_inches(self.options.width*(2.0/3), self.options.height)
# create subplots depending on availability of coverage information
if len(genome_stats.mean_coverage) >= 1:
axes_hist_GC = self.fig.add_subplot(321)
axes_scatter_GC = self.fig.add_subplot(322)
axes_hist_TD = self.fig.add_subplot(323)
axes_scatter_TD = self.fig.add_subplot(324)
axes_hist_cov_perc = self.fig.add_subplot(325)
axes_scatter_cov_perc = self.fig.add_subplot(326)
else:
axes_hist_GC = self.fig.add_subplot(221)
axes_scatter_GC = self.fig.add_subplot(222)
highlight_scaffold_ids : d[scaffold_id] -> color
Scaffolds in genome to highlight.
link_scaffold_ids : list of scaffold pairs
Pairs of scaffolds to link together.
mean_gc : float
Mean GC of genome.
gc_dist : d[gc][length][percentile] -> critical value
GC distribution.
percentiles_to_plot : iterable
Percentile values to mark on plot.
"""
# Set size of figure
self.fig.clear()
mpld3.plugins.clear(self.fig)
mpld3.plugins.connect(self.fig, mpld3.plugins.Reset(), mpld3.plugins.BoxZoom(), mpld3.plugins.Zoom())
mpld3.plugins.connect(self.fig, mpld3.plugins.MousePosition(fontsize=12, fmt='.1f'))
self.fig.set_size_inches(self.options.width, self.options.height)
axes_hist = self.fig.add_subplot(121)
axes_scatter = self.fig.add_subplot(122)
self.plot_on_axes(self.fig, genome_scaffold_stats,
highlight_scaffold_ids,
link_scaffold_ids,
mean_gc, gc_dist, percentiles_to_plot,
axes_hist, axes_scatter, True)
self.fig.tight_layout(pad=1, w_pad=1)
self.draw()