Example #1
0
    def setData(self, data=None):
        if not self.__initialized:
            self.initfuture.result()
            self.initialize()

        if self.itemsfuture is not None:
            raise Exception("Already processing")

        self.closeContext()
        self.data = data

        if data:
            self.geneAttrComboBox.clear()
            self.attributes = \
                [attr for attr in (data.domain.variables +
                                   data.domain.getmetas().values())
                 if isinstance(attr, (Orange.feature.String,
                                      Orange.feature.Discrete))]

            self.geneAttrComboBox.addItems(
                [attr.name for attr in self.attributes])

            self.taxid = data_hints.get_hint(self.data, "taxid", self.taxid)
            self.useAttr = data_hints.get_hint(self.data, "genesinrows",
                                               self.useAttr)

            self.openContext("", data)
            self.geneAttr = min(self.geneAttr, len(self.attributes) - 1)

            if self.taxid in self.organisms:
                self.organismIndex = self.organisms.index(self.taxid)

            self.updateInfoItems()
        else:
            self.clear()
Example #2
0
    def set_data(self, data):
        self.closeContext("Data")
        self.closeContext("TargetSelection")
        self.error([0, 1])
        self.warning(0)
        self.clear()
        self.genes_in_columns_check.setEnabled(True)
        self.data = data
        self.init_from_data(data)

        if self.data:
            self.genes_in_columns = not data_hints.get_hint(
                data, "genesinrows", False)
            self.openContext("Data", data)

            # If only attr. labels or only class values then disable
            # the 'Genes in columns' control
            if not self.attribute_targets or not self.class_targets:
                self.genes_in_columns_check.setEnabled(False)
                self.genes_in_columns = bool(self.attribute_targets)

        self.update_targets_widget()

        if self.data is not None  and \
                not (self.attribute_targets or self.class_targets):
            # If both attr. labels and classes are missing, show an error
            self.error(
                1,
                "Cannot compute gene scores! Differential expression widget "
                "requires a data-set with a discrete class variable "
                "or attribute labels!")
            self.data = None

        if self.data:
            # Load context selection
            items = [(label, v) for label, values in self.data_labels
                     for v in values]

            self.target_selections = [
                values[:1] for _, values in self.data_labels
            ]
            label, values = self.data_labels[0]
            self.current_target_selection = label, values[:
                                                          1]  # Default selections

            self.openContext("TargetSelection",
                             set(items))  # Load selections from context
            self.label_selection_widget.set_selection(
                *self.current_target_selection)

        if not self.data:
            self.send("Example table with selected genes", None)
            self.send("Example table with remaining genes", None)
            self.send("Selected genes", None)
Example #3
0
    def set_data(self, data):
        self.closeContext()
        self.data = data
        if data is not None:
            self.varmodel[:] = string_variables(data.domain)
            taxid = data_hints.get_hint(data, "taxid", default=self.taxid)

            if taxid in self.taxids:
                self.set_organism(self.taxids.index(taxid))

            self.use_attr_names = data_hints.get_hint(
                data, "genesinrows", default=self.use_attr_names)

            if not (0 <= self.gene_var_index < len(self.varmodel)):
                self.gene_var_index = len(self.varmodel) - 1

            self.openContext("", data)
            self.invalidate()
            self.commit()
        else:
            self.varmodel[:] = []
            self.send("Network", None)
Example #4
0
    def set_data(self, data):
        self.closeContext()
        self.data = data
        if data is not None:
            self.varmodel[:] = string_variables(data.domain)
            taxid = data_hints.get_hint(data, "taxid", default=self.taxid)

            if taxid in self.taxids:
                self.set_organism(self.taxids.index(taxid))

            self.use_attr_names = data_hints.get_hint(
                data, "genesinrows", default=self.use_attr_names
            )

            if not (0 <= self.gene_var_index < len(self.varmodel)):
                self.gene_var_index = len(self.varmodel) - 1

            self.openContext("", data)
            self.invalidate()
            self.commit()
        else:
            self.varmodel[:] = []
            self.send("Network", None)
    def SetData(self, data=None):
        self.closeContext()
        self.data = data
        self.warning(0)
        self.error(0)
        self.information(0)

        if data is not None:
            vars = data.domain.variables + data.domain.getmetas().values()
            vars = [var for var in vars
                    if isinstance(var, (Orange.feature.String,
                                        Orange.feature.Discrete))]
            self.geneAttrCandidates[:] = vars

            # Try to guess the gene name variable
            names_lower = [v.name.lower() for v in vars]
            scores = [(name == "gene", "gene" in name)
                      for name in names_lower]
            imax, _ = max(enumerate(scores), key=itemgetter(1))
            self.geneAttrIndex = imax

            taxid = data_hints.get_hint(data, "taxid", None)
            if taxid:
                try:
                    code = kegg.from_taxid(taxid)
                    self.organismIndex = self.organismCodes.index(code)
                except Exception as ex:
                    print ex, taxid

            self.useAttrNames = data_hints.get_hint(data, "genesinrows",
                                                    self.useAttrNames)

            self.openContext("", data)
        else:
            self.Clear()

        self.has_new_data = True
