Пример #1
0
class HistPlotTheme(PlotTheme):
    "cycles & peaks plot theme: histogram"
    name = "cyclehist.plot.hist"
    figsize = (
        AppTheme().appsize[0] - CyclePlotTheme.figsize[0],  # pylint: disable=unsubscriptable-object
        *CyclePlotTheme.figsize[1:])
    xlabel = PeaksPlotTheme.xlabel
    ylabel = CyclePlotTheme.ylabel
    explabel = 'Hybridisations'
    reflabel = 'Hairpin'
    formats = {'bases': '0.0a', 'ref': '0', 'exp': '0.0'}
    hist = deepcopy(PeaksPlotTheme.count)
    events = PlotAttrs(hist.color,
                       'o',
                       4,
                       alpha=.25,
                       selection_alpha=1.,
                       selection_color='~green')
    peaks = PlotAttrs(hist.color, '△', 5, alpha=0., angle=np.pi / 2.)
    pkcolors = deepcopy(PeaksPlotTheme.pkcolors)
    minzoomz: Optional[float] = .008 / .88e-3
    toolbar = dict(CyclePlotTheme.toolbar)
    toolbar['items'] = 'pan,box_zoom,wheel_zoom,hover,reset,save'
    tooltipmode = 'hline'
    tooltippolicy = 'follow_mouse'
    tooltips = [(i[1], '@' + i[0] + ("{" + i[2] + "}" if i[2] else ""))
                for i in PeakListTheme().columns[1:-1]]

    @initdefaults(frozenset(locals()))
    def __init__(self, **_):
        super().__init__(**_)
Пример #2
0
class CyclesPlotTheme(PlotTheme):
    "theme for cycles"
    name = "cycles.plot"
    raw = PlotAttrs('color',
                    'o',
                    .1,
                    alpha=.5,
                    palette={
                        'dark': 'YlOrBr',
                        'basic': 'inferno'
                    })
    selection = {
        'dark': PlotAttrs('lightblue', 'line', 3),
        'basic': PlotAttrs('blue', 'line', 3)
    }
    tooltips = [('(cycle, t, z)', '(@cycle, $~x{1}, $data_y{1.1111})')]
    radius = 1.
    histframes = PlotAttrs('~gray', '┸', 1, fill_color='gray')
    histcycles = PlotAttrs('~blue', '┸', 1, fill_color=None, line_alpha=.5)
    histxtoplabel = 'Cycles'
    histxlabel = 'Frames'
    figsize = PlotTheme.defaultfigsize(450, 450)
    toolbar = dict(PlotTheme.toolbar)
    toolbar.update(raw='tap,ypan,ybox_zoom,reset,save,dpxhover',
                   items='ypan,ybox_zoom,reset,save')

    @initdefaults(frozenset(locals()))
    def __init__(self, **kwa):
        super().__init__(**kwa)
Пример #3
0
class DriftControlPlotTheme(PlotTheme):
    "drift control plot theme"
    name = "qc.driftcontrol.plot"
    measures = PlotAttrs('', '-', 2, alpha=.75)
    median = PlotAttrs('', '-', 2, line_dash='dashed')
    pop10 = PlotAttrs('', '-', 2, line_dash=[4])
    pop90 = PlotAttrs('', '-', 2, line_dash=[4])
    colors = dict(dark=dict(measures='lightblue',
                            median='lightgreen',
                            pop10='lightgreen',
                            pop90='lightgreen'),
                  basic=dict(measures='darkblue',
                             median='darkgreen',
                             pop10='darkgreen',
                             pop90='darkgreen'))
    figsize = PlotTheme.defaultfigsize(300, 150)
    outlinewidth = 7
    outlinecolor = 'red'
    outlinealpha = .5
    ylabel = ''
    xlabel = 'Cycles'
    toolbar = dict(PlotTheme.toolbar)
    toolbar['items'] = 'pan,box_zoom,reset,save'

    @initdefaults(frozenset(locals()))
    def __init__(self, **_):
        super().__init__(**_)
