def set_data(self, data): """ Set the input profile dataset. """ self.closeContext() self.clear() self.data = data if data is not None: if is_discrete(data.domain.class_var): class_vals = data.domain.class_var.values else: class_vals = [] self.classes = list(class_vals) self.class_colors = colorpalette.ColorPaletteGenerator(len(class_vals)) self.selected_classes = list(range(len(class_vals))) for i in range(len(class_vals)): item = self.group_listbox.item(i) item.setIcon(colorpalette.ColorPixmap(self.class_colors[i])) variables = data.domain.variables + data.domain.metas annotvars = [var for var in variables if is_discrete(var) or is_string(var)] for var in annotvars: self.annot_cb.addItem(*gui.attributeItem(var)) if data.domain.class_var in annotvars: self.annot_index = annotvars.index(data.domain.class_var) self.annotation_variables = annotvars self.openContext(data) self._setup_plot() self.commit()
def set_data(self, data): """ Set the input profile dataset. """ self.closeContext() self.clear() self.data = data if data is not None: n_instances = len(data) n_attrs = len(data.domain.attributes) self.infoLabel.setText("%i instances on input\n%i attributes" % (n_instances, n_attrs)) annotvars = [var for var in data.domain.variables + data.domain.metas if is_discrete(var) or is_string(var)] for var in annotvars: self.annot_cb.addItem(*gui.attributeItem(var)) if data.domain.class_var in annotvars: self.annot_index = annotvars.index(data.domain.class_var) self.annotation_variables = annotvars self.graph_variables = [var for var in data.domain.attributes if var.is_continuous] groupvars = [var for var in data.domain.variables + data.domain.metas if is_discrete(var)] if len(groupvars) > 0: self.cb_attr.addItems([str(var) for var in groupvars]) self.group_var = str(groupvars[0]) self.group_variables = groupvars self.update_group_var() self.openContext(data) self.commit()
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.data = data if data is not None: self.geneAttrComboBox.clear() self.attributes = [ attr for attr in data.domain.variables + data.domain.metas if isinstance(attr, (Orange.data.StringVariable, Orange.data.DiscreteVariable)) ] for var in self.attributes: self.geneAttrComboBox.addItem(*gui.attributeItem(var)) self.taxid = str(self.data.attributes.get(TAX_ID, '')) self.useAttr = self.data.attributes.get(GENE_AS_ATTRIBUTE_NAME, self.useAttr) self.gene_attr = min(self.gene_attr, len(self.attributes) - 1) if self.taxid in self.organisms: self.organism_index = self.organisms.index(self.taxid) self.updateInfoItems() else: self.clear()
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 is not None: self.geneAttrComboBox.clear() self.attributes = \ [attr for attr in data.domain.variables + data.domain.metas if isinstance(attr, (Orange.data.StringVariable, Orange.data.DiscreteVariable))] for var in self.attributes: self.geneAttrComboBox.addItem(*gui.attributeItem(var)) 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.gene_attr = min(self.gene_attr, len(self.attributes) - 1) if self.taxid in self.organisms: self.organism_index = self.organisms.index(self.taxid) self.updateInfoItems() else: self.clear()
def add_row(self, attr=None, condition_type=None, condition_value=None): model = self.cond_list.model() row = model.rowCount() model.insertRow(row) attr_combo = gui.OrangeComboBox( minimumContentsLength=12, sizeAdjustPolicy=QComboBox.AdjustToMinimumContentsLengthWithIcon) attr_combo.row = row for var in self._visible_variables(self.data.domain): attr_combo.addItem(*gui.attributeItem(var)) attr_combo.setCurrentIndex(attr or 0) self.cond_list.setCellWidget(row, 0, attr_combo) index = QPersistentModelIndex(model.index(row, 3)) temp_button = QPushButton( '×', self, flat=True, styleSheet='* {font-size: 16pt; color: silver}' '*:hover {color: black}') temp_button.clicked.connect(lambda: self.remove_one(index.row())) self.cond_list.setCellWidget(row, 3, temp_button) self.remove_all_button.setDisabled(False) self.set_new_operators(attr_combo, attr is not None, condition_type, condition_value) attr_combo.currentIndexChanged.connect( lambda _: self.set_new_operators(attr_combo, False)) self.cond_list.resizeRowToContents(row)
def add_row(self, attr=None, condition_type=None, condition_value=None): model = self.cond_list.model() row = model.rowCount() model.insertRow(row) attr_combo = gui.OrangeComboBox( minimumContentsLength=12, sizeAdjustPolicy=QComboBox.AdjustToMinimumContentsLengthWithIcon) attr_combo.row = row for var in self._visible_variables(self.data.domain): attr_combo.addItem(*gui.attributeItem(var)) attr_combo.setCurrentIndex(attr or 0) self.cond_list.setCellWidget(row, 0, attr_combo) index = QPersistentModelIndex(model.index(row, 3)) temp_button = QPushButton('×', self, flat=True, styleSheet='* {font-size: 16pt; color: silver}' '*:hover {color: black}') temp_button.clicked.connect(lambda: self.remove_one(index.row())) self.cond_list.setCellWidget(row, 3, temp_button) self.remove_all_button.setDisabled(False) self.set_new_operators(attr_combo, attr is not None, condition_type, condition_value) attr_combo.currentIndexChanged.connect( lambda _: self.set_new_operators(attr_combo, False)) self.cond_list.resizeRowToContents(row)
def standarditem_from_rowgroup(rowgroup): item = QtGui.QStandardItem(rowgroup.name) icon, _ = gui.attributeItem(rowgroup.var) item.setIcon(icon) item.setToolTip(guiutils.variable_tooltip(rowgroup.var)) item.setData(rowgroup, Qt.UserRole) item.setFlags(item.flags() & ~Qt.ItemIsEditable) children = [guiutils.standarditem_from(val) for val in rowgroup.values] item.appendRows(children) return item
def standarditem_from_rowgroup(rowgroup): item = QStandardItem(rowgroup.name) icon, _ = gui.attributeItem(rowgroup.var) item.setIcon(icon) item.setToolTip(variable_tooltip(rowgroup.var)) item.setData(rowgroup, Qt.UserRole) item.setFlags(item.flags() & ~Qt.ItemIsEditable) children = [standarditem_from(val) for val in rowgroup.values] item.appendRows(children) return item
def add_row(self, attr=None): model = self.cond_list.model() row = model.rowCount() model.insertRow(row) attr_combo = QtGui.QComboBox() attr_combo.row = row attr_combo.setStyleSheet("border: none") for var in chain(self.data.domain.variables, self.data.domain.metas): attr_combo.addItem(*gui.attributeItem(var)) attr_combo.setCurrentIndex(attr or 0) self.cond_list.setCellWidget(row, 0, attr_combo) self.remove_all_button.setDisabled(False) self.set_new_operators(attr_combo, attr is not None) attr_combo.currentIndexChanged.connect( lambda _: self.set_new_operators(attr_combo, False))
def setDataset(self, data=None): if self.__state == OWGOEnrichmentAnalysis.Initializing: self.__initialize_finish() self.closeContext() self.clear() self.clusterDataset = data if data is not None: domain = data.domain allvars = domain.variables + domain.metas self.candidateGeneAttrs = [var for var in allvars if isstring(var)] self.geneAttrIndexCombo.clear() for var in self.candidateGeneAttrs: self.geneAttrIndexCombo.addItem(*gui.attributeItem(var)) taxid = data_hints.get_hint(data, "taxid", "") code = None try: code = go.from_taxid(taxid) except KeyError: pass except Exception as ex: print(ex) if code is not None: filename = "gene_association.%s.tar.gz" % code if filename in self.annotationFiles.values(): self.annotationIndex = \ [i for i, name in enumerate(self.annotationCodes) \ if self.annotationFiles[name] == filename].pop() self.useAttrNames = data_hints.get_hint(data, "genesinrows", self.useAttrNames) self.openContext(data) self.geneAttrIndex = min(self.geneAttrIndex, len(self.candidateGeneAttrs) - 1) if len(self.candidateGeneAttrs) == 0: self.useAttrNames = True self.geneAttrIndex = -1 elif self.geneAttrIndex < len(self.candidateGeneAttrs): self.geneAttrIndex = len(self.candidateGeneAttrs) - 1 self._updateEnrichment()
def set_data(self, data): """ Set the input profile dataset. """ self.closeContext() self.clear() self.clear_legend() self.data = data if data is not None: n_instances = len(data) n_attrs = len(data.domain.attributes) self.infoLabel.setText("%i genes on input\n%i attributes" % (n_instances, n_attrs)) if is_discrete(data.domain.class_var): class_vals = data.domain.class_var.values else: class_vals = [] self.classes = list(class_vals) self.class_colors = \ colorpalette.ColorPaletteGenerator(len(class_vals)) self.selected_classes = list(range(len(class_vals))) for i in range(len(class_vals)): item = self.group_listbox.item(i) item.setIcon(colorpalette.ColorPixmap(self.class_colors[i])) variables = data.domain.variables + data.domain.metas annotvars = [ var for var in variables if is_discrete(var) or is_string(var) ] for var in annotvars: self.annot_cb.addItem(*gui.attributeItem(var)) if data.domain.class_var in annotvars: self.annot_index = annotvars.index(data.domain.class_var) self.annotation_variables = annotvars self.openContext(data) if n_attrs: self._setup_plot() self.commit()
def add_row(self, attr=None, condition_type=None, condition_value=None): model = self.cond_list.model() row = model.rowCount() model.insertRow(row) attr_combo = QtGui.QComboBox() attr_combo.row = row for var in chain(self.data.domain.variables, self.data.domain.metas): attr_combo.addItem(*gui.attributeItem(var)) attr_combo.setCurrentIndex(attr or 0) self.cond_list.setCellWidget(row, 0, attr_combo) self.remove_all_button.setDisabled(False) self.set_new_operators(attr_combo, attr is not None, condition_type, condition_value) attr_combo.currentIndexChanged.connect( lambda _: self.set_new_operators(attr_combo, False)) self.cond_list.resizeRowToContents(row)
def setDataset(self, data=None): self.closeContext() self.clear() self.clusterDataset = data if data is not None: domain = data.domain allvars = domain.variables + domain.metas self.candidateGeneAttrs = [var for var in allvars if isstring(var)] self.geneAttrIndexCombo.clear() for var in self.candidateGeneAttrs: self.geneAttrIndexCombo.addItem(*gui.attributeItem(var)) taxid = data_hints.get_hint(data, "taxid", "") try: code = go.from_taxid(taxid) except KeyError: pass else: _c2i = { a.orgcode: i for i, a in enumerate(self.availableAnnotations) } try: self.annotationIndex = _c2i[code] except KeyError: pass self.useAttrNames = data_hints.get_hint(data, "genesinrows", self.useAttrNames) self.openContext(data) self.geneAttrIndex = min(self.geneAttrIndex, len(self.candidateGeneAttrs) - 1) if len(self.candidateGeneAttrs) == 0: self.useAttrNames = True self.geneAttrIndex = -1 elif self.geneAttrIndex < len(self.candidateGeneAttrs): self.geneAttrIndex = len(self.candidateGeneAttrs) - 1 self.__invalidate()
def add_row(self, attr=None, condition_type=None, condition_value=None): model = self.cond_list.model() row = model.rowCount() model.insertRow(row) attr_combo = QtGui.QComboBox( minimumContentsLength=12, sizeAdjustPolicy=QtGui.QComboBox.AdjustToMinimumContentsLengthWithIcon) attr_combo.row = row for var in chain(self.data.domain.variables, self.data.domain.metas): attr_combo.addItem(*gui.attributeItem(var)) attr_combo.setCurrentIndex(attr or 0) self.cond_list.setCellWidget(row, 0, attr_combo) self.remove_all_button.setDisabled(False) self.set_new_operators(attr_combo, attr is not None, condition_type, condition_value) attr_combo.currentIndexChanged.connect( lambda _: self.set_new_operators(attr_combo, False)) self.cond_list.resizeRowToContents(row)
def setData(self, data=None): """Set the input dataset with query gene names""" if self.__state & OWSetEnrichment.Initializing: self.__initialize_finish() self.error(0) self.closeContext() self.clear() self.groupsWidget.clear() self.data = data if data is not None: varlist = [ var for var in data.domain.variables + data.domain.metas if isinstance(var, Orange.data.StringVariable) ] self.geneAttrs = varlist for var in varlist: self.geneAttrComboBox.addItem(*gui.attributeItem(var)) oldtaxid = self.taxid self.geneattr = min(self.geneattr, len(self.geneAttrs) - 1) taxid = data_hints.get_hint(data, "taxid", "") if taxid in self.taxid_list: self.speciesIndex = self.taxid_list.index(taxid) self.taxid = taxid self.genesinrows = data_hints.get_hint(data, "genesinrows", self.genesinrows) self.openContext(data) if oldtaxid != self.taxid: self.taxid = "< Do not look >" self.setCurrentOrganism(taxid) self.refreshHierarchy() self._invalidate()
def setDataset(self, data=None): self.closeContext() self.clear() self.clusterDataset = data if data is not None: domain = data.domain allvars = domain.variables + domain.metas self.candidateGeneAttrs = [var for var in allvars if isstring(var)] self.geneAttrIndexCombo.clear() for var in self.candidateGeneAttrs: self.geneAttrIndexCombo.addItem(*gui.attributeItem(var)) taxid = data_hints.get_hint(data, "taxid", "") try: code = go.from_taxid(taxid) except KeyError: pass else: _c2i = {a.orgcode: i for i, a in enumerate(self.availableAnnotations)} try: self.annotationIndex = _c2i[code] except KeyError: pass self.useAttrNames = data_hints.get_hint(data, "genesinrows", self.useAttrNames) self.openContext(data) self.geneAttrIndex = min(self.geneAttrIndex, len(self.candidateGeneAttrs) - 1) if len(self.candidateGeneAttrs) == 0: self.useAttrNames = True self.geneAttrIndex = -1 elif self.geneAttrIndex < len(self.candidateGeneAttrs): self.geneAttrIndex = len(self.candidateGeneAttrs) - 1 self.__invalidate()
def setData(self, data=None): """Set the input dataset with query gene names""" if self.__state & OWSetEnrichment.Initializing: self.__initialize_finish() self.Error.clear() self.closeContext() self.clear() self.groupsWidget.clear() self.data = data if data is not None: varlist = [var for var in data.domain.variables + data.domain.metas if isinstance(var, Orange.data.StringVariable)] self.geneAttrs = varlist for var in varlist: self.geneAttrComboBox.addItem(*gui.attributeItem(var)) oldtaxid = self.taxid self.geneattr = min(self.geneattr, len(self.geneAttrs) - 1) taxid = data_hints.get_hint(data, "taxid", "") if taxid in self.taxid_list: self.speciesIndex = self.taxid_list.index(taxid) self.taxid = taxid self.genesinrows = data_hints.get_hint( data, "genesinrows", self.genesinrows) self.openContext(data) if oldtaxid != self.taxid: self.taxid = "< Do not look >" self.setCurrentOrganism(taxid) self.refreshHierarchy() self._invalidate()
def setDataset(self, data=None): self.closeContext() self.clear() self.clusterDataset = data if data is not None: domain = data.domain allvars = domain.variables + domain.metas self.candidateGeneAttrs = [var for var in allvars if isstring(var)] self.geneAttrIndexCombo.clear() for var in self.candidateGeneAttrs: self.geneAttrIndexCombo.addItem(*gui.attributeItem(var)) tax_id = data_hints.get_hint(data, TAX_ID, '') if tax_id is not None: _c2i = { a.taxid: i for i, a in enumerate(self.availableAnnotations) } try: self.annotationIndex = _c2i[tax_id] except KeyError: pass self.useAttrNames = data_hints.get_hint(data, GENE_NAME, default=self.useAttrNames) self.geneAttrIndex = min(self.geneAttrIndex, len(self.candidateGeneAttrs) - 1) if len(self.candidateGeneAttrs) == 0: self.useAttrNames = True self.geneAttrIndex = -1 elif self.geneAttrIndex < len(self.candidateGeneAttrs): self.geneAttrIndex = len(self.candidateGeneAttrs) - 1 self.__invalidate()
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 is not None: self.geneAttrComboBox.clear() self.attributes = \ [attr for attr in data.domain.variables + data.domain.metas if isinstance(attr, (Orange.data.StringVariable, Orange.data.DiscreteVariable))] for var in self.attributes: self.geneAttrComboBox.addItem(*gui.attributeItem(var)) 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.gene_attr = min(self.gene_attr, len(self.attributes) - 1) if self.taxid in self.organisms: self.organism_index = self.organisms.index(self.taxid) else: self.organism_index = 0 self.taxid = self.organisms[self.organism_index] self.updateInfoItems() else: self.clear()
def handle_input(self, data): if data: self.input_data = data self.gene_matcher = gene.GeneMatcher(self._get_selected_organism()) self.gene_column_combobox.clear() self.column_candidates = [ attr for attr in data.domain.variables + data.domain.metas if isinstance(attr, (StringVariable, DiscreteVariable)) ] for var in self.column_candidates: self.gene_column_combobox.addItem(*attributeItem(var)) self.tax_id = str(data_hints.get_hint(self.input_data, TAX_ID)) self.use_attr_names = data_hints.get_hint( self.input_data, GENE_NAME, default=self.use_attr_names) self.gene_col_index = min(self.gene_col_index, len(self.column_candidates) - 1) if self.tax_id in self.organisms: self.selected_organism = self.organisms.index(self.tax_id) self.on_input_option_change()
def handle_input(self, data): if data: self.input_data = data self.gene_column_combobox.clear() self.column_candidates = [ attr for attr in data.domain.variables + data.domain.metas if isinstance(attr, (StringVariable, DiscreteVariable)) ] for var in self.column_candidates: self.gene_column_combobox.addItem(*attributeItem(var)) self.tax_id = str(self.input_data.attributes.get(TAX_ID, '')) self.use_attr_names = self.input_data.attributes.get( GENE_AS_ATTRIBUTE_NAME, self.use_attr_names) self.gene_col_index = min(self.gene_col_index, len(self.column_candidates) - 1) if self.tax_id in self.organisms: self.selected_organism = self.organisms.index(self.tax_id) self.on_input_option_change()
def standarditem_from_var(var): item = QtGui.QStandardItem(var.name) _, icon = _gui.attributeItem(var) item.setIcon(icon) item.setToolTip(itemmodels.Variable)