Changeset 1322:eff7f5df83a5 in orange-bioinformatics


Ignore:
Timestamp:
01/24/11 11:19:39 (3 years ago)
Author:
ales_erjavec <ales.erjavec@…>
Branch:
default
Convert:
8505ca8d400a9e97bb93b275350411858807726f
Message:
  • filter out attribute label keys with only one distinct value (would raise a zero division error)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • widgets/OWVulcanoPlot.py

    r1274 r1322  
    1111import OWGUI 
    1212import orange 
     13import itertools 
    1314from math import log 
    1415from statc import mean, ttest_ind 
     
    344345    def setTargetCombo(self): 
    345346        if self.genesInColumns: 
    346             self.targets = sorted(reduce(set.union, [attr.attributes.items() for attr in (self.data.domain.attributes if self.data else [])], set())) 
     347            items = set(reduce(list.__add__, [attr.attributes.items() for attr in (self.data.domain.attributes if self.data else [])], [])) 
     348            grouped = itertools.groupby(sorted(items), key=lambda pair: pair[0]) 
     349            targets = [(key, [value for _, value in group]) for key, group in grouped] 
     350            targets = [(key, values) for key, values in targets if len(values) > 1] 
     351             
     352            self.targets = [(key, value) for key, values in targets for value in values] 
    347353            measurements = [attr.attributes.items() for attr in (self.data.domain.attributes if self.data else [])] 
    348354            targets = ["%s: %s" % t for t in self.targets] 
Note: See TracChangeset for help on using the changeset viewer.