Beispiel #1
0
    def __init__(self, parent=None):
        widget.OWWidget.__init__(self, parent)

        self.data = None
        self.target_group = None, []
        self.targets = []
        self.current_selection = []
        self.validindices = numpy.empty((0, ), dtype=int)

        self.graph = VolcanoGraph(symbolSize=self.symbol_size, background="w")
        self.graph.setSelectionMode(
            VolcanoGraph.SymetricSelection if self.
            symetric_selections else VolcanoGraph.RectSelection)

        self.graph.selectionChanged.connect(self.on_selection_changed)
        self.graph.scene().installEventFilter(self)
        self.graph.getViewBox().setMouseEnabled(False, False)
        self.graph.getViewBox().enableAutoRange(enable=True)
        self.graph.plotItem.showGrid(True, True, 0.3)
        self.mainArea.layout().addWidget(self.graph)

        ## GUI
        box = gui.widgetBox(self.controlArea, "Info")
        self.infoLabel = gui.label(box, self, "")
        self.infoLabel.setText("No data on input")
        self.infoLabel2 = gui.label(box, self, "")
        self.infoLabel2.setText("0 selected genes")

        box = gui.widgetBox(self.controlArea, "Target Labels")

        self.target_widget = guiutils.LabelSelectionWidget(
            self,
            groupChanged=self.on_label_activated,
            groupSelectionChanged=self.on_target_changed)

        box.layout().addWidget(self.target_widget)

        box = gui.widgetBox(self.controlArea, "Settings")

        gui.hSlider(
            box,
            self,
            "symbol_size",
            label="Symbol size:   ",
            minValue=2,
            maxValue=20,
            step=1,
            callback=lambda: self.graph.setSymbolSize(self.symbol_size))

        gui.checkBox(box,
                     self,
                     "symetric_selections",
                     "Symmetric selection",
                     callback=self.__on_selectionModeChanged)

        gui.auto_commit(self.controlArea, self, "auto_commit", "Commit")
        gui.rubber(self.controlArea)
    def __init__(self, parent=None):
        widget.OWWidget.__init__(self, parent)

        self.min_value, self.max_value = \
            self.thresholds.get(self.Scores[self.score_index][0], (1, 0))

        #: Input data set
        self.data = None
        #: Current target group selection
        self.targets = []
        #: The computed scores
        self.scores = None
        #: The computed scores from label permutations
        self.nulldist = None

        self.__scores_future = self.__scores_state = None

        self.__in_progress = False

        self.test_f = {
            OWFeatureSelection.LowTail: test_low,
            OWFeatureSelection.HighTail: test_high,
            OWFeatureSelection.TwoTail: test_two_tail,
        }

        self.histogram = Histogram(enableMouse=False,
                                   enableMenu=False,
                                   background="w")
        self.histogram.enableAutoRange(enable=False)
        self.histogram.getPlotItem().hideButtons()  # hide auto range button
        self.histogram.getViewBox().setMouseEnabled(False, False)
        self.histogram.selectionChanged.connect(
            self.__on_histogram_plot_selection_changed)
        self.histogram.selectionEdited.connect(self._invalidate_selection)

        self.mainArea.layout().addWidget(self.histogram)

        box = gui.widgetBox(self.controlArea, "Info")

        self.dataInfoLabel = gui.widgetLabel(box, "No data on input.\n")
        self.dataInfoLabel.setWordWrap(True)
        self.selectedInfoLabel = gui.widgetLabel(box, "\n")

        box1 = gui.widgetBox(self.controlArea, "Scoring Method")
        gui.comboBox(
            box1,
            self,
            "score_index",
            items=[sm[0] for sm in self.Scores],
            callback=[self.on_scoring_method_changed, self.update_scores])

        box = gui.widgetBox(self.controlArea, "Target Labels")
        self.label_selection_widget = guiutils.LabelSelectionWidget(self)
        self.label_selection_widget.setMaximumHeight(150)
        box.layout().addWidget(self.label_selection_widget)

        self.label_selection_widget.groupChanged.connect(
            self.on_label_activated)

        self.label_selection_widget.groupSelectionChanged.connect(
            self.on_target_changed)

        box = gui.widgetBox(self.controlArea, "Selection")
        box.layout().setSpacing(0)

        self.max_value_spin = gui.doubleSpin(box,
                                             self,
                                             "max_value",
                                             minv=-1e6,
                                             maxv=1e6,
                                             step=1e-6,
                                             label="Upper threshold:",
                                             callback=self.update_boundary,
                                             callbackOnReturn=True)

        self.low_value_spin = gui.doubleSpin(box,
                                             self,
                                             "min_value",
                                             minv=-1e6,
                                             maxv=1e6,
                                             step=1e-6,
                                             label="Lower threshold:",
                                             callback=self.update_boundary,
                                             callbackOnReturn=True)

        check = gui.checkBox(box,
                             self,
                             "compute_null",
                             "Compute null distribution",
                             callback=self.update_scores)

        perm_spin = gui.spin(box,
                             self,
                             "permutations_count",
                             minv=1,
                             maxv=50,
                             label="Permutations:",
                             callback=self.update_scores,
                             callbackOnReturn=True)

        check.disables.append(perm_spin)

        box1 = gui.widgetBox(box, orientation='horizontal')

        pval_spin = gui.doubleSpin(box1,
                                   self,
                                   "alpha_value",
                                   minv=2e-7,
                                   maxv=1.0,
                                   step=1e-7,
                                   label="α-value:")
        pval_select = gui.button(box1,
                                 self,
                                 "Select",
                                 callback=self.select_p_best,
                                 autoDefault=False)
        check.disables.append(pval_spin)
        check.disables.append(pval_select)

        check.makeConsistent()

        box1 = gui.widgetBox(box, orientation='horizontal')
        gui.spin(box1, self, "n_best", 0, 10000, step=1, label="Best Ranked:")
        gui.button(box1,
                   self,
                   "Select",
                   callback=self.select_n_best,
                   autoDefault=False)

        box = gui.widgetBox(self.controlArea, "Output")

        acbox = gui.auto_commit(box, self, "auto_commit", "Commit", box=None)
        acbox.button.setDefault(True)

        gui.checkBox(box,
                     self,
                     "add_scores_to_output",
                     "Add gene scores to output",
                     callback=self._invalidate_selection)

        gui.rubber(self.controlArea)

        self.on_scoring_method_changed()
        self._executor = concurrent.ThreadExecutor()
