Changeset 1877:2a17616eb737 in orange-bioinformatics for orangecontrib/bio/widgets/OWSetEnrichment.py


Ignore:
Timestamp:
10/09/13 11:56:52 (6 months ago)
Author:
Ales Erjavec <ales.erjavec@…>
Branch:
default
Parents:
1876:98f567fbb6f9 (diff), 1862:49d9912ff84f (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merged biolab/orange-bioinformatics into default

Fixed conflicts in orangecontrib/bio/widgets/OWSetEnrichment.py

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orangecontrib/bio/widgets/OWSetEnrichment.py

    r1874 r1877  
    2727 
    2828REPLACES = ["_bioinformatics.widgets.OWSetEnrichment.OWSetEnrichment"] 
     29 
     30 
     31def gsname(geneset): 
     32    return geneset.name if geneset.name else geneset.id 
    2933 
    3034 
     
    260264#            print self.speciesIndex 
    261265 
    262             self.setHierarchy(self.getHierarchy(taxid=self.taxid_list[self.speciesIndex])) 
     266            self.setHierarchy(*self.getHierarchy(taxid=self.taxid_list[self.speciesIndex])) 
    263267 
    264268            self.loadedGenematcher = "None" 
     
    281285            collect(collection[t_id], hierarchy) 
    282286 
    283         #add genesets without species identifiers 
    284         collection[taxid].update(collection[None]) 
    285         return collection[taxid] 
    286  
    287     def setHierarchy(self, hierarchy): 
     287        return (taxid, collection[taxid]), (None, collection[None]) 
     288 
     289    def setHierarchy(self, hierarchy, hierarchy_noorg): 
    288290        self.groupsWidgetItems = {} 
    289         def fill(col, parent, full=()): 
     291        def fill(col, parent, full=(), org=""): 
    290292            for key, value in sorted(col.items()): 
    291293                full_cat = full + (key,) 
     
    298300                item.setExpanded(True) 
    299301                item.category = full_cat 
     302                item.organism = org 
    300303                self.groupsWidgetItems[full_cat] = item 
    301                 fill(value, item, full_cat) 
    302  
    303         fill(hierarchy, self.groupsWidget) 
     304                fill(value, item, full_cat, org=org) 
     305 
     306        fill(hierarchy[1], self.groupsWidget, org=hierarchy[0]) 
     307        fill(hierarchy_noorg[1], self.groupsWidget, org=hierarchy_noorg[0]) 
    304308 
    305309#    def updateCategoryCounts(self): 
     
    308312 
    309313    def selectedCategories(self): 
    310         taxid = self.taxid_list[self.speciesIndex] 
    311         return [(key, taxid) for key, check in self.getHierarchyCheckState().items() if check == Qt.Checked] 
     314        return [(key, org) for (key, org), check in self.getHierarchyCheckState().items() if check == Qt.Checked] 
    312315 
    313316    def getHierarchyCheckState(self): 
     
    316319            name = str(item.data(0, Qt.DisplayRole).toString()) 
    317320            full_cat = full + (name,) 
    318             result = [(full_cat, checked)] 
     321            result = [((full_cat, item.organism), checked)] 
    319322            for i in range(item.childCount()): 
    320323                result.extend(collect(item.child(i), full_cat)) 
     
    326329 
    327330    def subsetSelectionChanged(self, item, column): 
     331        #FIXME this should also recompute FDR 
    328332        self.categoriesCheckState = self.getHierarchyCheckState() 
    329  
    330333        categories = self.selectedCategories() 
    331334        if not set(categories) <= set(self.currentAnnotatedCategories): 
     
    475478        for i, (geneset, (cmapped, rmapped, p_val, enrichment)) in enumerate(results): 
    476479            if len(cmapped) > 0: 
    477                 item = MyTreeWidgetItem(self.annotationsChartView, [" ".join(geneset.hierarchy), geneset.name]) 
     480                item = MyTreeWidgetItem(self.annotationsChartView, [" ".join(geneset.hierarchy), gsname(geneset)]) 
    478481                item.setData(2, Qt.DisplayRole, QVariant(countFmt % (len(cmapped), 100.0*len(cmapped)/countAll))) 
    479482                item.setData(2, Qt.ToolTipRole, QVariant(len(cmapped))) # For filtering 
     
    499502 
    500503        replace = lambda s:s.replace(",", " ").replace("(", " ").replace(")", " ") 
    501         self._completerModel = completerModel = QStringListModel(sorted(reduce(set.union, [[geneset.name] + replace(geneset.name).split() for geneset, (c, _, _, _) in results if c], set()))) 
     504        self._completerModel = completerModel = QStringListModel(sorted(reduce(set.union, [[gsname(geneset)] + replace(gsname(geneset)).split() for geneset, (c, _, _, _) in results if c], set()))) 
    502505        self.filterCompleter.setModel(completerModel) 
    503506 
     
    522525            item_cat = str(item.data(0, Qt.EditRole).toString()) 
    523526            count, pval = _toPyObject(item.data(2, Qt.ToolTipRole)), _toPyObject(item.data(4, 42)) 
    524             geneset = item.geneset.name.lower() 
     527            geneset = gsname(item.geneset).lower() 
    525528            hidden = item_cat not in categories or (self.useMinCountFilter and count < self.minClusterCount) or \ 
    526529                     (self.useMaxPValFilter and pval > self.maxPValue) or filterString not in geneset 
Note: See TracChangeset for help on using the changeset viewer.