def __init__(self): super().__init__() self.distribution_idx = 0 self.var_data = np.array([]) self.column_data = np.array([]) self.dataset = None self.column_idx = 0 self.var_idx = 0 self.available_plot = ["Probability Plot", "Q-Q Plot", "P-P Plot", "Q-Q Plot of 2 samples"] self.attrs = VariableListModel() self.all_attrs = VariableListModel() gui.listView( self.controlArea, self, "attribute", box="First variable", model=self.attrs, callback=self.attr_changed) self.view2 = gui.listView( self.controlArea, self, "group_var", box="Second variable", model=self.attrs, callback=self.var_changed) box = gui.vBox(self.controlArea, 'Type of plot') self.distribution_choose = gui.radioButtonsInBox( box, self, 'distribution_idx', btnLabels=self.available_plot, callback=self.plot_changed, ) self.figure = plt.figure() self.canvas = FigureCanvas(self.figure) self.mainArea.frameGeometry().width() self.mainArea.layout().addWidget(self.canvas)
def __init__(self): super().__init__() self.stats = [] self.dataset = None self.posthoc_lines = [] self.label_txts = self.mean_labels = self.boxes = self.labels = \ self.label_txts_all = self.attr_labels = self.order = [] self.p = -1.0 self.scale_x = self.scene_min_x = self.scene_width = 0 self.label_width = 0 common_options = dict( callback=self.attr_changed, sizeHint=(200, 100)) self.attrs = VariableListModel() gui.listView( self.controlArea, self, "attribute", box="Variable", model=self.attrs, **common_options) self.group_vars = VariableListModel() gui.listView( self.controlArea, self, "group_var", box="Grouping", model=self.group_vars, **common_options) # TODO: move Compare median/mean to grouping box self.display_box = gui.vBox(self.controlArea, "Display") gui.checkBox(self.display_box, self, "show_annotations", "Annotate", callback=self.display_changed) self.compare_rb = gui.radioButtonsInBox( self.display_box, self, 'compare', btnLabels=["No comparison", "Compare medians", "Compare means"], callback=self.display_changed) self.stretching_box = gui.checkBox( self.controlArea, self, 'stretched', "Stretch bars", box='Display', callback=self.display_changed).box gui.vBox(self.mainArea, addSpace=True) self.box_scene = QtGui.QGraphicsScene() self.box_view = QtGui.QGraphicsView(self.box_scene) self.box_view.setRenderHints(QtGui.QPainter.Antialiasing | QtGui.QPainter.TextAntialiasing | QtGui.QPainter.SmoothPixmapTransform) self.box_view.viewport().installEventFilter(self) self.mainArea.layout().addWidget(self.box_view) e = gui.hBox(self.mainArea, addSpace=False) self.infot1 = gui.widgetLabel(e, "<center>No test results.</center>") self.mainArea.setMinimumWidth(650) self.stats = self.dist = self.conts = [] self.is_continuous = False self.update_display_box()
def __init__(self): super().__init__() self.stats = [] self.dataset = None self.posthoc_lines = [] self.label_txts = self.mean_labels = self.boxes = self.labels = \ self.label_txts_all = self.attr_labels = self.order = [] self.p = -1.0 self.scale_x = self.scene_min_x = self.scene_width = 0 self.label_width = 0 common_options = dict( callback=self.attr_changed, sizeHint=(200, 100)) self.attrs = VariableListModel() gui.listView( self.controlArea, self, "attribute", box="Variable", model=self.attrs, **common_options) self.group_vars = VariableListModel() gui.listView( self.controlArea, self, "group_var", box="Grouping", model=self.group_vars, **common_options) # TODO: move Compare median/mean to grouping box self.display_box = gui.vBox(self.controlArea, "Display") gui.checkBox(self.display_box, self, "show_annotations", "Annotate", callback=self.display_changed) self.compare_rb = gui.radioButtonsInBox( self.display_box, self, 'compare', btnLabels=["No comparison", "Compare medians", "Compare means"], callback=self.display_changed) self.stretching_box = gui.checkBox( self.controlArea, self, 'stretched', "Stretch bars", box='Display', callback=self.display_changed).box gui.vBox(self.mainArea, addSpace=True) self.box_scene = QGraphicsScene() self.box_view = QGraphicsView(self.box_scene) self.box_view.setRenderHints(QPainter.Antialiasing | QPainter.TextAntialiasing | QPainter.SmoothPixmapTransform) self.box_view.viewport().installEventFilter(self) self.mainArea.layout().addWidget(self.box_view) e = gui.hBox(self.mainArea, addSpace=False) self.infot1 = gui.widgetLabel(e, "<center>No test results.</center>") self.mainArea.setMinimumWidth(650) self.stats = self.dist = self.conts = [] self.is_continuous = False self.update_display_box()
def _add_controls(self): displaybox = gui.widgetBox(self.controlArea, "Display") gui.checkBox(displaybox, self, "show_profiles", "Lines", callback=self.__show_profiles_changed, tooltip="Plot lines") gui.checkBox(displaybox, self, "show_range", "Range", callback=self.__show_range_changed, tooltip="Plot range between 10th and 90th percentile") gui.checkBox(displaybox, self, "show_mean", "Mean", callback=self.__show_mean_changed, tooltip="Plot mean curve") gui.checkBox(displaybox, self, "show_error", "Error bars", callback=self.__show_error_changed, tooltip="Show standard deviation") self.group_vars = DomainModel( placeholder="None", separators=False, valid_types=DiscreteVariable) self.group_view = gui.listView( self.controlArea, self, "group_var", box="Group by", model=self.group_vars, callback=self.__group_var_changed, sizeHint=QSize(30, 100)) self.group_view.setEnabled(False) plot_gui = OWPlotGUI(self) plot_gui.box_zoom_select(self.controlArea) gui.rubber(self.controlArea) gui.auto_send(self.controlArea, self, "auto_commit") self.info.set_input_summary(self.info.NoInput) self.info.set_output_summary(self.info.NoOutput)
def __init__(self): super().__init__() self.data = None box = gui.vBox(self.controlArea, box=True) self.variable_model = DomainModel( order=DomainModel.MIXED, valid_types=(ContinuousVariable, )) var_list = gui.listView( box, self, "variables", model=self.variable_model, callback=self.commit.deferred ) var_list.setSelectionMode(var_list.ExtendedSelection) combo = gui.comboBox( box, self, "operation", label="Operator: ", orientation=Qt.Horizontal, items=list(self.Operations), sendSelectedValue=True, callback=self.commit.deferred ) combo.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Fixed) gui.lineEdit( box, self, "var_name", label="Variable name: ", orientation=Qt.Horizontal, callback=self.commit.deferred ) gui.auto_apply(self.controlArea, self)
def __init__(self): # Commit is thunked because autocommit redefines it # pylint: disable=unnecessary-lambda super().__init__() self.data = None self.var_model = DomainModel(parent=self, order=DomainModel.MIXED) var_list = gui.listView(self.controlArea, self, "selected_vars", box="Group by", model=self.var_model, callback=self.commit.deferred, viewType=ListViewSearch) var_list.setSelectionMode(var_list.ExtendedSelection) gui.comboBox(self.controlArea, self, 'tiebreaker', box=True, label='Instance to select in each group:', items=tuple(self.TIEBREAKERS), callback=self.commit.deferred, sendSelectedValue=True) gui.auto_commit(self.controlArea, self, 'autocommit', 'Commit', orientation=Qt.Horizontal)
def _add_controls(self): infobox = gui.widgetBox(self.controlArea, "Info") self.infoLabel = gui.widgetLabel(infobox, "No data on input.") displaybox = gui.widgetBox(self.controlArea, "Display") gui.checkBox(displaybox, self, "show_profiles", "Lines", callback=self.__show_profiles_changed, tooltip="Plot lines") gui.checkBox(displaybox, self, "show_range", "Range", callback=self.__show_range_changed, tooltip="Plot range between 10th and 90th percentile") gui.checkBox(displaybox, self, "show_mean", "Mean", callback=self.__show_mean_changed, tooltip="Plot mean curve") gui.checkBox(displaybox, self, "show_error", "Error bars", callback=self.__show_error_changed, tooltip="Show standard deviation") self.group_vars = DomainModel( placeholder="None", separators=False, valid_types=DiscreteVariable) self.group_view = gui.listView( self.controlArea, self, "group_var", box="Group by", model=self.group_vars, callback=self.__group_var_changed) self.group_view.setEnabled(False) self.group_view.setMinimumSize(QSize(30, 100)) self.group_view.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Ignored) plot_gui = OWPlotGUI(self) plot_gui.box_zoom_select(self.controlArea) gui.rubber(self.controlArea) gui.auto_commit(self.controlArea, self, "auto_commit", "Send Selection", "Send Automatically")
def setUp(self): self.widget = OWWidget() self.widget.foo = None self.attrs = VariableListModel() self.view = gui.listView(self.widget.controlArea, self.widget, "foo", model=self.attrs)
def __call__(self, master, model_selected, model_other): self.master = master params_view = { "sizePolicy": QSizePolicy(*SIZE_POLICY_ADAPTING), "selectionMode": QListView.ExtendedSelection, "dragEnabled": True, "defaultDropAction": Qt.MoveAction, "dragDropOverwriteMode": False, "dragDropMode": QListView.DragDrop, } self.view_selected = view = gui.listView(widget=master.controlArea, master=master, box="Displayed Axes", **params_view) view.box.setMinimumHeight(120) view.viewport().setAcceptDrops(True) delete = QAction( "Delete", view, shortcut=QKeySequence(Qt.Key_Delete), triggered=self.__deactivate_selection, ) view.addAction(delete) self.model_selected = model = model_selected model.rowsInserted.connect(master.invalidate_plot) model.rowsRemoved.connect(master.invalidate_plot) model.rowsMoved.connect(master.invalidate_plot) view.setModel(model) addClassLabel = QAction("+", master, toolTip="Add new class label", triggered=self._action_add) removeClassLabel = QAction( unicodedata.lookup("MINUS SIGN"), master, toolTip="Remove selected class label", triggered=self.__deactivate_selection, ) add_remove = itemmodels.ModelActionsWidget( [addClassLabel, removeClassLabel], master) add_remove.layout().addStretch(10) add_remove.layout().setSpacing(1) add_remove.setSizePolicy(*SIZE_POLICY_FIXED) view.box.layout().addWidget(add_remove) self.add_remove = add_remove self.box = add_remove.buttons[1] self.model_other = model_other
def _add_controls(self): displaybox = gui.widgetBox(self.controlArea, "显示") gui.checkBox( displaybox, self, "show_profiles", "线", callback=self.__show_profiles_changed, tooltip="Plot lines", ) gui.checkBox( displaybox, self, "show_range", "范围", callback=self.__show_range_changed, tooltip="Plot range between 10th and 90th percentile", ) gui.checkBox( displaybox, self, "show_mean", "平均值", callback=self.__show_mean_changed, tooltip="Plot mean curve", ) gui.checkBox( displaybox, self, "show_error", "误差线", callback=self.__show_error_changed, tooltip="Show standard deviation", ) self.group_vars = DomainModel(placeholder="None", separators=False, valid_types=DiscreteVariable) self.group_view = gui.listView( self.controlArea, self, "group_var", box="分组依据", model=self.group_vars, callback=self.__group_var_changed, sizeHint=QSize(30, 100), viewType=ListViewSearch, sizePolicy=(QSizePolicy.Minimum, QSizePolicy.Expanding), ) self.group_view.setEnabled(False) plot_gui = OWPlotGUI(self) plot_gui.box_zoom_select(self.buttonsArea) gui.auto_send(self.buttonsArea, self, "auto_commit")
def __init__(self, parent=None): super().__init__(parent) self.__groups = None self.__profiles = None self.data = None self.data_subset = None self.subset_selection = [] self.graph_variables = [] # Setup GUI infobox = gui.widgetBox(self.controlArea, "Info") self.infoLabel = gui.widgetLabel(infobox, "No data on input.") displaybox = gui.widgetBox(self.controlArea, "Display") radiobox = gui.radioButtons(displaybox, self, "display_index", callback=self.__update_visibility) gui.appendRadioButton(radiobox, "Range (min-max) with mean") gui.appendRadioButton(radiobox, "Line plot") gui.appendRadioButton(radiobox, "Mean") gui.appendRadioButton(radiobox, "Line plot with mean") showbox = gui.widgetBox(self.controlArea, "Show") gui.checkBox(showbox, self, "display_quartiles", "Error bars", callback=self.__update_visibility) self.group_vars = DomainModel( placeholder="None", separators=False, valid_types=DiscreteVariable) self.group_view = gui.listView( self.controlArea, self, "group_var", box="Group by", model=self.group_vars, callback=self.__group_var_changed) self.group_view.setEnabled(False) self.group_view.setMinimumSize(QSize(30, 100)) self.group_view.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Ignored) self.gui = OWPlotGUI(self) self.box_zoom_select(self.controlArea) gui.rubber(self.controlArea) gui.auto_commit(self.controlArea, self, "auto_commit", "Send Selection", "Send Automatically") self.graph = LinePlotGraph(self) self.graph.getPlotItem().buttonsHidden = True self.graph.setRenderHint(QPainter.Antialiasing, True) self.mainArea.layout().addWidget(self.graph) self._legend = LegendItem() self._legend.setParentItem(self.graph.getPlotItem().vb) self._legend.hide() self._legend.anchor((1, 0), (1, 0))
def __init__(self): super().__init__() self.data = None self.set_data(self.data) # show warning self.group_vars = DomainModel( placeholder="None", separators=False, valid_types=Orange.data.DiscreteVariable) self.group_view = gui.listView( self.controlArea, self, "group_var", box="Group by", model=self.group_vars, callback=self.grouping_changed) gui.auto_commit(self.controlArea, self, "autocommit", "Apply")
def _add_controls(self): infobox = gui.widgetBox(self.controlArea, "Info") self.infoLabel = gui.widgetLabel(infobox, "No data on input.") displaybox = gui.widgetBox(self.controlArea, "Display") gui.checkBox(displaybox, self, "show_profiles", "Lines", callback=self.__show_profiles_changed, tooltip="Plot lines") gui.checkBox(displaybox, self, "show_range", "Range", callback=self.__show_range_changed, tooltip="Plot range between 10th and 90th percentile") gui.checkBox(displaybox, self, "show_mean", "Mean", callback=self.__show_mean_changed, tooltip="Plot mean curve") gui.checkBox(displaybox, self, "show_error", "Error bars", callback=self.__show_error_changed, tooltip="Show standard deviation") self.group_vars = DomainModel(placeholder="None", separators=False, valid_types=DiscreteVariable) self.group_view = gui.listView(self.controlArea, self, "group_var", box="Group by", model=self.group_vars, callback=self.__group_var_changed) self.group_view.setEnabled(False) self.group_view.setMinimumSize(QSize(30, 100)) self.group_view.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Ignored) plot_gui = OWPlotGUI(self) plot_gui.box_zoom_select(self.controlArea) gui.rubber(self.controlArea) gui.auto_commit(self.controlArea, self, "auto_commit", "Send Selection", "Send Automatically")
def _add_controls(self): infobox = gui.widgetBox(self.controlArea, "信息") self.infoLabel = gui.widgetLabel(infobox, "没有输入数据。") displaybox = gui.widgetBox(self.controlArea, "显示") gui.checkBox(displaybox, self, "show_profiles", "线", callback=self.__show_profiles_changed, tooltip="Plot lines") gui.checkBox(displaybox, self, "show_range", "范围", callback=self.__show_range_changed, tooltip="Plot range between 10th and 90th percentile") gui.checkBox(displaybox, self, "show_mean", "平均值", callback=self.__show_mean_changed, tooltip="Plot mean curve") gui.checkBox(displaybox, self, "show_error", "误差条", callback=self.__show_error_changed, tooltip="Show standard deviation") self.group_vars = DomainModel(placeholder="无", separators=False, valid_types=DiscreteVariable) self.group_view = gui.listView(self.controlArea, self, "group_var", box="分组", model=self.group_vars, callback=self.__group_var_changed) self.group_view.setEnabled(False) self.group_view.setMinimumSize(QSize(30, 100)) self.group_view.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Ignored) plot_gui = OWPlotGUI(self) plot_gui.box_zoom_select(self.controlArea) gui.rubber(self.controlArea) gui.auto_commit(self.controlArea, self, "auto_commit", "选中发送", "自动发送")
def __call__(self, master, model_selected, model_other): self.master = master params_view = {"sizePolicy": QSizePolicy(*SIZE_POLICY_ADAPTING), "selectionMode": QListView.ExtendedSelection, "dragEnabled": True, "defaultDropAction": Qt.MoveAction, "dragDropOverwriteMode": False, "dragDropMode": QListView.DragDrop} self.view_selected = view = gui.listView(widget=master.controlArea, master=master, box="Displayed Axes", **params_view) view.box.setMinimumHeight(120) view.viewport().setAcceptDrops(True) delete = QAction( "Delete", view, shortcut=QKeySequence(Qt.Key_Delete), triggered=self.__deactivate_selection ) view.addAction(delete) self.model_selected = model = model_selected model.rowsInserted.connect(master.invalidate_plot) model.rowsRemoved.connect(master.invalidate_plot) model.rowsMoved.connect(master.invalidate_plot) view.setModel(model) addClassLabel = QAction("+", master, toolTip="Add new class label", triggered=self._action_add) removeClassLabel = QAction(unicodedata.lookup("MINUS SIGN"), master, toolTip="Remove selected class label", triggered=self.__deactivate_selection) add_remove = itemmodels.ModelActionsWidget([addClassLabel, removeClassLabel], master) add_remove.layout().addStretch(10) add_remove.layout().setSpacing(1) add_remove.setSizePolicy(*SIZE_POLICY_FIXED) view.box.layout().addWidget(add_remove) self.add_remove = add_remove self.box = add_remove.buttons[1] self.model_other = model_other
def test_select(self): widget = OWWidget() widget.foo = None self.attrs = VariableListModel() view = gui.listView(widget.controlArea, widget, "foo", model=self.attrs) self.assertIsNone(widget.foo) a, b, c = (ContinuousVariable(x) for x in "abc") self.attrs[:] = [a, b, c] view.setCurrentIndex(self.attrs.index(0, 0)) self.assertIs(widget.foo, a) view.setCurrentIndex(self.attrs.index(2, 0)) self.assertIs(widget.foo, c) widget.foo = b selection = view.selectedIndexes() self.assertEqual(len(selection), 1) self.assertEqual(selection[0].row(), 1)
def __init__(self): super().__init__() self.data = None self.set_data(self.data) # show warning self.group_vars = DomainModel(placeholder="None", separators=False, valid_types=Orange.data.DiscreteVariable) self.group_view = gui.listView(self.controlArea, self, "group_var", box="Group by", model=self.group_vars, callback=self.grouping_changed) gui.auto_commit(self.controlArea, self, "autocommit", "Apply")
def __init__(self): super().__init__() self.graph = ParallelCoordinates(self) self.mainArea.layout().addWidget(self.graph) self.model = DomainModel(separators=False, valid_types=DomainModel.PRIMITIVE) self.colormodel = DomainModel(valid_types=DomainModel.PRIMITIVE) box = gui.vBox(self.controlArea, 'Lines') combo = gui.comboBox(box, self, 'color_attr', sendSelectedValue=True, label='Color:', orientation=Qt.Horizontal, callback=self.update_plot) combo.setModel(self.colormodel) box = gui.vBox(self.controlArea, 'Dimensions') view = gui.listView(box, self, 'selected_attrs', model=self.model, callback=self.update_plot) view.setSelectionMode(view.ExtendedSelection) # Prevent drag selection. Otherwise, each new addition to selectio`n # the mouse passes over triggers a webview redraw. Sending lots of data # around multiple times on large datasets results in stalling and crashes. view.mouseMoveEvent = ( lambda event: None if view.state() == view.DragSelectingState else super( view.__class__, view).mouseMoveEvent(event)) self.optimize_button = gui.button( box, self, 'Optimize Selected Dimensions', callback=self.optimize, tooltip='Optimize visualized dimensions by maximizing cumulative ' 'Kendall rank correlation coefficient.') gui.auto_commit(self.controlArea, self, 'autocommit', '&Apply')
def setUp(self): self.widget = OWWidget() self.widget.foo = None self.attrs = VariableListModel() self.view = gui.listView( self.widget.controlArea, self.widget, "foo", model=self.attrs)
def __init__(self): super().__init__() self.stats = [] self.dataset = None self.posthoc_lines = [] self.label_txts = self.mean_labels = self.boxes = self.labels = \ self.label_txts_all = self.attr_labels = self.order = [] self.p = -1.0 self.scale_x = self.scene_min_x = self.scene_width = 0 self.label_width = 0 self.attrs = VariableListModel() view = gui.listView(self.controlArea, self, "attribute", box="Variable", model=self.attrs, callback=self.attr_changed) view.setMinimumSize(QSize(30, 30)) # Any other policy than Ignored will let the QListBox's scrollbar # set the minimal height (see the penultimate paragraph of # http://doc.qt.io/qt-4.8/qabstractscrollarea.html#addScrollBarWidget) view.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Ignored) gui.separator(view.box, 6, 6) self.cb_order = gui.checkBox( view.box, self, "order_by_importance", "Order by relevance", tooltip="Order by 𝜒² or ANOVA over the subgroups", callback=self.apply_sorting) self.group_vars = VariableListModel() view = gui.listView(self.controlArea, self, "group_var", box="Subgroups", model=self.group_vars, callback=self.grouping_changed) view.setMinimumSize(QSize(30, 30)) # See the comment above view.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Ignored) # TODO: move Compare median/mean to grouping box # The vertical size policy is needed to let only the list views expand self.display_box = gui.vBox(self.controlArea, "Display", sizePolicy=(QSizePolicy.Minimum, QSizePolicy.Maximum)) gui.checkBox(self.display_box, self, "show_annotations", "Annotate", callback=self.display_changed) self.compare_rb = gui.radioButtonsInBox( self.display_box, self, 'compare', btnLabels=["No comparison", "Compare medians", "Compare means"], callback=self.display_changed) # The vertical size policy is needed to let only the list views expand self.stretching_box = gui.checkBox( self.controlArea, self, 'stretched', "Stretch bars", box='Display', callback=self.display_changed, sizePolicy=(QSizePolicy.Minimum, QSizePolicy.Maximum)).box gui.auto_commit(self.controlArea, self, "auto_commit", "Send Selection", "Send Automatically") gui.vBox(self.mainArea, addSpace=True) self.box_scene = QGraphicsScene() self.box_scene.selectionChanged.connect(self.commit) self.box_view = QGraphicsView(self.box_scene) self.box_view.setRenderHints(QPainter.Antialiasing | QPainter.TextAntialiasing | QPainter.SmoothPixmapTransform) self.box_view.viewport().installEventFilter(self) self.mainArea.layout().addWidget(self.box_view) e = gui.hBox(self.mainArea, addSpace=False) self.infot1 = gui.widgetLabel(e, "<center>No test results.</center>") self.mainArea.setMinimumWidth(600) self.stats = self.dist = self.conts = [] self.is_continuous = False self.update_display_box()
def __init__(self): super().__init__() self.data = None self.valid_data = self.valid_group_data = None self.bar_items = [] self.curve_items = [] self.curve_descriptions = None self.binnings = [] self.last_click_idx = None self.drag_operation = self.DragNone self.key_operation = None self._user_var_bins = {} varview = gui.listView( self.controlArea, self, "var", box="Variable", model=DomainModel(valid_types=DomainModel.PRIMITIVE, separators=False), callback=self._on_var_changed, viewType=ListViewSearch ) gui.checkBox( varview.box, self, "sort_by_freq", "Sort categories by frequency", callback=self._on_sort_by_freq, stateWhenDisabled=False) box = self.continuous_box = gui.vBox(self.controlArea, "Distribution") slider = gui.hSlider( box, self, "number_of_bins", label="Bin width", orientation=Qt.Horizontal, minValue=0, maxValue=max(1, len(self.binnings) - 1), createLabel=False, callback=self._on_bins_changed) self.bin_width_label = gui.widgetLabel(slider.box) self.bin_width_label.setFixedWidth(35) self.bin_width_label.setAlignment(Qt.AlignRight) slider.sliderReleased.connect(self._on_bin_slider_released) gui.comboBox( box, self, "fitted_distribution", label="Fitted distribution", orientation=Qt.Horizontal, items=(name[0] for name in self.Fitters), callback=self._on_fitted_dist_changed) self.smoothing_box = gui.indentedBox(box, 40) gui.hSlider( self.smoothing_box, self, "kde_smoothing", label="Smoothing", orientation=Qt.Horizontal, minValue=2, maxValue=20, callback=self.replot) gui.checkBox( box, self, "hide_bars", "Hide bars", stateWhenDisabled=False, callback=self._on_hide_bars_changed, disabled=not self.fitted_distribution) box = gui.vBox(self.controlArea, "Columns") gui.comboBox( box, self, "cvar", label="Split by", orientation=Qt.Horizontal, searchable=True, model=DomainModel(placeholder="(None)", valid_types=(DiscreteVariable), ), callback=self._on_cvar_changed, contentsLength=18) gui.checkBox( box, self, "stacked_columns", "Stack columns", callback=self.replot) gui.checkBox( box, self, "show_probs", "Show probabilities", callback=self._on_show_probabilities_changed) gui.checkBox( box, self, "cumulative_distr", "Show cumulative distribution", callback=self._on_show_cumulative) gui.auto_apply(self.controlArea, self, commit=self.apply) self.info.set_input_summary(self.info.NoInput) self.info.set_output_summary(self.info.NoOutput) self._set_smoothing_visibility() self._setup_plots() self._setup_legend()
def __init__(self): super().__init__() self.data = None self.valid_data = self.valid_group_data = None self.bar_items = [] self.curve_items = [] self.curve_descriptions = None self.binnings = [] self.last_click_idx = None self.drag_operation = self.DragNone self.key_operation = None self._user_var_bins = {} gui.listView(self.controlArea, self, "var", box="变量", model=DomainModel(valid_types=DomainModel.PRIMITIVE, separators=False), callback=self._on_var_changed) box = self.continuous_box = gui.vBox(self.controlArea, "分布") slider = gui.hSlider(box, self, "number_of_bins", label="Bin 宽度", orientation=Qt.Horizontal, minValue=0, maxValue=max(1, len(self.binnings) - 1), createLabel=False, callback=self._on_bins_changed) self.bin_width_label = gui.widgetLabel(slider.box) self.bin_width_label.setFixedWidth(35) self.bin_width_label.setAlignment(Qt.AlignRight) slider.sliderReleased.connect(self._on_bin_slider_released) gui.comboBox(box, self, "fitted_distribution", label="拟合分布", orientation=Qt.Horizontal, items=(name[0] for name in self.Fitters), callback=self._on_fitted_dist_changed) self.smoothing_box = gui.indentedBox(box, 40) gui.hSlider(self.smoothing_box, self, "kde_smoothing", label="平滑化", orientation=Qt.Horizontal, minValue=2, maxValue=20, callback=self.replot) gui.checkBox(box, self, "hide_bars", "隐藏柱子", stateWhenDisabled=False, callback=self._on_hide_bars_changed, disabled=not self.fitted_distribution) box = gui.vBox(self.controlArea, "列") gui.comboBox(box, self, "cvar", label="由...分割", orientation=Qt.Horizontal, model=DomainModel( placeholder="(None)", valid_types=(DiscreteVariable), ), callback=self._on_cvar_changed, contentsLength=18) gui.checkBox(box, self, "stacked_columns", "堆叠列", callback=self.replot) gui.checkBox(box, self, "show_probs", "显示概率", callback=self._on_show_probabilities_changed) gui.checkBox(box, self, "cumulative_distr", "Show cumulative distribution", callback=self.replot) gui.auto_apply(self.controlArea, self, commit=self.apply) self._set_smoothing_visibility() self._setup_plots() self._setup_legend()
def __init__(self): super().__init__() # widget attributes self.input_data = None self.store_input_domain = None self.input_genes_names = [] self.input_genes_ids = [] self.tax_id = None self.use_attr_names = None self.gene_id_attribute = None # custom gene set input self.feature_model = itemmodels.DomainModel( valid_types=(DiscreteVariable, StringVariable)) self.custom_data = None self.custom_tax_id = None self.custom_use_attr_names = None self.custom_gene_id_attribute = None self.custom_gene_id_column = None self.num_of_custom_sets = None self.rows_by_cluster = None self.rows_by_batch = None self.clusters = [] self.new_cluster_profile = [] # data model self.cluster_info_model = None # Info info_box = vBox(self.controlArea, 'Info') self.input_info = widgetLabel(info_box) # Cluster selection self.cluster_indicator_model = itemmodels.DomainModel( valid_types=(DiscreteVariable, ), separators=False) self.cluster_indicator_box = widgetBox(self.controlArea, 'Cluster Indicator') self.cluster_indicator_view = listView( self.cluster_indicator_box, self, 'cluster_indicators', model=self.cluster_indicator_model, selectionMode=QListWidget.MultiSelection, callback=self.invalidate, sizeHint=QSize(256, 70)) # Batch selection self.batch_indicator_model = itemmodels.DomainModel( valid_types=(DiscreteVariable, ), separators=False, placeholder="") box = widgetBox(self.controlArea, 'Batch Indicator') self.batch_indicator_combobox = comboBox( box, self, 'batch_indicator', model=self.batch_indicator_model, sendSelectedValue=True, callback=self.batch_indicator_changed) # Gene scoring box = widgetBox(self.controlArea, 'Gene Scoring') self.gene_scoring = GeneScoringWidget(box, self) self.gene_scoring.set_method_selection_area('scoring_method_selection') self.gene_scoring.set_method_design_area('scoring_method_design') self.gene_scoring.set_test_type('scoring_test_type') # Gene Sets widget gene_sets_box = widgetBox(self.controlArea, "Gene Sets") self.gs_widget = GeneSetsSelection(gene_sets_box, self, 'stored_gene_sets_selection') self.gs_widget.hierarchy_tree_widget.itemClicked.connect( self.__gene_sets_enrichment) # custom gene sets area box = vBox(self.controlArea, "Custom Gene Sets") if self.custom_gene_set_indicator not in self.feature_model: self.custom_gene_set_indicator = None self.gs_label_combobox = comboBox( box, self, "custom_gene_set_indicator", sendSelectedValue=True, model=self.feature_model, callback=self.handle_custom_gene_sets) self.gs_label_combobox.setDisabled(True) # main area splitter = QSplitter(Qt.Horizontal, self.mainArea) self.mainArea.layout().addWidget(splitter) genes_filter = widgetBox(splitter, 'Filter Genes', orientation=QHBoxLayout()) spin(genes_filter, self, 'max_gene_count', 0, 10000, label='Count', tooltip='Minimum genes count', checked='use_gene_count_filter', callback=self.filter_genes, callbackOnReturn=True, checkCallback=self.filter_genes) doubleSpin(genes_filter, self, 'max_gene_p_value', 0.0, 1.0, 0.0001, label='p-value', tooltip='Maximum p-value of the enrichment score', checked='use_gene_pval_filter', callback=self.filter_genes, callbackOnReturn=True, checkCallback=self.filter_genes) doubleSpin(genes_filter, self, 'max_gene_fdr', 0.0, 1.0, 0.0001, label='FDR', tooltip='Maximum false discovery rate', checked='use_gene_fdr_filter', callback=self.filter_genes, callbackOnReturn=True, checkCallback=self.filter_genes) gene_sets_filter = widgetBox(splitter, 'Filter Gene Sets', orientation=QHBoxLayout()) spin(gene_sets_filter, self, 'min_gs_count', 0, DISPLAY_GENE_SETS_COUNT, label='Count', tooltip='Minimum genes count', checked='use_gs_count_filter', callback=self.filter_gene_sets, callbackOnReturn=True, checkCallback=self.filter_gene_sets) doubleSpin(gene_sets_filter, self, 'max_gs_p_value', 0.0, 1.0, 0.0001, label='p-value', tooltip='Maximum p-value of the enrichment score', checked='use_gs_pval_filter', callback=self.filter_gene_sets, callbackOnReturn=True, checkCallback=self.filter_gene_sets) doubleSpin(gene_sets_filter, self, 'max_gs_fdr', 0.0, 1.0, 0.0001, label='FDR', tooltip='Maximum false discovery rate', checked='use_gs_max_fdr', callback=self.filter_gene_sets, callbackOnReturn=True, checkCallback=self.filter_gene_sets) self.cluster_info_view = QTableView() self.cluster_info_view.verticalHeader().setVisible(False) self.cluster_info_view.setItemDelegate(HTMLDelegate()) self.cluster_info_view.horizontalHeader().hide() self.cluster_info_view.horizontalHeader().setSectionResizeMode( QHeaderView.Stretch) auto_commit(self.controlArea, self, "auto_commit", "&Commit", box=False) self.mainArea.layout().addWidget(self.cluster_info_view)
def __init__(self): self._task = None # type: Optional[self.Task] self._executor = ThreadExecutor(self) self.data = None self.test_type = '' self.discrete_model = DomainModel(separators=False, valid_types=(DiscreteVariable,), parent=self) self.domain_model = DomainModel(valid_types=DomainModel.PRIMITIVE, parent=self) box = gui.vBox(self.controlArea, 'Hypotheses Testing') gui.listView(box, self, 'chosen_X', model=self.discrete_model, box='Grouping Variables', selectionMode=QListView.ExtendedSelection, callback=self.Error.no_vars_selected.clear, toolTip='Select multiple variables with Ctrl+ or Shift+Click.') target = gui.comboBox(box, self, 'chosen_y', sendSelectedValue=True, label='Test Variable', callback=[self.set_test_type, self.Error.no_class_selected.clear]) target.setModel(self.domain_model) gui.checkBox(box, self, 'is_permutation', label='Permutation test', callback=self.set_test_type) gui.comboBox(box, self, 'test_statistic', label='Statistic:', items=tuple(self.TEST_STATISTICS), orientation=Qt.Horizontal, sendSelectedValue=True, callback=self.set_test_type) gui.label(box, self, 'Test: %(test_type)s') box = gui.vBox(self.controlArea, 'Filter') gui.spin(box, self, 'min_count', 5, 1000, 5, label='Minimum group size (count):') self.btn_compute = gui.button(self.controlArea, self, '&Compute', callback=self.compute) gui.rubber(self.controlArea) class Model(PyTableModel): _n_vars = 0 _BACKGROUND = [QBrush(QColor('#eee')), QBrush(QColor('#ddd'))] def setHorizontalHeaderLabels(self, labels, n_vars): self._n_vars = n_vars super().setHorizontalHeaderLabels(labels) def data(self, index, role=Qt.DisplayRole): if role == Qt.BackgroundRole and index.column() < self._n_vars: return self._BACKGROUND[index.row() % 2] if role == Qt.DisplayRole or role == Qt.ToolTipRole: colname = self.headerData(index.column(), Qt.Horizontal) if colname.lower() in ('count', 'count | class'): row = self.mapToSourceRows(index.row()) return int(self[row] [index.column()]) return super().data(index, role) owwidget = self class View(gui.TableView): _vars = None def set_vars(self, vars): self._vars = vars def selectionChanged(self, *args): super().selectionChanged(*args) rows = list({index.row() for index in self.selectionModel().selectedRows(0)}) if not rows: owwidget.Outputs.data.send(None) return model = self.model().tolist() filters = [Values([FilterDiscrete(self._vars[col], {model[row][col]}) for col in range(len(self._vars))]) for row in self.model().mapToSourceRows(rows)] data = Values(filters, conjunction=False)(owwidget.data) annotated = create_annotated_table(owwidget.data, data.ids) owwidget.Outputs.selected_data.send(data) owwidget.Outputs.data.send(annotated) self.view = view = View(self) self.model = Model(parent=self) view.setModel(self.model) view.horizontalHeader().setStretchLastSection(False) self.mainArea.layout().addWidget(view) self.set_test_type()
def __init__(self): super().__init__() self.stats = [] self.dataset = None self.posthoc_lines = [] self.label_txts = self.mean_labels = self.boxes = self.labels = \ self.label_txts_all = self.attr_labels = self.order = [] self.scale_x = 1 self.scene_min_x = self.scene_max_x = self.scene_width = 0 self.label_width = 0 self.attrs = VariableListModel() view = gui.listView(self.controlArea, self, "attribute", box="变量", model=self.attrs, callback=self.attr_changed) view.setMinimumSize(QSize(30, 30)) # Any other policy than Ignored will let the QListBox's scrollbar # set the minimal height (see the penultimate paragraph of # http://doc.qt.io/qt-4.8/qabstractscrollarea.html#addScrollBarWidget) view.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Ignored) gui.checkBox(view.box, self, "order_by_importance", "按相关性排序", tooltip="Order by 𝜒² or ANOVA over the subgroups", callback=self.apply_attr_sorting) self.group_vars = VariableListModel(placeholder="None") view = gui.listView(self.controlArea, self, "group_var", box="Subgroups", model=self.group_vars, callback=self.grouping_changed) gui.checkBox(view.box, self, "order_grouping_by_importance", "按变量相关性排序", tooltip="Order by 𝜒² or ANOVA over the variable values", callback=self.on_group_sorting_checkbox) view.setMinimumSize(QSize(30, 30)) # See the comment above view.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Ignored) # TODO: move Compare median/mean to grouping box # The vertical size policy is needed to let only the list views expand self.display_box = gui.vBox(self.controlArea, "显示", sizePolicy=(QSizePolicy.Minimum, QSizePolicy.Maximum), addSpace=False) gui.checkBox(self.display_box, self, "show_annotations", "注释", callback=self.display_changed) self.compare_rb = gui.radioButtonsInBox( self.display_box, self, 'compare', btnLabels=["不比较", "比较中位数", "比较平均值"], callback=self.layout_changed) # The vertical size policy is needed to let only the list views expand self.stretching_box = box = gui.vBox(self.controlArea, box="显示", sizePolicy=(QSizePolicy.Minimum, QSizePolicy.Fixed)) self.stretching_box.sizeHint = self.display_box.sizeHint gui.checkBox(box, self, 'stretched', "拉伸框条", callback=self.display_changed, stateWhenDisabled=False) gui.checkBox(box, self, 'show_labels', "显示标签", callback=self.display_changed) self.sort_cb = gui.checkBox(box, self, 'sort_freqs', "按子组频率排序", callback=self.display_changed, stateWhenDisabled=False) gui.vBox(self.mainArea, addSpace=True) self.box_scene = QGraphicsScene() self.box_scene.selectionChanged.connect(self.commit) self.box_view = QGraphicsView(self.box_scene) self.box_view.setRenderHints(QPainter.Antialiasing | QPainter.TextAntialiasing | QPainter.SmoothPixmapTransform) self.box_view.viewport().installEventFilter(self) self.mainArea.layout().addWidget(self.box_view) gui.hBox(self.mainArea, addSpace=False) self.stat_test = "" self.mainArea.setMinimumWidth(300) self.stats = self.dist = self.conts = [] self.is_continuous = False self.update_display_box()
def __init__(self): super().__init__() self.stats = [] self.dataset = None self.posthoc_lines = [] self.label_txts = self.mean_labels = self.boxes = self.labels = \ self.label_txts_all = self.attr_labels = self.order = [] self.p = -1.0 self.scale_x = self.scene_min_x = self.scene_width = 0 self.label_width = 0 self.attrs = VariableListModel() view = gui.listView(self.controlArea, self, "attribute", box="变量", model=self.attrs, callback=self.attr_changed) view.setMinimumSize(QSize(30, 30)) # Any other policy than Ignored will let the QListBox's scrollbar # set the minimal height (see the penultimate paragraph of # http://doc.qt.io/qt-4.8/qabstractscrollarea.html#addScrollBarWidget) view.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Ignored) gui.separator(view.box, 6, 6) self.cb_order = gui.checkBox(view.box, self, "order_by_importance", "按相关性排序", tooltip="由𝜒²或方差对子群排序", callback=self.apply_sorting) self.group_vars = DomainModel(placeholder="无", separators=False, valid_types=Orange.data.DiscreteVariable) self.group_view = view = gui.listView(self.controlArea, self, "group_var", box="子群", model=self.group_vars, callback=self.grouping_changed) view.setEnabled(False) view.setMinimumSize(QSize(30, 30)) # See the comment above view.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Ignored) # TODO: move Compare median/mean to grouping box # The vertical size policy is needed to let only the list views expand self.display_box = gui.vBox(self.controlArea, "Display", sizePolicy=(QSizePolicy.Minimum, QSizePolicy.Maximum), addSpace=False) gui.checkBox(self.display_box, self, "show_annotations", "Annotate", callback=self.display_changed) self.compare_rb = gui.radioButtonsInBox( self.display_box, self, 'compare', btnLabels=["无比较", "中位数比较", "均值比较"], callback=self.layout_changed) # The vertical size policy is needed to let only the list views expand self.stretching_box = box = gui.vBox(self.controlArea, box="显示", sizePolicy=(QSizePolicy.Minimum, QSizePolicy.Fixed)) self.stretching_box.sizeHint = self.display_box.sizeHint gui.checkBox(box, self, 'stretched', "拉杆", callback=self.display_changed) gui.checkBox(box, self, 'show_labels', "显示框标签", callback=self.display_changed) self.sort_cb = gui.checkBox(box, self, 'sort_freqs', "按子组频率排序", callback=self.display_changed) gui.rubber(box) gui.auto_commit(self.controlArea, self, "auto_commit", "选中发送", "自动发送") gui.vBox(self.mainArea, addSpace=True) self.box_scene = QGraphicsScene() self.box_scene.selectionChanged.connect(self.commit) self.box_view = QGraphicsView(self.box_scene) self.box_view.setRenderHints(QPainter.Antialiasing | QPainter.TextAntialiasing | QPainter.SmoothPixmapTransform) self.box_view.viewport().installEventFilter(self) self.mainArea.layout().addWidget(self.box_view) e = gui.hBox(self.mainArea, addSpace=False) self.infot1 = gui.widgetLabel(e, "<center>没有测试结果。</center>") self.mainArea.setMinimumWidth(600) self.stats = self.dist = self.conts = [] self.is_continuous = False self.update_display_box()
def __init__(self): super().__init__() self.stats = [] self.dataset = None self.posthoc_lines = [] self.label_txts = self.mean_labels = self.boxes = self.labels = \ self.label_txts_all = self.attr_labels = self.order = [] self.scale_x = self.scene_min_x = self.scene_width = 0 self.label_width = 0 self.attrs = VariableListModel() view = gui.listView( self.controlArea, self, "attribute", box="Variable", model=self.attrs, callback=self.attr_changed) view.setMinimumSize(QSize(30, 30)) # Any other policy than Ignored will let the QListBox's scrollbar # set the minimal height (see the penultimate paragraph of # http://doc.qt.io/qt-4.8/qabstractscrollarea.html#addScrollBarWidget) view.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Ignored) gui.separator(view.box, 6, 6) self.cb_order = gui.checkBox( view.box, self, "order_by_importance", "Order by relevance", tooltip="Order by 𝜒² or ANOVA over the subgroups", callback=self.apply_sorting) self.group_vars = DomainModel( placeholder="None", separators=False, valid_types=Orange.data.DiscreteVariable) self.group_view = view = gui.listView( self.controlArea, self, "group_var", box="Subgroups", model=self.group_vars, callback=self.grouping_changed) view.setEnabled(False) view.setMinimumSize(QSize(30, 30)) # See the comment above view.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Ignored) # TODO: move Compare median/mean to grouping box # The vertical size policy is needed to let only the list views expand self.display_box = gui.vBox( self.controlArea, "Display", sizePolicy=(QSizePolicy.Minimum, QSizePolicy.Maximum), addSpace=False) gui.checkBox(self.display_box, self, "show_annotations", "Annotate", callback=self.display_changed) self.compare_rb = gui.radioButtonsInBox( self.display_box, self, 'compare', btnLabels=["No comparison", "Compare medians", "Compare means"], callback=self.layout_changed) # The vertical size policy is needed to let only the list views expand self.stretching_box = box = gui.vBox( self.controlArea, box="Display", sizePolicy=(QSizePolicy.Minimum, QSizePolicy.Fixed)) self.stretching_box.sizeHint = self.display_box.sizeHint gui.checkBox( box, self, 'stretched', "Stretch bars", callback=self.display_changed) gui.checkBox( box, self, 'show_labels', "Show box labels", callback=self.display_changed) self.sort_cb = gui.checkBox( box, self, 'sort_freqs', "Sort by subgroup frequencies", callback=self.display_changed) gui.rubber(box) gui.auto_commit(self.controlArea, self, "auto_commit", "Send Selection", "Send Automatically") gui.vBox(self.mainArea, addSpace=True) self.box_scene = QGraphicsScene() self.box_scene.selectionChanged.connect(self.commit) self.box_view = QGraphicsView(self.box_scene) self.box_view.setRenderHints(QPainter.Antialiasing | QPainter.TextAntialiasing | QPainter.SmoothPixmapTransform) self.box_view.viewport().installEventFilter(self) self.mainArea.layout().addWidget(self.box_view) e = gui.hBox(self.mainArea, addSpace=False) self.infot1 = gui.widgetLabel(e, "<center>No test results.</center>") self.mainArea.setMinimumWidth(300) self.stats = self.dist = self.conts = [] self.is_continuous = False self.update_display_box()