Beispiel #3
0
    def __init__(self, parent=None):
        widget.OWWidget.__init__(self, parent)

        self.data = None
        self.target_group = None, []
        self.targets = []
        self.current_selection = []
        self.validindices = numpy.empty((0, ), dtype=int)

        self.graph = VolcanoGraph(symbolSize=self.symbol_size, background="w")
        self.graph.setSelectionCut(self.cut_log_r, self.cut_log_p)
        self.graph.setSelectionMode(
            VolcanoGraph.SymetricSelection if self.
            symetric_selections else VolcanoGraph.RectSelection)

        self.graph.selectionChanged.connect(self.on_selection_changed)
        self.graph.scene().installEventFilter(self)
        self.graph.getViewBox().setMouseEnabled(False, False)
        self.graph.getViewBox().enableAutoRange(enable=True)
        self.graph.getViewBox().setMenuEnabled(False)
        self.graph.getPlotItem().hideButtons()
        self.graph.plotItem.showGrid(True, True, 0.3)
        self.mainArea.layout().addWidget(self.graph)

        ## GUI
        box = gui.widgetBox(self.controlArea, "Info")
        self.infoLabel = gui.label(box, self, "")
        self.infoLabel.setText("No data on input")
        self.infoLabel2 = gui.label(box, self, "")
        self.infoLabel2.setText("0 selected genes")

        box = gui.widgetBox(self.controlArea, "Target Labels")

        self.target_widget = guiutils.LabelSelectionWidget(
            self,
            groupChanged=self.on_label_activated,
            groupSelectionChanged=self.on_target_changed)

        box.layout().addWidget(self.target_widget)

        box = gui.widgetBox(self.controlArea, "Selection")
        cb = gui.checkBox(
            box,
            self,
            "symetric_selections",
            "Symmetric selection",
            callback=self.__on_selectionModeChanged)  # type: QCheckBox
        form = QFormLayout(
            labelAlignment=Qt.AlignRight,
            formAlignment=Qt.AlignLeft,
            fieldGrowthPolicy=QFormLayout.AllNonFixedFieldsGrow,
        )

        form.addRow(
            "|log(ratio)|:",
            gui.spin(box,
                     self,
                     "cut_log_r",
                     0.0,
                     20.0,
                     step=0.01,
                     decimals=4,
                     spinType=float,
                     callback=self.on_cut_changed))
        form.addRow(
            "-log<sub>10</sub>(P_value):",
            gui.spin(box,
                     self,
                     "cut_log_p",
                     0.0,
                     20.0,
                     step=0.01,
                     decimals=4,
                     spinType=float,
                     callback=self.on_cut_changed))
        box.layout().addLayout(form)

        def set_enable_all(layout, enabled):
            for i in range(layout.count()):
                item = layout.itemAt(i)
                if item is not None and item.widget() is not None:
                    item.widget().setEnabled(enabled)

        set_enable_all(form, self.symetric_selections)
        cb.toggled.connect(partial(set_enable_all, form))
        box = gui.widgetBox(self.controlArea, "Settings")

        gui.hSlider(
            box,
            self,
            "symbol_size",
            label="Symbol size:   ",
            minValue=2,
            maxValue=20,
            step=1,
            callback=lambda: self.graph.setSymbolSize(self.symbol_size))

        gui.rubber(self.controlArea)
        gui.auto_commit(self.controlArea, self, "auto_commit", "Commit")