Example #6
0
    def setData(self, data=None):
        if not self.__initialized:
            self.initfuture.result()
            self.initialize()

        if self.itemsfuture is not None:
            raise Exception("Already processing")

        self.closeContext()
        self.data = data

        if data:
            self.geneAttrComboBox.clear()
            self.attributes = \
                [attr for attr in (data.domain.variables +
                                   data.domain.getmetas().values())
                 if isinstance(attr, (Orange.feature.String,
                                      Orange.feature.Discrete))]

            self.geneAttrComboBox.addItems(
                [attr.name for attr in self.attributes]
            )

            self.taxid = data_hints.get_hint(self.data, "taxid", self.taxid)
            self.useAttr = data_hints.get_hint(
                self.data, "genesinrows", self.useAttr)

            self.openContext("", data)
            self.geneAttr = min(self.geneAttr, len(self.attributes) - 1)

            if self.taxid in self.organisms:
                self.organismIndex = self.organisms.index(self.taxid)

            self.updateInfoItems()
        else:
            self.clear()
Example #7
0
    def setData(self, data=None):
#         self.closeContext("")
        self.closeContext("targets")
        self.clear()
        self.data = data
        self.error(0)
        self.warning([0, 1])
        if data:
            self.genes_in_columns = not bool(data.domain.classVar)
            self.genesInColumnsCheck.setDisabled(not bool(data.domain.classVar))
            if self.genes_in_columns:
                self.genes_in_columns = not data_hints.get_hint(data, "genesinrows", not self.genes_in_columns)
#             self.openContext("", data)
        else:
            self.infoLabel.setText("No data on input.")
        self.init_from_data()
    def set_data(self, data):
        self.closeContext("Data")
        self.closeContext("TargetSelection")
        self.error([0, 1])
        self.warning(0)
        self.clear()
        self.genes_in_columns_check.setEnabled(True)
        self.data = data
        self.init_from_data(data)

        if self.data:
            self.genes_in_columns = not data_hints.get_hint(data, "genesinrows", False)
            self.openContext("Data", data)

            # If only attr. labels or only class values then disable
            # the 'Genes in columns' control
            if not self.attribute_targets or not self.class_targets:
                self.genes_in_columns_check.setEnabled(False)
                self.genes_in_columns = bool(self.attribute_targets)

        self.update_targets_widget()

        if self.data is not None  and \
                not (self.attribute_targets or self.class_targets):
            # If both attr. labels and classes are missing, show an error
            self.error(1, "Cannot compute gene scores! Differential expression widget "
                          "requires a data-set with a discrete class variable "
                          "or attribute labels!")
            self.data = None

        if self.data:
            # Load context selection
            items = [(label, v) for label, values in self.data_labels for v in values]

            self.target_selections = [values[:1] for _, values in self.data_labels]
            label, values = self.data_labels[0]
            self.current_target_selection = label, values[:1] # Default selections

            self.openContext("TargetSelection", set(items)) # Load selections from context
            self.label_selection_widget.set_selection(*self.current_target_selection)

        if not self.data:
            self.send("Example table with selected genes", None)
            self.send("Example table with remaining genes", None)
            self.send("Selected genes", None)
Example #9
0
    def setData(self, data):

        self.allowComboChangeCallback = False

        self.data = data

        if data:
            taxid = data_hints.get_hint(data, "taxid", None)
            try:
                self.organismIndex = self.organismTaxids.index(taxid)
            except Exception, ex:
                pass

            if obiGsea.already_have_correlations(data):

                #disable correlation type
                comboboxItems(self.corTypeF, [])
                self.corTypeF.setDisabled(True)
                #set permutation type to fixed
                self.ptype = 1
                self.permTypeF.setDisabled(True)

            else:
                #enable correlation type
                comboboxItems(self.corTypeF, nth(self.correlationTypes, 0))
                self.corTypeF.setDisabled(False)
                #allow change of permutation type
                self.permTypeF.setDisabled(False)
                #print "set classes"

            self.phenCombo.clear()
            self.phenCands = obiGsea.phenotype_cands(data)
            self.phenCombo.addItems(map(lambda x: str(x[0]), self.phenCands))

            self.phenCombo.setDisabled(len(self.phenCands) <= 1)

            self.selectedPhenVar = 0

            self.allowComboChangeCallback = True

            self.phenComboChange()