Пример #4
0
class PeaksPlotTheme(PlotTheme):
    """
    peaks plot theme
    """
    name = "hybridstat.peaks.plot"
    figsize = PlotTheme.defaultfigsize(300, 500)
    xtoplabel = 'Duration (s)'
    xlabel = 'Rate (%)'
    fiterror = "Fit unsuccessful!"
    ntitles = 4
    count = PlotAttrs('~blue', '-', 1)
    eventscount = PlotAttrs(count.color, 'o', 3)
    peakscount = PlotAttrs(count.color,
                           '△',
                           15,
                           fill_alpha=0.5,
                           angle=np.pi / 2.)
    referencecount = PlotAttrs('bisque', 'patch', alpha=0.5)
    peaksduration = PlotAttrs('~green',
                              '◇',
                              15,
                              fill_alpha=0.5,
                              angle=np.pi / 2.)
    pkcolors = dict(dark=dict(reference='bisque', missing='red',
                              found='black'),
                    basic=dict(reference='bisque', missing='red',
                               found='gray'))
    toolbar = dict(PlotTheme.toolbar)
    toolbar['items'] = 'ypan,ybox_zoom,ywheel_zoom,reset,save,tap'

    @initdefaults(frozenset(locals()))
    def __init__(self, **_):
        super().__init__(**_)
Пример #5
0
class HairpinGroupScatterTheme(PlotTheme):
    "grouped beads plot theme"
    name = "hairpingroup.plot"
    figsize = PlotTheme.defaultfigsize(500, 300)
    xlabel = 'Bead'
    ylabel = 'Bases'
    reflabel = 'Hairpin'
    xgridalpha = 0.
    ntitles = 5
    format = '0.0'
    events = PlotAttrs('~gray', 'o', 3, alpha=.5)
    peaks = PlotAttrs('~blue', 'o', 10, line_alpha=1., fill_alpha=.0)
    hpin = PlotAttrs('color', '+', 15, alpha=1., line_width=2)
    pkcolors = {
        'dark': {
            'missing': 'red',
            'found': 'lightgreen'
        },
        'basic': {
            'missing': 'red',
            'found': 'darkgreen'
        }
    }
    toolbar = dict(PlotTheme.toolbar)
    toolbar['items'] = 'pan,box_zoom,reset,save,hover,box_select'
    tooltipmode = 'mouse'
    tooltippolicy = 'follow_mouse'
    tooltips = [('Bead', '@bead'), ('Z (base)', '@bases'),
                ('Ref (base)', '@id'), (PeaksPlotTheme.xlabel, '@count{0.0}'),
                (PeaksPlotTheme.xtoplabel, '@duration{0.000}')]
    displaytimeout = .5

    @initdefaults(frozenset(locals()))
    def __init__(self, **_):
        super().__init__(**_)
Пример #6
0
class ExtensionPlotTheme(DriftControlPlotTheme):
    "drift control plot theme"
    name = "qc.extension.plot"
    ylabel = 'δ(Φ3-Φ1) (µm)'
    measures = PlotAttrs('', 'o', 2, alpha=.75)
    ybars = PlotAttrs('', 'vbar', 1, alpha=.75)
    ymed = PlotAttrs('', 'vbar', 1, fill_alpha=0.)
    colors = dict(DriftControlPlotTheme.colors)
    colors['dark'].update(ybars='lightblue', ymed='lightblue')
    colors['basic'].update(ybars='darkblue', ymed='darkblue')
    ybarswidth = .8

    @initdefaults(frozenset(locals()))
    def __init__(self, **_):
        super().__init__(**_)
Пример #7
0
class ConsensusScatterTheme(PlotTheme):
    "scatter plot of durations & rates thee"
    name = "consensus.plot.scatter"
    figsize = PlotTheme.defaultfigsize(300, 300)
    xlabel = PeaksPlotTheme.xlabel
    ylabel = PeaksPlotTheme.xtoplabel
    reflabel = 'Hairpin'
    format = '0.0'
    peaks = PlotAttrs('color', '+', 10, line_alpha=1., fill_alpha=.0)
    pkcolors = {
        'dark': {
            'missing': 'red',
            'found': 'lightgreen'
        },
        'basic': {
            'missing': 'red',
            'found': 'darkgreen'
        }
    }
    toolbar = dict(PlotTheme.toolbar)
    toolbar['items'] = 'pan,box_zoom,reset,save,hover,box_select'
    tooltipmode = 'mouse'
    tooltippolicy = 'follow_mouse'
    tooltips = [('Bead', '@bead'), ('Z (base)', '@bases'),
                ('Strand', '@orient'), (PeaksPlotTheme.xlabel, '@rate{0.0}'),
                (PeaksPlotTheme.xtoplabel, '@duration{0.000}')]

    @initdefaults(frozenset(locals()))
    def __init__(self, **_):
        super().__init__(**_)
