Example #1
0
def make_field_chooser(x, xs, y, ys):
    """Choose values for x and y.
    """
    xd = Dropdown(description='%s:' % x, values=xs)
    yd = Dropdown(description='%s:' % y, values=ys)
    container = VBox(children=[xd, yd])
    return container
Example #2
0
    def naeem_panel(self):

        plott = Dropdown(description="Corr Plot",
                         values=[
                             'sync', 'async', 'phase', 'modulous',
                             'sync_codist', 'async_codist'
                         ])
        link((self.model, "plottype"), (plott, "value"))

        plot_3d = Dropdown(description="Kind",
                           values=['corr2d', 'corr3d', 'contour3d'])
        link((self.model, "plot3d"), (plot_3d, "value"))

        scale_a = FloatSlider(description="Scale Start")

        scale_b = FloatSlider(description="Scale End")

        scalecheck = Checkbox(description="Scalling")
        link((self.model, "scalebox"), (scalecheck, "value"))

        cfill = Checkbox(description="Fill")
        link((self.model, "fill"), (cfill, "value"))

        return ControlPanel(
            title="NAEEM KHAN",
            children=[plott, plot_3d, scalecheck, scale_a, scale_b, cfill])
Example #3
0
def _widget_abbrev(o):
    """Make widgets from abbreviations: single values, lists or tuples."""
    float_or_int = (float, int)
    if isinstance(o, (list, tuple)):
        if o and all(isinstance(x, string_types) for x in o):
            return Dropdown(options=[unicode_type(k) for k in o])
        elif _matches(o, (float_or_int, float_or_int)):
            min, max, value = _get_min_max_value(o[0], o[1])
            if all(isinstance(_, int) for _ in o):
                cls = IntSlider
            else:
                cls = FloatSlider
            return cls(value=value, min=min, max=max)
        elif _matches(o, (float_or_int, float_or_int, float_or_int)):
            step = o[2]
            if step <= 0:
                raise ValueError("step must be >= 0, not %r" % step)
            min, max, value = _get_min_max_value(o[0], o[1], step=step)
            if all(isinstance(_, int) for _ in o):
                cls = IntSlider
            else:
                cls = FloatSlider
            return cls(value=value, min=min, max=max, step=step)
    else:
        return _widget_abbrev_single_value(o)
Example #4
0
    def __init__(self,
                 data,
                 model=None,
                 all_models=None,
                 axes_style={},
                 data_style={},
                 init_style={},
                 best_style={},
                 **kwargs):
        # Dropdown menu of all subclasses of Model, incl. user-defined.
        self.models_menu = Dropdown()
        # Dropbox API is very different between IPy 2.x and 3.x.
        if IPY2:
            if all_models is None:
                all_models = {m.__name__: m for m in Model.__subclasses__()}
            self.models_menu.values = all_models
        else:
            if all_models is None:
                all_models = [(m.__name__, m) for m in Model.__subclasses__()]
            self.models_menu.options = all_models
        self.models_menu.on_trait_change(self._on_model_value_change, 'value')
        # Button to trigger fitting.
        self.fit_button = Button(description='Fit')
        self.fit_button.on_click(self._on_fit_button_click)

        # Button to trigger guessing.
        self.guess_button = Button(description='Auto-Guess')
        self.guess_button.on_click(self._on_guess_button_click)

        # Parameter widgets are not built here. They are (re-)built when
        # the model is (re-)set.
        super(NotebookFitter,
              self).__init__(data, model, axes_style, data_style, init_style,
                             best_style, **kwargs)
Example #5
0
    def unit_panel(self):
        # create spectrum controls.  NOTE: should only be called once.
        specunit = Dropdown(description="Specunit",
                            values=self.model.SPECUNITS.values())
        link((self.model, "spec_unit"), (specunit, "value"))

        varunit = Dropdown(description="Varunit",
                           values=self.model.VARUNITS.values())
        link((self.model, "var_unit"), (varunit, "value"))

        iunit = Text(description="I Unit", values=self.model.iunit)
        link((self.model, "iunit"), (iunit, "value"))

        normunit = Dropdown(description="Normunit",
                            values=self.model.NORMUNITS.values())
        link((self.model, "norm_unit"), (normunit, "value"))

        return ControlPanel(title="Units",
                            children=[normunit, specunit, varunit, iunit])
