source: orange-bioinformatics/orangecontrib/bio/widgets/prototypes/OWNormalization.py @ 1873:0810c5708cc5

Revision 1873:0810c5708cc5, 2.1 KB checked in by Ales Erjavec <ales.erjavec@…>, 6 months ago (diff)

Moved '_bioinformatics' into orangecontrib namespace.

Line 
1"""
2<name>Normalization</name>
3<description>Gene Expression data normalization</description>
4<prototype>1</prototype>
5"""
6
7from __future__ import absolute_import
8
9import os, sys
10
11import Orange
12from Orange.OrangeWidgets import OWGUI
13from Orange.OrangeWidgets.OWWidget import *
14
15from ... import obiDifscale
16
17class OWNormalization(OWWidget):
18    settingsList = []
19   
20    METHODS = ["Median", "Quantile"]
21    def __init__(self, parent=None, signalManager=None, title="Differentiation Scale"):
22        OWWidget.__init__(self, parent, signalManager, title, wantMainArea=False)
23       
24        self.inputs = [("Data 1", Orange.data.Table, self.set_data1), ("Data 2", Orange.data.Table, self.set_data2)]
25        self.outputs = [("Normalized Data 1", Orange.data.Table), ("Normalized Data 2", Orange.data.Table)]
26       
27        self.selected_method = "Median"
28       
29        #####
30        # GUI
31        #####
32       
33        OWGUI.comboBox(self.controlArea, self, "selected_method",
34                       box="Method",
35                       tooltip="Normalization type",
36                       items=self.METHODS,
37                       sendSelectedValue=True,
38                       callback=self.on_method_changed)
39       
40        self.data1 = None
41        self.data2 = None
42       
43        self.resize(200, 50)
44       
45    def set_data1(self, data=None):
46        self.data1 = data
47   
48    def set_data2(self, data=None):
49        self.data2 = data
50       
51    def handleNewSignals(self):
52        self.run_normalization()
53   
54    def on_method_changed(self):
55        self.run_normalization()
56       
57    def run_normalization(self):
58        if self.data1 is not None:
59            norm1, norm2 = obiDifscale.normalize(self.data1, self.data2, type=self.selected_method.lower())
60            self.send("Normalized Data 1", norm1)
61            self.send("Normalized Data 2", norm2)
62        else:
63            self.send("Normalized Data 1", None)
64            self.send("Normalized Data 2", None)
65           
66if __name__ == "__main__":
67    app = QApplication([])
68    w = OWNormalization()
69    data = Orange.data.Table("GDS")
70    w.show()
71    app.exec_()
Note: See TracBrowser for help on using the repository browser.