Пример #8
0
class FoVPlotTheme(PlotTheme):
    "FoV plot theme"
    name = "fov"
    beads = PlotAttrs('color',
                      'o',
                      alpha=.7,
                      nonselection_alpha=.7,
                      selection_alpha=.7,
                      nonselection_color='color',
                      selection_fill_color='color')
    text = PlotAttrs('color',
                     'text',
                     text_font_style='bold',
                     nonselection_alpha=1.,
                     nonselection_text_color="color",
                     selection_alpha=1.,
                     selection_text_color='blue')
    image = PlotAttrs('Greys256', 'image', x=0, y=0)
    radius = 1.
    figsize = PlotTheme.defaultfigsize(160 * 5, 100 * 5)
    calibfigsize = PlotTheme.defaultfigsize(256, 192)
    ylabel = 'Y (μm)'
    xlabel = 'X (μm)'
    colors = dict(ok='palegreen',
                  fixed='chocolate',
                  bad='orange',
                  discarded='red',
                  missing='magenta')
    thumbnail = 128
    calibimg = PlotAttrs('Greys256', 'image', x=0, y=0)
    calibsize = 6. / 16
    tooltips = '<table>@ttips{safe}</table>'
    tooltiptype = dict(NAMES)
    tooltiprow = ('<tr>' + '<td>{cycle}</td><td>cycle{plural} with:</td>' +
                  '<td>{type}</td><td>{message}</td>' + '</tr>')
    tooltipok = ('<tr><td><td><td>σ[HF] =</td><td>{:.4f}</td></tr>'
                 '<tr><td><td><td>Δz    =</td><td>{:.2f}</td></tr>')
    toolbar = dict(PlotTheme.toolbar)
    toolbar['items'] = 'pan,box_zoom,reset,tap,save,hover'

    @initdefaults(frozenset(locals()))
    def __init__(self, **_):
        super().__init__(**_)
Пример #9
0
class CyclePlotTheme(PlotTheme):
    "cycles & peaks plot theme: cycles"
    name: str = "cyclehist.plot.cycle"
    figsize: Tuple[int, int, str] = (300, 497, 'fixed')
    phasezoom: int = 20
    fiterror: str = PeaksPlotTheme.fiterror
    xlabel: str = PlotTheme.xtoplabel
    ylabel: str = PlotTheme.yrightlabel
    ntitles: int = 5
    format: str = '0.0a'
    frames: PlotAttrs = PlotAttrs('~gray', '-', 1., alpha=.25)
    points: PlotAttrs = PlotAttrs(deepcopy(PeaksPlotTheme.count.color),
                                  'o',
                                  1,
                                  alpha=.5)
    toolbar: Dict[str, Any] = dict(PlotTheme.toolbar,
                                   items='pan,box_zoom,wheel_zoom,reset,save')

    @initdefaults(frozenset(locals()))
    def __init__(self, **_):
        super().__init__(**_)
Пример #10
0
class RampPlotTheme(PlotTheme):
    """
    ramp plot theme
    """
    name = "ramp.theme"
    consensusarea = PlotAttrs('~gray', 'patch', 1, alpha=.5)
    consensusline = PlotAttrs(consensusarea.color, 'line', 1, alpha=.5)
    beadarea = PlotAttrs('~blue', 'patch', 1, alpha=.5)
    beadline = PlotAttrs(beadarea.color, 'line', 1, alpha=.5)
    beadcycles = PlotAttrs(beadarea.color, 'line', 1, alpha=.5)
    frames = PlotAttrs("phase", 'o', 5, alpha=.25)
    phases = ['lightblue'] * 5 + ['darkgreen'] * 4
    phaserange = (..., ...)
    ylabelnormalized = "Z (% strand size)"
    xlabel = 'Z magnet (mm)'
    figsize = PlotTheme.defaultfigsize(300, 500)
    widgetwidth = 500
    dataformat = "raw"
    clip = 99., .1
    toolbar = dict(PlotTheme.toolbar)
    toolbar['items'] = 'pan,box_zoom,reset,save'

    @initdefaults(frozenset(locals()))
    def __init__(self, **_):
        super().__init__(**_)
