source: orange-bioinformatics/Orange/bioinformatics/widgets/prototypes/OWNormalization.py @ 1625:cefeb35cbfc9

Revision 1625:cefeb35cbfc9, 2.0 KB checked in by mitar, 2 years ago (diff)

Moving files around.

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