Example #6
0
    def display_on_map(self, map_name=None):
        color_scales = {
            "gimme_fluxes":         [dict(type='min', color="yellow", size=20),
                                     dict(type='value', value=0, color="green", size=7),
                                     dict(type='max', color='blue', size=20)],
            "expression":           [dict(type='value', value=log_plus_one(self.cutoff), color="green", size=10),
                                     dict(type='max', color='blue', size=20),
                                     dict(type='min', color='yellow', size=5)],
            "inconsistency_scores": [dict(type='value', value=0, color="yellow", size=10),
                                     dict(type='max', color='green', size=20)]
        }

        normalization_functions = {
            "gimme_fluxes": float,
            "expression": float,
            "inconsistency_scores": float
        }

        viewer = EscherViewer(self.data_frame, map_name, color_scales, normalization_functions)
        drop_down = Dropdown()
        drop_down.options = {
            "Fluxes": "gimme_fluxes",
            "Expression": "expression",
            "Inconsistency Score": "inconsistency_scores"
        }
        drop_down.default_value = "gimme_fluxes"
        drop_down.on_trait_change(lambda x: viewer(drop_down.get_state("value")["value"]))
        display(drop_down)
        viewer("gimme_fluxes")
Example #7
0
def make_aggregator(xs, ys):
    dx = Dropdown(description='"X" Axis',
                  values=OrderedDict((describe_field(x), x) for x in xs))
    dy = Dropdown(description='"Y" Axis',
                  values=OrderedDict((describe_field(y), y) for y in ys))
    dx.value = 'perspective'
    dy.value = 'source-schemafamilies'
    c = HBox(children=(dx, dy))
    return c
Example #8
0
def _widget_abbrev_single_value(o):
    """Make widgets from single values, which can be used as parameter defaults."""
    if isinstance(o, string_types):
        return Text(value=unicode_type(o))
    elif isinstance(o, dict):
        return Dropdown(options=o)
    elif isinstance(o, bool):
        return Checkbox(value=o)
    elif isinstance(o, float):
        min, max, value = _get_min_max_value(None, None, o)
        return FloatSlider(value=o, min=min, max=max)
    elif isinstance(o, int):
        min, max, value = _get_min_max_value(None, None, o)
        return IntSlider(value=o, min=min, max=max)
    else:
        return None
Example #9
0
    def display_on_map(self, map_name):
        color_scales = {
            "fluxes_%s" % self._a_key: [dict(type='min', color="yellow", size=20),
                                        dict(type='value', value=0, color="blue", size=7),
                                        dict(type='max', color='green', size=20)],
            "fluxes_%s" % self._b_key: [dict(type='min', color="yellow", size=20),
                                        dict(type='value', value=0, color="blue", size=7),
                                        dict(type='max', color='green', size=20)],
            "manhattan_distance":      [dict(type='min', color="yellow", size=20),
                                        dict(type='value', value=0, color="blue", size=7),
                                        dict(type='max', color='green', size=20)],
            "euclidean_distance":      [dict(type='min', color="yellow", size=20),
                                        dict(type='value', value=0, color="blue", size=7),
                                        dict(type='max', color='green', size=20)],
            "activity_profile":        [dict(type='value', value=-1, color="yellow", size=10),
                                        dict(type='value', value=0, color="green", size=10),
                                        dict(type='value', value=1, color='blue', size=10)],
            "fold_change":             [dict(type='min', color="yellow", size=20),
                                        dict(type='value', value=0, color="blue", size=7),
                                        dict(type='max', color='green', size=20)]
        }

        normalization_functions = {
            "fluxes_%s" % self._a_key: float,
            "fluxes_%s" % self._b_key: float,
            "manhattan_distance": float,
            "euclidean_distance": float,
            "activity_profile": int,
            "fold_change": np.log2
        }

        viewer = EscherViewer(self.data_frame, map_name, color_scales, normalization_functions)
        drop_down = Dropdown()
        drop_down.options = OrderedDict({
            "Flux Distribution %s" % self._a_key: "fluxes_%s" % self._a_key,
            "Flux Distribution %s" % self._b_key: "fluxes_%s" % self._b_key,
            "Manhattan Distance": "manhattan_distance",
            "Euclidean Distance": "euclidean_distance",
            "Activity Profile": "activity_profile",
            "log2 Fold Change": "fold_change"
        })
        drop_down.default_value = "fluxes_%s" % self._a_key
        drop_down.on_trait_change(lambda x: viewer(drop_down.get_state("value")["value"]))
        display(drop_down)
        viewer("fluxes_%s" % self._a_key)
