コード例 #1
0
ファイル: qualimap.py プロジェクト: jfear/snakemakelib
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
コード例 #2
0
ファイル: picard.py プロジェクト: jfear/snakemakelib
    def facet_grid_hist(self, **kwargs):
        """facet_grid hist wrapper.

        Returns:
          plist (list): list of bokeh plot objects
        """
        kwargs.update(self.kw)
        f = figure(**kwargs['figure'])
        mlines(f, df=self, **kwargs['renderer'])
        gp = facet_grid(f, df=self, ncol=self.ncol,
                        **kwargs['facet'])
        plist = [x for sublist in gp.children for x in sublist]
        return plist
コード例 #3
0
ファイル: test_facet.py プロジェクト: percyfal/bokehutils
 def test_init_groups(self):
     self._fig.line("x", "y", legend="y", source=self._source)
     self._fig.line("x", "z", legend="z", source=self._source, color="red")
     gp = facet_grid(self._fig, "x", ["y", "z"], self._data, groups=["sex"])
コード例 #4
0
ファイル: test_facet.py プロジェクト: percyfal/bokehutils
 def test_init(self):
     self._fig.circle("x", "y", source=self._source)
     facet_grid(self._fig, "x", "y", source=self._source)
コード例 #5
0
 def test_init_groups(self):
     self._fig.line("x", "y", legend="y", source=self._source)
     self._fig.line("x", "z", legend="z", source=self._source, color="red")
     gp = facet_grid(self._fig, "x", ["y", "z"], self._data, groups=["sex"])
コード例 #6
0
 def test_init(self):
     self._fig.circle("x", "y", source=self._source)
     facet_grid(self._fig, "x", "y", source=self._source)