Example #1
0
def line(x_datas,
         y_datas,
         names=None,
         colors=None,
         xlim=(None, None),
         ylim=(None, None),
         **kwargs):
    """Create a simple line plot.

    :param x_datas: a list of datasets, each item containing the
        data for that set.
    :params y_datas: a list of weight vectors (one for each dataset).
    :param names: the name of each dataset.
    :param colors: color used to plot each dataset.
    :param xlim: tuple for plotting limits (start, end). A value None will
        trigger calculation from the data.
    :param ylim: tuple for plotting limits (start, end). A value None will
        trigger calculation from the data.
    :param kwargs: kwargs for bokeh figure.

    :returns: a bokeh plot.

    After creating this plot, you may wish to change the following:

        * p.xaxis.axis_label
        * p.yaxis.axis_label
    """
    return simple(x_datas,
                  y_datas,
                  names=names,
                  colors=colors,
                  xlim=xlim,
                  ylim=ylim,
                  style='line',
                  **kwargs)
Example #2
0
    def dotplot_assembly(self, assembly_maf):
        """Dotplot the assembly."""
        records = list()
        with open(assembly_maf) as maf:
            while True:
                line = maf.readline()
                print(line)
                if line.startswith('#'):
                    continue
                elif line.startswith('a'):
                    r1 = maf.readline().split()[1:5]
                    r2 = maf.readline().split()[1:5]
                    maf.readline()
                    records.append(r1 + r2)
                elif line == "":
                    break
                else:
                    print(line)
                    raise IOError("Cannot read alignment file")

        names = [
            'ref', 'rstart', 'rlen', 'rorient', 'query', 'qstart', 'qlen',
            'qorient'
        ]
        df = pd.DataFrame(records, columns=names)
        df = df.loc[df['qorient'] == '+']
        for f in ['qstart', 'qlen', 'rstart', 'rlen']:
            df[f] = df[f].astype(int)
        df['qend'] = df['qstart'] + df['qlen']
        df['rend'] = df['rstart'] + df['rlen']

        df['qend'] = df['qend'].astype(int)
        df['rend'] = df['rend'].astype(int)
        dotplot = base.simple([], [],
                              xlim=(0, max(df['rend'])),
                              ylim=(0, max(df['qend'])),
                              width=440,
                              height=400,
                              x_axis_label='position',
                              y_axis_label='position',
                              title=assembly_maf)
        dotplot.segment(df['rstart'], df['qstart'], df['rend'], df['qend'])
        return dotplot
Example #3
0
def steps(x_datas,
          y_datas,
          names=None,
          colors=None,
          xlim=(None, None),
          ylim=(None, None),
          mode='before',
          **kwargs):
    """Create a simple step-line plot.

    :param x_datas: a list of datasets, each item containing the
        data for that set.
    :params y_datas: a list of weight vectors (one for each dataset).
    :param names: the name of each dataset.
    :param colors: color used to plot each dataset.
    :param xlim: tuple for plotting limits (start, end). A value None will
        trigger calculation from the data.
    :param ylim: tuple for plotting limits (start, end). A value None will
        trigger calculation from the data.
    :param mode: one of 'before', 'center', 'after' indicating where the step
        (change in y value) should be placed.
    :param kwargs: kwargs for bokeh figure.

    :returns: a bokeh plot.

    After creating this plot, you may wish to change the following:

        * p.xaxis.axis_label
        * p.yaxis.axis_label
    """
    return simple(x_datas,
                  y_datas,
                  names=names,
                  colors=colors,
                  xlim=xlim,
                  ylim=ylim,
                  mode=mode,
                  style='steps',
                  **kwargs)