Example #10
0
    def plot_panel(self):
        # create draw mode controls.  NOTE: should only be called once.
        cbar = Checkbox(description="Colorbar")
        link((self.model, "colorbar"), (cbar, "value"))

        interact = Checkbox(description="Interactive")
        link((self.model, "interactive"), (interact, "value"))

        plug_select = Checkbox(description="Line Selection")
        link((self.model, "selectlines"), (plug_select, "value"))

        autoupdate = Checkbox(description="Auto Update")
        link((self.model, "autoupdate"), (autoupdate, "value"))

        plugin2 = Checkbox(description='Cursor')
        plugin3 = Checkbox(description='plugin3')
        fwidth = FloatText(description='Plot width')
        fheight = FloatText(description='Plot height')
        link((self.model, "figwidth"), (fwidth, "value"))
        link((self.model, "figheight"), (fheight, "value"))

        f = Text(description="Function:")
        link((self.model, "user_f"), (f, "value"))
        fapp = Button(color='black',
                      background_color='AliceBlue',
                      description="Apply")
        fapp.on_click(lambda x: self.model.apply_userf(name='apply clicked'))

        #plugins = HBox([plugin1,plugin2,plugin3])
        #more = Checkbox(description="More Options")### LINK IT
        #link((self, "moreopt"), (more, "value"))
        #popmore = Popup(children=[VBox([HBox([plug_select,plugin2,plugin3]),
        #                                HBox([f,fapp]),
        #                                VBox([fwidth, fheight])
        #                              ])],
        #                description='Advanced', button_text='Advanced')

        more = Checkbox(description="Advanced")
        link((self.model, "advancedbox"), (more, "value"))

        popmore = VBox([
            HBox([
                plug_select,
                plugin2,
                #		plugin3
            ]),
            HBox([f, fapp]),
            HBox([fwidth, fheight])
        ])
        link((self.model, "advancedbox"), (popmore, "visible"))

        cmapcheck = Checkbox(description="Colormap")
        link((self.model, "cmapbox"), (cmapcheck, "value"))

        cmap = Dropdown(description="Colormap", values=self.model.COLORMAPS)
        link((self.model, "colormap"), (cmap, "value"))
        link((self.model, "cmapbox"), (cmap, "visible"))

        colorcheck = Checkbox(description="Color")
        link((self.model, "colorbox"), (colorcheck, "value"))

        color = Dropdown(description="Color", values=self.model.COLORS)
        link((self.model, "color"), (color, "value"))
        link((self.model, "colorbox"), (color, "visible"))

        kind = Dropdown(description="Plot Type", values=PLOTPARSER.keys())
        link((self.model, "kind"), (kind, "value"))

        return ControlPanel(title="Plot Settings",
                            children=[
                                VBox([autoupdate, kind]),
                                HBox([cbar, interact]),
                                HBox([colorcheck, cmapcheck]),
                                HBox([more]), cmap, color, popmore
                            ])