def make_qualimap_plots(qmglobals=None, coverage_per_contig=None): """Make qualimap summary plots""" retval = { "fig": {"coverage_per_contig": None, "globals": None}, "file": {"coverage_per_contig": coverage_per_contig, "globals": qmglobals}, "uri": {"coverage_per_contig": data_uri(coverage_per_contig), "globals": data_uri(qmglobals)}, } # Globals if qmglobals is not None: df_all = pd.read_csv(qmglobals) df_all["Sample"] = df_all["Sample"].astype("str") fig = figure( y_range=[0, max(df_all["number of reads"])], title="Mapping summary", title_text_font_size="12pt", plot_width=400, plot_height=400, x_range=sorted(list(set(df_all["Sample"]))), ) mdotplot( fig, x="Sample", size=10, df=df_all, alpha=0.5, y=["number of reads", "number of mapped reads", "number of duplicated reads", "number of unique reads"], ) xaxis(fig, axis_label="sample", major_label_orientation=np.pi / 3, axis_label_text_font_size="10pt") yaxis(fig, axis_label="count", major_label_orientation=1, axis_label_text_font_size="10pt") retval["fig"]["globals"] = fig # Coverage per contig if coverage_per_contig is not None: df_all = pd.read_csv(coverage_per_contig, index_col=0) df_all["Sample"] = df_all["Sample"].astype("str") fig = figure(width=300, height=300) points( fig, x="chrlen_percent", y="mapped_bases_percent", df=df_all, glyph="text", text="chr", text_font_size="8pt" ) main(fig, title_text_font_size="8pt") xaxis(fig, axis_label="Chromosome length of total (%)", axis_label_text_font_size="8pt") yaxis(fig, axis_label="Mapped bases of total (%)", axis_label_text_font_size="8pt") gp = facet_grid( fig, x="chrlen_percent", y="mapped_bases_percent", df=df_all, groups=["Sample"], width=300, height=300, share_x_range=True, share_y_range=True, title_text_font_size="12pt", ) for fig in [item for sublist in gp.children for item in sublist]: abline(fig, x="chrlen_percent", y="mapped_bases_percent", df=df_all, slope=1) retval["fig"]["coverage_per_contig"] = gp return retval
def test_mdotplot_title(self): mdotplot(self._fig, x="treatment", y=["x", "y"], df=self._data, size=10, alpha=0.5, title="test", title_text_font_size='12pt')
def test_mdotplot(self): mdotplot(self._fig, x="treatment", y=["y", "z"], df=self._data, color=["red", "blue"], legend=["y", "z"], size=10, alpha=0.5) output_file("tabort.html") show(self._fig)
def make_cutadapt_summary_plot(inputfile): df_summary = pd.read_csv(inputfile) df_summary["sample"] = df_summary["sample"].astype("str") TOOLS = "pan,wheel_zoom,box_zoom,box_select,reset,save" fig = figure(tools=TOOLS, width=400, height=400, x_range=sorted(list(set(df_summary["sample"]))), y_range=[0, 105], title="Cutadapt metrics", title_text_font_size='12pt') mdotplot(fig, x="sample", y=["read1_pct", "read2_pct"], df=df_summary, size=10, alpha=0.5) xaxis(fig, axis_label="sample", major_label_orientation=np.pi/3, axis_label_text_font_size='10pt') yaxis(fig, axis_label="percent reads", major_label_orientation=1, axis_label_text_font_size='10pt') return {'fig': fig, 'uri': data_uri(inputfile), 'file': inputfile}