Пример #11
0
class CleaningPlotTheme(PlotTheme):
    """
    cleaning plot theme
    """
    name: str = "cleaning.theme"
    lines: PlotAttrs = PlotAttrs('~gray', '-', 1, alpha=.3)
    points: PlotAttrs = PlotAttrs('color', 'o', 1, alpha=.5)
    hover: PlotAttrs = PlotAttrs('white', 'o', 4, alpha=0.)
    figsize: Tuple[int, int, str] = PlotTheme.defaultfigsize(300, 500)
    clip: int = 3
    clipovershoot: float = 10
    maxfixedbeads: int = 15
    widgetwidth: int = 535
    ntitles: int = 5
    order: Tuple[str, ...] = ('aberrant', 'hfsigma', 'extent', 'population',
                              'pingpong', 'alignment', 'clipping',
                              'saturation', 'good')
    colors: Dict[str, str] = dict(
        good='#6baed6',  # blue
        hfsigma='gold',
        extent='orange',
        population='hotpink',
        pingpong='firebrick',
        saturation='chocolate',
        alignment='darkgray',
        clipping='darkorchid',
        aberrant='red')
    tooltips: List[Tuple[str, ...]] = [
        ('(cycle, t, z, status)', '(@cycle, $~x{1}, $data_y{1.1111}, @status)')
    ]
    toolbar: Dict[str, Any] = dict(
        PlotTheme.toolbar,
        items='pan,box_zoom,ypan,ybox_zoom,ywheel_zoom,reset,save,dpxhover')

    @initdefaults(frozenset(locals()))
    def __init__(self, **_):
        super().__init__(**_)
Пример #12
0
class HairpinGroupHistTheme(PlotTheme):
    "grouped beads plot theme"
    name = "hairpingroup.plot.hist"
    figsize = PlotTheme.defaultfigsize(300, 300)
    xdata = "duration"
    binsize = .1
    xlabel = PeaksPlotTheme.xtoplabel
    ylabel = 'Density'
    hist = PlotAttrs('~gray', '┸', 1, fill_color='gray')
    toolbar = dict(PlotTheme.toolbar)
    toolbar['items'] = 'pan,box_zoom,reset,save'

    @initdefaults(frozenset(locals()))
    def __init__(self, **_):
        super().__init__(**_)
Пример #13
0
class BeadsScatterPlotConfig(BasePlotConfig):
    "Information about the current fovs displayed"
    name: str = NAME
    sorting: Set[str] = field(
        default_factory=lambda: {'hairpin', 'track', 'bead'})
    figargs: Dict[str, Any] = field(default_factory=lambda: dict(
        toolbar_sticky=False,
        toolbar_location='above',
        tools=['pan,wheel_zoom,box_zoom,save,reset,hover'],
        plot_width=1000,
        plot_height=600,
        sizing_mode=defaultfigsize()[-1],
        x_axis_label='bead'))
    yaxis: Tuple[str, str] = ("postions (base pairs = {:.2f} nm⁻¹)",
                              "positions (base pairs)")

    datacolumns: List[str] = field(default_factory=lambda: [
        'hybridisationrate', 'averageduration', 'blockageresolution',
        'baseposition', 'peakposition', 'status', 'distance', 'closest',
        'orientation', 'hairpin'
    ])

    tooltipcolumns: List[Tuple[str, str]] = field(
        default_factory=lambda: [(getcolumn(i).label if i != 'baseposition'
                                  else 'z (bp)', f'@{i}') for i in (
                                      'hybridisationrate',
                                      'averageduration',
                                      'blockageresolution',
                                      'status',
                                      'distance',
                                      'closest',
                                      'orientation',
                                  )])

    events: PlotAttrs = field(default_factory=lambda: PlotAttrs(
        '',
        'oval',
        fill_color='~gray',
        fill_alpha=.5,
        line_alpha=1.,
        line_width=2.,
        line_color='color',
        x='x',
        y='baseposition',
        width='hybridisationrate',
        height='blockageresolution',
    ))
    blockages: PlotAttrs = field(default_factory=lambda: PlotAttrs(
        'color',
        'o',
        10,
        x='x',
        y='baseposition',
        fill_alpha=0.,
        line_alpha=0.,
    ))
    bindings: PlotAttrs = field(default_factory=lambda: PlotAttrs(
        'color', 'x', 10, x='x', y='bindingposition', alpha=.8))
    colors: Dict[str, str] = field(
        default_factory=lambda: {
            "truepos": "lightgreen",
            "falsepos": "red",
            "falseneg": "red",
            "baseline": "dpxblue",
            "< baseline": "dpxblue",
            "singlestrand": "dpxblue",
            "> singlestrand": "dpxblue",
            "": "lightgreen"
        })
    order: Dict[str, int] = field(
        default_factory=lambda: {
            j: i
            for i, j in enumerate(
                ("baseline", "< baseline", "singlestrand", "> singlestrand",
                 "", "truepos", "falsepos", "falseneg"))
        })
Пример #14
0
class FoVStatsPlotConfig(BasePlotConfig):
    "Information about the current fovs displayed"
    name: str = NAME
    linear: bool = True
    refagg: str = 'median'
    yaxisnorm: YAxisNorm = field(
        default_factory=lambda: ("status", ["", "truepos"]))
    binnedz: BinnedZ = field(default_factory=BinnedZ)
    binnedbp: BinnedZ = field(default_factory=lambda: BinnedZ(10, 10, 0))
    xinfo: List[AxisConfig] = field(
        default_factory=lambda:
        [AxisConfig('track'), AxisConfig('beadstatus')])
    yaxis: str = 'bead'
    xaxistag: Dict[str, str] = field(
        default_factory=lambda:
        {i.key: str(i.label)
         for i in COLS if (i.axis == 'x') and i.label})
    yaxistag: Dict[str, str] = field(
        default_factory=lambda:
        {i.key: str(i.label)
         for i in COLS if (i.axis == 'y') and i.label})
    orientationtag: Dict[str, str] = field(default_factory=lambda: {
        "+": "+",
        "-": INVISIBLE + "-",
        "": INVISIBLE * 2 + '?'
    })

    uselabelcolors: bool = True
    defaultcolors: str = 'Blues'
    orientationcolor: Dict[str, str] = field(default_factory=lambda: {
        "+": "lightgreen",
        "-": "dpxblue"
    })
    statuscolor: Dict[str, str] = field(
        default_factory=lambda: {
            "< baseline": f"dpxblue",
            "baseline": f"dpxblue",
            "truepos": f"lightgreen",
            "falseneg": f"red",
            "falsepos": f"red",
            "": f"green",
            "singlestrand": f"dpxblue",
            "> singlestrand": f"dpxblue",
        })
    beadstatuscolor: Dict[str, str] = field(
        default_factory=lambda: {
            "ok": "lightgreen",
            **dict.fromkeys(("empty", "bug", "unknown"), "red"),
            **dict.fromkeys(_ExceptionNames.keys(), "red")
        })
    spread: float = 1.5
    toplabel: Tuple[str, str] = ('Bead count', 'Bead / Blockage count')
    toptick: Tuple[str, str] = ('{}', '{}/{}')
    figargs: Dict[str, Any] = field(default_factory=lambda: dict(
        toolbar_sticky=False,
        toolbar_location='above',
        tools=['pan,wheel_zoom,box_zoom,save,reset,hover'],
        plot_width=900,
        plot_height=400,
        sizing_mode=defaultfigsize()[-1],
    ))
    pointstips: List[Tuple[str, str]] = field(default_factory=lambda: [
        ("track", "@track"),
        ("bead", "@bead"),
        ("y", "$y"),
    ])
    boxtips: List[Tuple[str, str]] = field(default_factory=lambda: [
        ("x", "@xv"),
        ("y", "@yv"),
    ])
    box: PlotAttrs = field(default_factory=lambda: PlotAttrs(
        '',
        'rect',
        fill_color='color',
        line_color='color',
        x='x',
        y=f'boxcenter',
        width=.9,
        height=f'boxheight',
    ))
    vertices: PlotAttrs = field(default_factory=lambda: PlotAttrs(
        '',
        'segment',
        line_color='dpxblue',
        line_width=2,
        x0='x',
        x1='x',
        y0=f'bottom',
        y1=f'top',
    ))
    median: PlotAttrs = field(default_factory=lambda: PlotAttrs(
        '',
        'rect',
        fill_color='black',
        line_color='black',
        x='x',
        y='median',
        height=.00001,
        line_width=1,
        width=.9,
    ))
    bars: PlotAttrs = field(default_factory=lambda: PlotAttrs(
        '',
        'rect',
        fill_color='dpxblue',
        line_color='dpxblue',
        x='x',
        height=.00001,
        line_width=3,
        width=.5,
    ))
    points: PlotAttrs = field(default_factory=lambda: PlotAttrs(
        '~gray', 'circle', x='x', y='y', size=10))

    @property
    def xaxis(self) -> List[str]:
        "return x-axis names"
        return [i.name for i in self.xinfo]

    def getxaxisinfo(self, attr: str, xaxis: List[Union[str,
                                                        AxisConfig]]) -> list:
        "x axis info"
        vals = {getattr(j, 'name', j): i for i, j in enumerate(xaxis)}
        return sorted(vals[i.name] for i in self.xinfo
                      if i.name in vals and getattr(i, attr))
Пример #15
0
class StatsPlotSelectorTheme:
    "theme for beads plot"
    points: PlotAttrs = field(default_factory=lambda: PlotAttrs(
        '#fdae6b', 'x', x='x', y='y', size=10, line_width=2))