Example #1
0
    def __init__(self,parent=None, signalManager = None):
        OWWidget.__init__(self, parent, signalManager, "&Display Motifs", 0)

        # set default settings
        self.colorBy = None
        self.pvalThresholdIndex = None
        self.pvalThreshold = None

        #load settings
        self.loadSettings()

        # GUI
        self.graph = OWGraph(self.mainArea)
        self.graph.setYRlabels(None)
        self.graph.enableGridXB(0)
        self.graph.enableGridYL(1)
        self.graph.setAxisMaxMinor(QwtPlot.xBottom, 10)
        self.graph.setAxisMaxMajor(QwtPlot.xBottom, 10)
        self.graph.setAxisAutoScale(QwtPlot.xBottom)
        self.graph.setAxisScale(QwtPlot.xBottom, -1020, 0, 0)
        self.mainArea.layout().addWidget(self.graph)
        
        # inputs
        # data and graph temp variables
        self.inputs = [("Examples", ExampleTable, self.cdata, Default), ("Genes", list, self.newGeneList, Default), ("Motifs", list, self.newMotifList, Default)]

        self.data = None
        self.motifLines = []
        self.visibleValues = []
        self.valueToCurve = {}
        self.allGenes = [] ## genes displayed always in same order
        self.geneList = [] ## selected genes
        self.motifList = [] ## selected motifs
        self.valuesPresentInData = []

        self.clusterPostProbThreshold = 0

        # GUI
        self.selValues = OWGUI.widgetBox(self.controlArea, "Values")
        self.selcolorBy = OWGUI.widgetBox(self.controlArea, "Color By")

        self.colorByCombo = OWGUI.comboBox(self.selcolorBy, self, "colorBy",
                                           items=[],
                                           callback=self.colorByChanged)
        
        self.pvalThresholdCombo = OWGUI.comboBox(self.selValues, self, "pvalThresholdIndex",
                                                 items=[],
                                                 callback=self.pvalThresholdChanged)
        
        self.valuesQLB = QListWidget(self.selValues)
        self.valuesQLB.setSelectionMode(QListWidget.MultiSelection)
        self.connect(self.valuesQLB, SIGNAL("itemSelectionChanged()"), self.valuesSelectionChange)
        self.selValues.layout().addWidget(self.valuesQLB)
        
        self.unselectAllQLB = OWGUI.button(self.selValues, self, "Unselect all",
                                           callback = self.unselAll)
Example #2
0
    def __init__(self, parent=None, signalManager=None,
                 title="Databases Pack"):

        super(OWDatabasesPack, self).__init__(
            parent, signalManager, title, wantMainArea=False)

        self.fileslist = [("Taxonomy", "ncbi_taxonomy.tar.gz")]
        self.downloadurl = "https://dl.dropboxusercontent.com/u/100248799/sf_pack.tar.gz"
        self.downloadmessage = (
            "Downloading a subset of available databases for a smoother " +
            "ride through the workshop"
        )
        self.loadSettings()
        self._tmpfile = None
        self.reply = None

        # Locks held on server files
        self.locks = []
        self.net_manager = QNetworkAccessManager()
        # Lock all files in files list so any other (in process) atempt to
        # download the files waits)
        box = OWGUI.widgetBox(self.controlArea, "Info")
        self.info = OWGUI.widgetLabel(box, self.downloadmessage)
        self.info.setWordWrap(True)

        box = OWGUI.widgetBox(self.controlArea, "Status")
        self.statusinfo = OWGUI.widgetLabel(box, "Please wait")
        self.statusinfo.setWordWrap(True)
        self.progressbar = QProgressBar()
        box.layout().addWidget(self.progressbar)

        self.setMinimumWidth(250)

        already_available = [(domain, filename)
                             for domain in serverfiles.listdomains()
                             for filename in serverfiles.listfiles(domain)]

        if set(self.fileslist) <= set(already_available):
            # All files are already downloaded
            self.statusinfo.setText("All files already available")
            self.setStatusMessage("Done")
        else:
            for domain, filename in self.fileslist + [("_tmp_cache_", "pack")]:
                manager = serverfiles._lock_file(domain, filename)
                try:
                    manager.__enter__()
                except Exception:
                    warnings.warn("Could not acquire lock for {0} {0}"
                                  .format(domain, filename))
                    self.warning(0, "...")
                else:
                    self.locks.append(manager)

            QTimer.singleShot(0, self.show)
            QTimer.singleShot(0, self.run)
Example #3
0
    def __init__(self, parent=None, signalManager=None, title="Databases Pack"):

        super(OWDatabasesPack, self).__init__(parent, signalManager, title, wantMainArea=False)

        self.fileslist = [("Taxonomy", "ncbi_taxonomy.tar.gz")]
        self.downloadurl = "https://dl.dropboxusercontent.com/u/100248799/sf_pack.tar.gz"
        self.downloadmessage = (
            "Downloading a subset of available databases for a smoother " + "ride through the workshop"
        )
        self.loadSettings()
        self._tmpfile = None
        self.reply = None

        # Locks held on server files
        self.locks = []
        self.net_manager = QNetworkAccessManager()
        # Lock all files in files list so any other (in process) atempt to
        # download the files waits)
        box = OWGUI.widgetBox(self.controlArea, "Info")
        self.info = OWGUI.widgetLabel(box, self.downloadmessage)
        self.info.setWordWrap(True)

        box = OWGUI.widgetBox(self.controlArea, "Status")
        self.statusinfo = OWGUI.widgetLabel(box, "Please wait")
        self.statusinfo.setWordWrap(True)
        self.progressbar = QProgressBar()
        box.layout().addWidget(self.progressbar)

        self.setMinimumWidth(250)

        already_available = [
            (domain, filename) for domain in serverfiles.listdomains() for filename in serverfiles.listfiles(domain)
        ]

        if set(self.fileslist) <= set(already_available):
            # All files are already downloaded
            self.statusinfo.setText("All files already available")
            self.setStatusMessage("Done")
        else:
            for domain, filename in self.fileslist + [("_tmp_cache_", "pack")]:
                manager = serverfiles._lock_file(domain, filename)
                try:
                    manager.__enter__()
                except Exception:
                    warnings.warn("Could not acquire lock for {0} {0}".format(domain, filename))
                    self.warning(0, "...")
                else:
                    self.locks.append(manager)

            QTimer.singleShot(0, self.show)
            QTimer.singleShot(0, self.run)
Example #4
0
    def Commit(self):
        if not self.dbc:
            self.Connect()
        allTables = []

        import time
        start = time.time()

        pb = OWGUI.ProgressBar(self, iterations=1000)

        table = None

        ids = []
        for item in self.experimentsWidget.selectedItems():
            ids += str(item.text(5)).split(",")

        table = self.dbc.get_single_data(
            ids=ids,
            callback=pb.advance,
            exclude_constant_labels=self.excludeconstant)

        end = int(time.time() - start)

        pb.finish()

        #self.send("Example table", None)
        #        table.taxid = "352472"
        #        table.genesinrows = False

        from Orange.orng.orngDataCaching import data_hints
        data_hints.set_hint(table, "taxid", "352472", 10.0)
        data_hints.set_hint(table, "genesinrows", False, 10.0)

        self.send("Example table", table)
Example #5
0
    def __init__(self, parent=None, signalManager=None):
        OWWidget.__init__(self,
                          parent,
                          signalManager,
                          'Data Files Selector',
                          wantMainArea=0,
                          resizingEnabled=1)

        self.callbackDeposit = []

        self.inputs = [("Structured Data", DataFiles, self.onDataInput)]
        self.outputs = [("Examples", ExampleTable),
                        ("Structured Data", DataFiles)]

        self.dataStructure = None
        self.datasets = None
        self.lastSentIds = []

        # Settings
        self.applyOnChange = 0
        self.loadSettings()

        # GUI
        # info
        box = OWGUI.widgetBox(self.controlArea, "Info", addSpace=True)
        self.infoa = OWGUI.widgetLabel(box, 'No data loaded.')
        self.infob = OWGUI.widgetLabel(box, '')
        self.infoc = OWGUI.widgetLabel(box, '')

        # LIST VIEW
        frmListView = OWGUI.widgetBox(self.controlArea, None, addSpace=True)
        self.tree = QTreeWidget(frmListView)
        self.tree.setSelectionMode(QAbstractItemView.MultiSelection)
        self.tree.setHeaderLabel("Directory/Data File")
        frmListView.layout().addWidget(self.tree)
        self.connect(self.tree, SIGNAL('itemSelectionChanged()'),
                     self.selectionChanged)

        # Output
        box = OWGUI.widgetBox(self.controlArea, "Output", addSpace=True)
        OWGUI.checkBox(box, self, 'applyOnChange',
                       'Commit data on selection change')
        self.commitBtn = OWGUI.button(box,
                                      self,
                                      "Commit",
                                      callback=self.sendData,
                                      disabled=1)
        self.resize(300, 600)
Example #6
0
    def __init__(self, parent=None, signalManager = None):
        OWWidget.__init__(self, parent, signalManager, "Save Data Files", wantMainArea = 0, resizingEnabled = 1)

        self.inputs = [("Structured Data", DataFiles, self.structuredData, Default)]
        self.outputs = []
        self.dataStructure = None

        # Settings
        self.recentDirs=[]
        self.selectedDirName = "(none)"
        self.loadSettings()

        # GUI
        rfbox = OWGUI.widgetBox(self.controlArea, "Directory", orientation="horizontal", addSpace = True)
        self.dircombo = QComboBox(rfbox)
        rfbox.layout().addWidget(self.dircombo)
        browse = OWGUI.button(rfbox, self, '&...', callback = self.browseDirectory, disabled=0)
        browse.setMaximumWidth(25)
        # info
        box = OWGUI.widgetBox(self.controlArea, "Info", addSpace = True)
        self.infoa = OWGUI.widgetLabel(box, 'No data on input.')
        # Output
        box = OWGUI.widgetBox(self.controlArea, "Output", addSpace = True)
        self.save = OWGUI.button(box, self, '&Save', callback = self.saveData, disabled=1)
        self.adjustSize()
           
        # initial settings            
        self.recentDirs=filter(os.path.exists, self.recentDirs)
        self.setDirlist()
        self.dircombo.setCurrentIndex(0)
        self.resize(300,self.height())
Example #7
0
    def __init__(self, parent=None, signalManager=None):
        OWWidget.__init__(self, parent, signalManager, 'Data Distance')

        self.inputs = [("Structured Data", DataFiles, self.chipdata)]
        self.outputs = [("Distance Matrix", orange.SymMatrix)]

        self.Metrics = 0
        self.loadSettings()
        self.data = []
        ##        self.metrics = [("Euclidean", orange.ExamplesDistanceConstructor_Euclidean),
        ##            ("Manhattan", orange.ExamplesDistanceConstructor_Manhattan),
        ##            ("Hamming", orange.ExamplesDistanceConstructor_Hamming)]
        self.metrics = [("Manhattan", distManhattan),
                        ("Euclidean", distEuclidean),
                        ("1 - (Pearson correlation coefficient)", distPearson),
                        ("1 - (Spearman rank correlation coefficient)",
                         distSpearman)]

        # GUI
        self.mainArea.setFixedWidth(0)
        # Info box
        box = QVGroupBox("Info", self.controlArea)
        self.infoa = QLabel('No data on input.', box)
        self.infob = QLabel('', box)
        OWGUI.separator(self.controlArea)

        # Distance metrics selection
        items = [x[0] for x in self.metrics]
        OWGUI.comboBox(
            self.controlArea,
            self,
            "Metrics",
            box="Distance Metrics",
            items=items,
            tooltip="Metrics to measure distance between data sets.",
            callback=self.onMetricsChange)

        self.resize(384, 138)
Example #8
0
    def __init__(self, parent=None, signalManager = None):
        OWWidget.__init__(self, parent, signalManager, 'Example Selector')
        self.callbackDeposit = []

        self.inputs = [("Example Selection", ExampleSelection, self.loadselection, Multiple + Default), ("Structured Data", DataFiles, self.chipdata)]
        self.outputs = [("Example Selection", ExampleSelection), ("Selected Structured Data", DataFiles, Default), ("Other Structured Data", DataFiles)]

        # Settings
        self.negate = 0
        self.commitOnChange = 1
        self.sendNotSelectedData = 1
        self.loadSettings()

        self.selectors = {}
        self.data = None

        # GUI
        # info
        box = QVGroupBox("Info", self.controlArea)
        self.infoa = QLabel('No data on input.', box)
        self.infob = QLabel('', box)
        OWGUI.separator(self.controlArea)
        box.setMinimumWidth(170)

        # gene selection
        self.layout=QVBoxLayout(self.mainArea)
        box = QVGroupBox("Gene Selection", self.mainArea)
        self.table=QTable(box)
        self.table.setSelectionMode(QTable.NoSelection)
        self.layout.add(box)
        self.table.hide()
        self.drawtable()

        OWGUI.checkBox(box, self, 'negate', 'Negate', callback = self.selectionChange)

        # output
        box = QVGroupBox("Output", self.controlArea)
        OWGUI.checkBox(box, self, 'sendNotSelectedData', 'Send not selected data', callback=self.selectionChange)
        OWGUI.checkBox(box, self, 'commitOnChange', 'Commit data on change')
        self.commitBtn = OWGUI.button(box, self, "Commit", callback=self.senddata, disabled=1)

        self.resize(700,100)
Example #9
0
    def chipdata(self, data):
        self.data = []
        if data:
            self.infob.setText("")
            numFiles = reduce(lambda a, b: a + len(b[1]), data, 0)
            lenSD = len(data)
            self.infoa.setText("%d set%s, total of %d data file%s." %
                               (lenSD, ["", "s"][lenSD != 1], numFiles,
                                ["", "s"][numFiles != 1]))
            numExamplesList = []
            # construct a list of ExampleTable lengths and a list of attribute names
            for (name, etList) in data:
                for et in etList:
                    setattr(et, "dirname", name)
                    setattr(et, "strain", name)
                    self.data.append(et)
                    numExamplesList.append(len(et))
            if len(self.data) > 1:
                # test that files contain the same attributes and equal number of examples
                attrSorted = self.data[0].domain.attributes
                attrSorted.sort()
                numEx = len(self.data[0])
                for et in self.data[1:]:
                    attrSorted2 = et.domain.attributes
                    attrSorted2.sort()
                    if map(lambda x: x.name, attrSorted) != map(
                            lambda x: x.name, attrSorted2):
                        self.data = []
                        self.infob.setText(
                            "Error: data files contain different attributes, aborting distance computation."
                        )
                        return
                    if len(et) != numEx:
                        self.data = []
                        self.infob.setText(
                            "Error: data files contain unequal number of examples, aborting distance computation."
                        )
                        return
                # compute distances
                pb = OWGUI.ProgressBar(self, iterations=len(self.data))
                self.computeMatrix()
                pb.finish()

            else:
                self.data = []
                self.infob.setText(
                    'Error: not enough data, aborting distance computation.')
        else:
            self.infoa.setText('No data on input.')
Example #10
0
    def __init__(self, parent):
        QObject.__init__(self)
        grid = OWGUI.widgetBox(parent, "", orientation = "horizontal")
        grid.setMinimumWidth(250)
        grid.setMinimumHeight(100)

        self.boxes = [ OWGUI.listBox(grid, self) for a in range(2) ]

        for box in self.boxes: 
            #box.setSelectionMode(QListWidget.SingleSelection)
            box.setSelectionMode(QListWidget.MultiSelection)

        self.connect(self.boxes[0], SIGNAL("itemSelectionChanged ()"), self.highlighted1)
        self.connect(self.boxes[1], SIGNAL("itemSelectionChanged ()"), self.highlighted2)

        self.classes = []

        def createSquarePixmap(color = Qt.black):
            return OWGUI.createAttributePixmap("", color)

        self.whiteSq = createSquarePixmap(Qt.white)
        self.marked = [ createSquarePixmap(Qt.red), createSquarePixmap(Qt.blue) ]

        self.classVals = []
Example #11
0
    def update_distances(self, base_indices=()):
        """Recompute the experiment distances.
        """
        distance = self.selected_distance()
        if base_indices == ():
            base_group_index = self.selected_base_group_index()
            base_indices = [ind[base_group_index] \
                            for _, ind in self.groups]

        assert (len(base_indices) == len(self.groups))

        base_distances = []
        attributes = self.data.domain.attributes
        pb = OWGUI.ProgressBar(self, len(self.groups) * \
                               len(attributes))

        cached_distances, filled_set = self.get_cached_distances(distance)

        for (group, indices), base_index in zip(self.groups, base_indices):
            # Base column of the group
            if base_index is not None:
                base_vec = exp.linearize(self.data, [base_index])
                distances = []
                # Compute the distances between base column
                # and all the rest data columns.
                for i in range(len(attributes)):
                    if i == base_index:
                        distances.append(0.0)
                    elif self.get_cached_distance(distance, i,
                                                  base_index) is not None:
                        distances.append(
                            self.get_cached_distance(distance, i, base_index))
                    else:
                        vec_i = exp.linearize(self.data, [i])
                        dist = distance(base_vec, vec_i)
                        self.store_distance(distance, i, base_index, dist)
                        distances.append(dist)
                    pb.advance()

                base_distances.append(distances)
            else:
                base_distances.append(None)

        pb.finish()
        self.distances = base_distances
Example #12
0
    def __init__(self, parent=None, signalManager = None):
        OWWidget.__init__(self, parent, signalManager, 'Data Files Selector', wantMainArea = 0, resizingEnabled = 1)

        self.callbackDeposit = []

        self.inputs = [("Structured Data", DataFiles, self.onDataInput)]
        self.outputs = [("Examples", ExampleTable), ("Structured Data", DataFiles)]

        self.dataStructure = None
        self.datasets = None
        self.lastSentIds = []

        # Settings
        self.applyOnChange = 0
        self.loadSettings()

        # GUI
        # info
        box = OWGUI.widgetBox(self.controlArea, "Info", addSpace = True)
        self.infoa = OWGUI.widgetLabel(box, 'No data loaded.')
        self.infob = OWGUI.widgetLabel(box, '')
        self.infoc = OWGUI.widgetLabel(box, '')
            
        # LIST VIEW
        frmListView = OWGUI.widgetBox(self.controlArea, None, addSpace = True)
        self.tree = QTreeWidget(frmListView)
        self.tree.setSelectionMode(QAbstractItemView.MultiSelection)
        self.tree.setHeaderLabel("Directory/Data File")
        frmListView.layout().addWidget(self.tree)
        self.connect(self.tree,SIGNAL('itemSelectionChanged()'),self.selectionChanged)

        # Output
        box = OWGUI.widgetBox(self.controlArea, "Output", addSpace = True)
        OWGUI.checkBox(box, self, 'applyOnChange', 'Commit data on selection change')
        self.commitBtn = OWGUI.button(box, self, "Commit", callback=self.sendData, disabled=1)
        self.resize(300,600)
Example #13
0
    def __init__(self, parent=None, signalManager=None):
        OWWidget.__init__(self,
                          parent,
                          signalManager,
                          "Save Data Files",
                          wantMainArea=0,
                          resizingEnabled=1)

        self.inputs = [("Structured Data", DataFiles, self.structuredData,
                        Default)]
        self.outputs = []
        self.dataStructure = None

        # Settings
        self.recentDirs = []
        self.selectedDirName = "(none)"
        self.loadSettings()

        # GUI
        rfbox = OWGUI.widgetBox(self.controlArea,
                                "Directory",
                                orientation="horizontal",
                                addSpace=True)
        self.dircombo = QComboBox(rfbox)
        rfbox.layout().addWidget(self.dircombo)
        browse = OWGUI.button(rfbox,
                              self,
                              '&...',
                              callback=self.browseDirectory,
                              disabled=0)
        browse.setMaximumWidth(25)
        # info
        box = OWGUI.widgetBox(self.controlArea, "Info", addSpace=True)
        self.infoa = OWGUI.widgetLabel(box, 'No data on input.')
        # Output
        box = OWGUI.widgetBox(self.controlArea, "Output", addSpace=True)
        self.save = OWGUI.button(box,
                                 self,
                                 '&Save',
                                 callback=self.saveData,
                                 disabled=1)
        self.adjustSize()

        # initial settings
        self.recentDirs = filter(os.path.exists, self.recentDirs)
        self.setDirlist()
        self.dircombo.setCurrentIndex(0)
        self.resize(300, self.height())
Example #14
0
    def __init__(self, parent=None, signalManager=None, name="dictyExpress"):
        OWWidget.__init__(self, parent, signalManager, name)
        self.outputs = [("Example table", ExampleTable)]
        self.serverToken = ""
        self.server = obiDicty.defaddress

        self.platform = None

        self.selectedExperiments = []
        self.buffer = obiDicty.CacheSQLite(bufferfile)

        self.searchString = ""
        self.excludeconstant = False

        box = OWGUI.widgetBox(self.controlArea, "Cache")
        OWGUI.button(box, self, "Clear cache", callback=self.clear_buffer)

        OWGUI.checkBox(self.controlArea, self, "excludeconstant",
                       "Exclude labels with constant values")

        OWGUI.button(self.controlArea, self, "&Commit", callback=self.Commit)
        box = OWGUI.widgetBox(self.controlArea, "Server")
        OWGUI.lineEdit(box,
                       self,
                       "serverToken",
                       "Token",
                       callback=self.Connect)
        OWGUI.rubber(self.controlArea)

        OWGUI.lineEdit(self.mainArea,
                       self,
                       "searchString",
                       "Search",
                       callbackOnType=True,
                       callback=self.SearchUpdate)
        self.experimentsWidget = QTreeWidget()
        self.experimentsWidget.setHeaderLabels([
            "Strain", "Treatment", "Growth condition", "Platform", "N", "Chips"
        ])
        self.experimentsWidget.setSelectionMode(QTreeWidget.ExtendedSelection)
        self.experimentsWidget.setRootIsDecorated(False)
        self.experimentsWidget.setSortingEnabled(True)
        ##        self.experimentsWidget.setAlternatingRowColors(True)

        self.mainArea.layout().addWidget(self.experimentsWidget)

        self.loadSettings()
        self.dbc = None

        QTimer.singleShot(0, self.UpdateExperiments)

        self.resize(800, 600)
    def __init__(self, parent=None, signalManager=None,
                 title="Quality Control"):
        OWWidget.__init__(self, parent, signalManager, title,
                          wantGraph=True)

        self.inputs = [("Experiment Data", Orange.data.Table, self.set_data)]

        ## Settings
        self.selected_distance_index = 0

        ## Attributes
        self.data = None
        self.distances = None
        self.groups = None
        self.unique_pos = None
        self.base_group_index = 0

        ## GUI
        box = OWGUI.widgetBox(self.controlArea, "Info")
        self.info_box = OWGUI.widgetLabel(box, "\n")

        ## Separate By box
        box = OWGUI.widgetBox(self.controlArea, "Separate By")
        self.split_by_model = PyListModel()
        self.split_by_view = QListView()
        self.split_by_view.setSelectionMode(QListView.ExtendedSelection)
        self.split_by_view.setModel(self.split_by_model)
        box.layout().addWidget(self.split_by_view)

        self.connect(self.split_by_view.selectionModel(),
                     SIGNAL("selectionChanged(QItemSelection, QItemSelection)"),
                     self.on_split_key_changed)

        ## Sort By box
        box = OWGUI.widgetBox(self.controlArea, "Sort By")
        self.sort_by_model = PyListModel()
        self.sort_by_view = QListView()
        self.sort_by_view.setSelectionMode(QListView.ExtendedSelection)
        self.sort_by_view.setModel(self.sort_by_model)
        box.layout().addWidget(self.sort_by_view)
        
        self.connect(self.sort_by_view.selectionModel(),
                     SIGNAL("selectionChanged(QItemSelection, QItemSelection)"),
                     self.on_sort_key_changed)

        ## Distance box
        box = OWGUI.widgetBox(self.controlArea, "Distance Measure")
        OWGUI.comboBox(box, self, "selected_distance_index",
                       items=[t[0] for t in self.DISTANCE_FUNCTIONS],
                       callback=self.on_distance_measure_changed)

        self.connect(self.graphButton,
                     SIGNAL("clicked()"),
                     self.save_graph)
        
        self.scene = QGraphicsScene()
        self.scene_view = QualityGraphicsView(self.scene)
        self.scene_view.setRenderHints(QPainter.Antialiasing)
        self.scene_view.setAlignment(Qt.AlignLeft | Qt.AlignVCenter)
        self.mainArea.layout().addWidget(self.scene_view)
        
        self.connect(self.scene_view,
                     SIGNAL("view_size_changed(QSize)"),
                     self.on_view_resize)

        self._disable_updates = False
        self._cached_distances = {}
        self._base_index_hints = {}
        self.main_widget = None
        
        self.resize(800, 600)
Example #16
0
 def __init__(self, parent=None, signalManager=None, name="Normalize Expression Array"):
     OWWidget.__init__(self, parent, signalManager, name, wantGraph=True)
     
     self.inputs = [("Expression array", ExampleTable, self.setData)]
     self.outputs = [("Normalized expression array", ExampleTable, Default), ("Filtered expression array", ExampleTable)]
     
     self.selectedGroup = 0
     self.selectedCenterMethod = 0
     self.selectedMergeMethod = 0
     self.zCutoff = 1.96
     self.appendZScore = False
     self.appendRIValues = False
     self.autoCommit = False
     
     self.loadSettings()
     ## GUI
     self.infoBox = OWGUI.widgetLabel(OWGUI.widgetBox(self.controlArea, "Info", addSpace=True),
                                      "No data on input.")
     
     box = OWGUI.widgetBox(self.controlArea, "Split by", addSpace=True)
     self.groupCombo = OWGUI.comboBox(box, self, "selectedGroup", 
                                      callback=self.onGroupSelection
                                      )
     
     self.centerCombo = OWGUI.comboBox(self.controlArea, self, "selectedCenterMethod",
                                       box="Center Fold-change Using",
                                       items=[name for name, _ in self.CENTER_METHODS],
                                       callback=self.onCenterMethodChange,
                                       addSpace=True
                                       )
     
     self.mergeCombo = OWGUI.comboBox(self.controlArea, self, "selectedMergeMethod",
                                      box="Merge Replicates",
                                      items=[name for name, _ in self.MERGE_METHODS],
                                      tooltip="Select the method for replicate merging",
                                      callback=self.onMergeMethodChange,
                                      addSpace=True
                                      )
     
     box = OWGUI.doubleSpin(self.controlArea, self, "zCutoff", 0.0, 3.0, 0.01,
                            box="Z-Score Cutoff",
                            callback=[self.replotMA, self.commitIf])
     
     OWGUI.separator(self.controlArea)
     
     box = OWGUI.widgetBox(self.controlArea, "Ouput")
     OWGUI.checkBox(box, self, "appendZScore", "Append Z-Scores",
                    tooltip="Append calculated Z-Scores to output",
                    callback=self.commitIf
                    )
     
     OWGUI.checkBox(box, self, "appendRIValues", "Append Log Ratio and Intensity values",
                    tooltip="Append calculated Log Ratio and Intensity values to output data",
                    callback=self.commitIf
                    )
     
     cb = OWGUI.checkBox(box, self, "autoCommit", "Commit on change",
                    tooltip="Commit data on any change",
                    callback=self.commitIf
                    )
     
     b = OWGUI.button(box, self, "Commit", callback=self.commit)
     OWGUI.setStopper(self, b, cb, "changedFlag", callback=self.commit)
     
     self.connect(self.graphButton, SIGNAL("clicked()"), self.saveGraph)
     
     OWGUI.rubber(self.controlArea)
     self.graph = OWGraph(self.mainArea)
     self.graph.setAxisTitle(QwtPlot.xBottom, "Intensity: log<sub>10</sub>(R*G)")
     self.graph.setAxisTitle(QwtPlot.yLeft, "Log ratio: log<sub>2</sub>(R/G)")
     self.graph.showFilledSymbols = True
     self.mainArea.layout().addWidget(self.graph)
     self.groups = []
     self.split_data = None, None
     self.merged_splits = None, None
     self.centered = None, None
     self.changedFlag = False
     self.data = None
     
     self.resize(800, 600)
Example #17
0
    def __init__(self, parent=None, signalManager = None):
        OWWidget.__init__(self, parent, signalManager, 'ANOVA')
        # input / output data: [("name1", [orange.ExampleTable1a,...]), ("name2", [orange.ExampleTable2a,...])]
        self.inputs = [("Structured Data", DataFiles, self.onDataInput)]
        self.outputs = [("Example Selection", ExampleSelection, Default), ("Selected Structured Data", DataFiles, Default), ("Other Structured Data", DataFiles)]

        # data, p-values, selected examples
        self.dataStructure = None                       # input data
        self.numExamples = 0
        self.numVariables = 0
        self.ps = Numeric.ones((3,0), Numeric.Float)    # p-values: 2D Numeric.array of shape (3, numExamples)
        self.selectorName = ""                          # for Example Selection output: (self.selectorName, [0,1,0,...])

        # Settings
        self.anovaType = OWHypTest.StSST
        self.popMean = 0         # single sample t-test, value to compare to
        self.useFactors = [0,0,0]       # [use factor A, use factor B, use interaction]
        self._interaction = 0           # to store last setting: 0: no interaction, 1: test for interaction effect (set this value manually !!!)
        self.selectorA = True
        self.selectorB = False
        self.selectorI = False
        self.alphaA = "0.05"
        self.alphaB = "0.05"
        self.alphaI = "0.05"
        self.autoUpdateSelName = 1
        self.sendNotSelectedData = 1
        self.sendProbabilities = 0
        self.commitOnChange = 0
        self.loadSettings()

        # GUI
        self.mainArea.setFixedWidth(0)
        ca=QFrame(self.controlArea)
        gl=QGridLayout(ca,4,1,5)
        
        # info
        box = QVGroupBox("Info", ca)
        gl.addWidget(box,0,0)
        self.infoa = QLabel('No data on input.', box)
        self.infob = QLabel('', box)
        self.infoc = QLabel('', box)

        # ANOVA type
        self.boxAnovaType = QVButtonGroup("Statistics", ca)
        gl.addWidget(self.boxAnovaType,1,0)
        self.boxAnovaType.setDisabled(1)

        self.boxAnovaType.setRadioButtonExclusive(1)
        self.boxAnovaType.buttons = []
##        for i,lbl in enumerate(OWHypTest.StNames):
##            w = QRadioButton(lbl, self.boxAnovaType)
##            w.setOn(self.anovaType == i)
##            self.boxAnovaType.buttons.append(w)
##            if i == OWHypTest.StSST:
##                self.boxPopMean = QHBox(self.boxAnovaType)
##                QLabel("             population mean  ", self.boxPopMean)
##                OWGUI.lineEdit(self.boxPopMean, self, "popMean", callback=self.onPopMeanChange)
        for i,lbl in enumerate(OWHypTest.StNames):
            w = QRadioButton(lbl, self.boxAnovaType)
            w.setOn(self.anovaType == i)
            self.boxAnovaType.buttons.append(w)
            if i == OWHypTest.StSST:
                self.boxPopMean = QHBox(self.boxAnovaType)
                QLabel("       population mean  ", self.boxPopMean)
                OWGUI.lineEdit(self.boxPopMean, self, "popMean", callback=self.onPopMeanChange)
        OWGUI.connectControl(self.boxAnovaType, self, "anovaType", self.onAnovaType, "clicked(int)", OWGUI.CallFront_radioButtons(self.boxAnovaType))
        
        # selection of examples
        self.boxSelection = QVGroupBox("Example Selection", ca)
        gl.addWidget(self.boxSelection,2,0)
        self.lblNumGenes = []   # list of labels
        # selector A
        self.boxSelectorA = QVBox(self.boxSelection)
        self.cbSelectorA = OWGUI.checkBox(self.boxSelectorA, self, "selectorA", "Factor A (variables)", callback=self.onSelectionChange,
                                          tooltip='H0: The mean does not depend on factor A (represented by variables).')
        frmA = QFrame(self.boxSelectorA)
        glA = QGridLayout(frmA,1,3,5)
        leA = OWGUI.lineEdit(frmA, self, "alphaA", orientation="horizontal", controlWidth=None, callback=lambda x=0: self.onAlphaChange(x))
        glA.addWidget(leA,0,1) # Qt.AlignRight
        glA.addWidget(QLabel("     p <= ", frmA), 0,0)
        self.lblNumGenes.append(QLabel('', frmA))
        glA.addWidget(self.lblNumGenes[-1],0,2) # Qt.AlignRight | 0x22

        # selector B
        self.boxSelectorB = QVBox(self.boxSelection)
        self.cbSelectorB = OWGUI.checkBox(self.boxSelectorB, self, "selectorB", "Factor B (data sets)", callback=self.onSelectionChange,
                                          tooltip='H0: The mean does not depend on factor B (represented by data sets).')
        frmB = QFrame(self.boxSelectorB)
        glB = QGridLayout(frmB,1,3,5)
        leB = OWGUI.lineEdit(frmB, self, "alphaB", orientation="horizontal", callback=lambda x=1: self.onAlphaChange(x))
        glB.addWidget(leB,0,1)
        glB.addWidget(QLabel("     p <= ", frmB), 0,0)
        self.lblNumGenes.append(QLabel('', frmB))
        glB.addWidget(self.lblNumGenes[-1],0,2)
        
        # selector I
        self.boxSelectorI = QVBox(self.boxSelection)
        self.cbSelectorI = OWGUI.checkBox(self.boxSelectorI, self, "selectorI", "Interaction (variables * data sets)", callback=self.onSelectionChange,
                                          tooltip='H0: There is no interaction between factor A and factor B.')
        frmI = QFrame(self.boxSelectorI)
        glI = QGridLayout(frmI,1,3,5)
        leI = OWGUI.lineEdit(frmI, self, "alphaI", orientation="horizontal", callback=lambda x=2: self.onAlphaChange(x))
        ## slider could be used to replace lineEdit (but not sensitive enough)
        ##        self.alphaIf = 0.05
        ##        leI = OWGUI.qwtHSlider(self.boxSelectorI, self, "alphaIf", box="", label="      p < ", labelWidth=None, minValue=0.0001, maxValue=1.0, step=0.1, precision=3, callback=lambda x=2: self.onAlphaChange(x), logarithmic=1, ticks=0, maxWidth=None)
        glI.addWidget(leI,0,1)
        glI.addWidget(QLabel("     p <= ", frmI), 0,0)
        self.lblNumGenes.append(QLabel('', frmI))
        glI.addWidget(self.lblNumGenes[-1],0,2)
        
        # output
        box = QVGroupBox("Output", ca)
        gl.addWidget(box,3,0)
        self.leSelectorName = OWGUI.lineEdit(box, self, 'selectorName', label='Selector Name: ')
        self.leSelectorName.setReadOnly(self.autoUpdateSelName)
        OWGUI.checkBox(box, self, 'autoUpdateSelName', 'Automatically update selector name', callback=self.onAutoUpdateSelNameChange)
        OWGUI.checkBox(box, self, 'sendNotSelectedData', 'Send not selected data', callback=self.onSendNotSelectedChange)
        OWGUI.checkBox(box, self, 'sendProbabilities', 'Show p-values', callback=self.onSendProbabilitiesChange)
        OWGUI.checkBox(box, self, 'commitOnChange', 'Commit data on selection change', callback=lambda: self.onCommit(self.commitOnChange))
        self.btnCommit = OWGUI.button(box, self, "Commit", callback=self.onCommit)

        # enable/disable anova type box, example selection box, commit button, update the number of examples for individual selectors
        self.updateAnovaTypeBox()
        self.updateSelectorBox()
        self.updateSelectorInfos()
        self.updateSelectorName()
        self.resize(283, self.sizeHint().height())
Example #18
0
    def __init__(self,
                 parent=None,
                 signalManager=None,
                 title="Gene Atlas Tissue Expression"):
        OWWidget.__init__(self, parent, signalManager, title)

        self.inputs = [("Example Table", Orange.data.Table, self.set_data)]
        self.outputs = [("Selected Genes", Orange.data.Table)]

        self.selected_organism = "H**o sapiens"
        self.selected_gene_attr = 0
        self.genes_in_columns = False
        self.selected_ef = 0
        self.selected_ef_value = 0

        self.loadSettings()

        #####
        # GUI
        #####
        box = OWGUI.widgetBox(self.controlArea, "Info", addSpace=True)
        self.info_label = OWGUI.widgetLabel(box, "No data on input.\n")

        box = OWGUI.widgetBox(self.controlArea, "Organism", addSpace=True)
        cb = OWGUI.comboBox(box,
                            self,
                            "selected_organism",
                            items=self.ORGANISMS,
                            tooltip="Organism name",
                            callback=self.on_organism_change,
                            sendSelectedValue=True,
                            valueType=str)
        cb.setMaximumWidth(250)

        box = OWGUI.widgetBox(self.controlArea,
                              "Gene Attribute",
                              addSpace=True)
        self.gene_attr_cb = OWGUI.comboBox(
            box,
            self,
            "selected_gene_attr",
            tooltip="Attribute (column) containing the gene names.",
            callback=self.on_gene_attr_change,
        )
        self.gene_attr_cb.setMaximumWidth(250)

        cb = OWGUI.checkBox(
            box,
            self,
            "genes_in_columns",
            "Use attribute names",
            tooltip="Gene names in columns.",
            callback=self.on_genes_change,
        )
        cb.disables.append((-1, self.gene_attr_cb))
        cb.makeConsistent()

        box = OWGUI.widgetBox(self.controlArea, "Tissues", addSpace=True)
        self.categories_cb = OWGUI.comboBox(
            box,
            self,
            "selected_ef",
            box="Categories",
            items=self.FACTORS,
            tooltip="Experimental factor.",
            callback=self.on_ef_change,
        )
        self.categories_cb.box.setFlat(True)

        self.values_cb = OWGUI.comboBox(box,
                                        self,
                                        "selected_ef_value",
                                        box="Values",
                                        tooltip="Experimental factor value.",
                                        callback=self.on_ef_value_change)
        self.values_cb.setMaximumWidth(250)
        self.values_cb.box.setFlat(True)

        box = OWGUI.widgetBox(self.controlArea, "Cache", addSpace=True)
        OWGUI.button(box,
                     self,
                     "Clear cache",
                     callback=self.on_cache_clear,
                     tooltip="Clear Gene Atlas cache.")

        OWGUI.rubber(self.controlArea)

        OWGUI.button(self.controlArea,
                     self,
                     label="Commit",
                     callback=self.commit,
                     tooltip="Send selected genes")

        self.report_view = QTreeView(self.mainArea)
        self.report_view.setSelectionMode(QTreeView.ExtendedSelection)
        self.report_view.setSortingEnabled(True)
        self.report_view.setRootIsDecorated(False)
        self.report_view.setAlternatingRowColors(True)
        self.report_view.setEditTriggers(QTreeView.NoEditTriggers)
        self.mainArea.layout().addWidget(self.report_view)
        self.report_header = ["Gene symbol", "Up", "Down"]

        model = QStandardItemModel()
        model.setHorizontalHeaderLabels(self.report_header)
        self.report_view.setModel(model)

        self.data = None
        self.candidate_vars = []
        self.candidate_var_names = []
        self.results = {}, {}, {}

        self.ensembl_info = None
        self.gene_matcher = obiGene.GMDirect()
        self.loaded_matcher_taxid = None
        self.unknown_genes = []
        self.query_genes = []

        #        self.set_organism(self.selected_organism, update_results=False)

        self.get_atlas_summary = obiGeneAtlas.get_atlas_summary

        #Cached construct_matcher
        @lru_cache(maxsize=3)
        def my_cached_matcher(org):
            return obiGeneAtlas.default_gene_matcher(org)

        self.construct_matcher = my_cached_matcher
Example #19
0
    def __init__(self, parent=None, signalManager=None, title="Gene Network"):
        super(OWGeneNetwork, self).__init__(parent,
                                            signalManager,
                                            title,
                                            wantMainArea=False,
                                            resizingEnabled=False)

        self.taxid = "9606"
        self.gene_var_index = -1
        self.use_attr_names = False
        self.network_source = 1
        self.include_neighborhood = True
        self.autocommit = False
        self.min_score = 0.9
        self.loadSettings()

        self.taxids = taxonomy.common_taxids()
        self.current_taxid_index = self.taxids.index(self.taxid)

        self.data = None
        self.geneinfo = None
        self.nettask = None
        self._invalidated = False

        box = OWGUI.widgetBox(self.controlArea, "Info")
        self.info = OWGUI.widgetLabel(box, "No data on input\n")

        box = OWGUI.widgetBox(self.controlArea, "Organism")
        self.organism_cb = OWGUI.comboBox(box,
                                          self,
                                          "current_taxid_index",
                                          items=map(taxonomy.name,
                                                    self.taxids),
                                          callback=self._update_organism)
        box = OWGUI.widgetBox(self.controlArea, "Genes")
        self.genes_cb = OWGUI.comboBox(box,
                                       self,
                                       "gene_var_index",
                                       callback=self._update_query_genes)
        self.varmodel = OWItemModels.VariableListModel()
        self.genes_cb.setModel(self.varmodel)

        OWGUI.checkBox(box,
                       self,
                       "use_attr_names",
                       "Use attribute names",
                       callback=self._update_query_genes)

        box = OWGUI.widgetBox(self.controlArea, "Network")
        OWGUI.comboBox(box,
                       self,
                       "network_source",
                       items=[s.name for s in SOURCES],
                       callback=self._on_source_db_changed)
        OWGUI.checkBox(box,
                       self,
                       "include_neighborhood",
                       "Include immediate gene neighbors",
                       callback=self.invalidate)
        self.score_spin = OWGUI.doubleSpin(box,
                                           self,
                                           "min_score",
                                           0.0,
                                           1.0,
                                           step=0.001,
                                           label="Minimal edge score",
                                           callback=self.invalidate)
        self.score_spin.setEnabled(SOURCES[self.network_source].score_filter)

        box = OWGUI.widgetBox(self.controlArea, "Commit")
        OWGUI.button(box, self, "Commit", callback=self.commit, default=True)

        self.executor = ThreadExecutor()
Example #20
0
    def __init__(self, parent=None, signalManager=None, name="dictyExpress"):
        OWWidget.__init__(self, parent, signalManager, name)
        self.outputs = [("Example table", ExampleTable)]
        self.serverToken = ""
        self.server = obiDicty.defaddress

        self.platform = None

        self.selectedExperiments = []
        self.buffer = obiDicty.CacheSQLite(bufferfile)

        self.searchString = ""
        self.excludeconstant = False
        
        box = OWGUI.widgetBox(self.controlArea, "Cache")
        OWGUI.button(box, self, "Clear cache", callback=self.clear_buffer)

        OWGUI.checkBox(self.controlArea, self, "excludeconstant", "Exclude labels with constant values" )

        OWGUI.button(self.controlArea, self, "&Commit", callback=self.Commit)
        box  = OWGUI.widgetBox(self.controlArea, "Server")
        OWGUI.lineEdit(box, self, "serverToken","Token", callback=self.Connect)
        OWGUI.rubber(self.controlArea)

        OWGUI.lineEdit(self.mainArea, self, "searchString", "Search", callbackOnType=True, callback=self.SearchUpdate)
        self.experimentsWidget = QTreeWidget()
        self.experimentsWidget.setHeaderLabels(["Strain", "Treatment", "Growth condition", "Platform", "N", "Chips"]) 
        self.experimentsWidget.setSelectionMode(QTreeWidget.ExtendedSelection)
        self.experimentsWidget.setRootIsDecorated(False)
        self.experimentsWidget.setSortingEnabled(True)
##        self.experimentsWidget.setAlternatingRowColors(True)

        self.mainArea.layout().addWidget(self.experimentsWidget)

        self.loadSettings()
        self.dbc = None        

        QTimer.singleShot(0, self.UpdateExperiments)        

        self.resize(800, 600)
    def __init__(self, parent=None, signalManager=None, name="KEGG Pathways"):
        OWWidget.__init__(self, parent, signalManager, name, wantGraph=True)
        self.inputs = [("Examples", Orange.data.Table, self.SetData),
                       ("Reference", Orange.data.Table, self.SetRefData)]
        self.outputs = [("Selected Examples", Orange.data.Table),
                        ("Unselected Examples", Orange.data.Table)]
        self.organismIndex = 0
        self.geneAttrIndex = 0
        self.autoCommit = False
        self.autoResize = True
        self.useReference = False
        self.useAttrNames = 0
        self.showOrthology = True

        self.loadSettings()

        self.organismCodes = []
        self._changedFlag = False

        self.controlArea.setMaximumWidth(250)
        box = OWGUI.widgetBox(self.controlArea, "Info")
        self.infoLabel = OWGUI.widgetLabel(box, "No data on input\n")

        # Organism selection.
        box = OWGUI.widgetBox(self.controlArea, "Organism")
        self.organismComboBox = OWGUI.comboBox(
            box, self, "organismIndex",
            items=[],
            callback=self.Update,
            addSpace=True,
            debuggingEnabled=0,
            tooltip="Select the organism of the input genes")

        # Selection of genes attribute
        box = OWGUI.widgetBox(self.controlArea, "Gene attribute")
        self.geneAttrCandidates = VariableListModel(parent=self)
        self.geneAttrCombo = OWGUI.comboBox(
            box, self, "geneAttrIndex", callback=self.Update)
        self.geneAttrCombo.setModel(self.geneAttrCandidates)

        OWGUI.checkBox(box, self, "useAttrNames",
                       "Use variable names",
                       disables=[(-1, self.geneAttrCombo)],
                       callback=self.Update)

        self.geneAttrCombo.setDisabled(bool(self.useAttrNames))

        OWGUI.separator(self.controlArea)

        OWGUI.checkBox(self.controlArea, self, "useReference",
                       "From signal",
                       box="Reference",
                       callback=self.Update)

        OWGUI.separator(self.controlArea)

        OWGUI.checkBox(self.controlArea, self, "showOrthology",
                       "Show pathways in full orthology",
                       box="Orthology",
                       callback=self.UpdateListView)

        OWGUI.checkBox(self.controlArea, self, "autoResize",
                       "Resize to fit",
                       box="Image",
                       callback=self.UpdatePathwayViewTransform)

        box = OWGUI.widgetBox(self.controlArea, "Cache Control")

        OWGUI.button(box, self, "Clear cache",
                     callback=self.ClearCache,
                     tooltip="Clear all locally cached KEGG data.")

        OWGUI.separator(self.controlArea)

        box = OWGUI.widgetBox(self.controlArea, "Selection")
        cb = OWGUI.checkBox(box, self, "autoCommit", "Commit on update")
        button = OWGUI.button(box, self, "Commit", callback=self.Commit,
                              default=True)
        OWGUI.setStopper(self, button, cb, "_changedFlag", self.Commit)

        OWGUI.rubber(self.controlArea)

        spliter = QSplitter(Qt.Vertical, self.mainArea)
        self.pathwayView = PathwayView(self, spliter)
        self.pathwayView.scene().selectionChanged.connect(
            self._onSelectionChanged
        )
        self.mainArea.layout().addWidget(spliter)

        self.listView = QTreeWidget(spliter)
        spliter.addWidget(self.listView)

        self.listView.setAllColumnsShowFocus(1)
        self.listView.setColumnCount(4)
        self.listView.setHeaderLabels(["Pathway", "P value",
                                       "Genes", "Reference"])

        self.listView.setSelectionMode(QTreeWidget.SingleSelection)

        self.listView.setSortingEnabled(True)

        self.listView.setMaximumHeight(200)

        self.connect(self.listView,
                     SIGNAL("itemSelectionChanged()"),
                     self.UpdatePathwayView)

        self.connect(self.graphButton,
                     SIGNAL("clicked()"),
                     self.saveGraph)

        select = QAction(
            "Select All", self,
            shortcut=QKeySequence.SelectAll
        )
        select.triggered.connect(self.selectAll)
        self.addAction(select)

        self.data = None
        self.refData = None

        self.resize(800, 600)

        self.connect(self,
                     SIGNAL("widgetStateChanged(QString, int, QString)"),
                     self.onStateChange)

        self.has_new_data = False
        self.has_new_reference_set = False

        self._executor = ThreadExecutor()
        self.setEnabled(False)
        self.setBlocking(True)
        QTimer.singleShot(0, self._initialize)
        self.infoLabel.setText("Fetching organism definitions\n")
    def __init__(self, parent=None, signalManager=None, name="Gene selection"):
        OWWidget.__init__(self, parent, signalManager, name, wantGraph=True, showSaveGraph=True)
        self.inputs = [("Examples", ExampleTable, self.set_data)]
        self.outputs = [("Example table with selected genes", ExampleTable), ("Example table with remaining genes", ExampleTable), ("Selected genes", ExampleTable)]

        self.method_index = 0
        self.genes_in_columns = False
        self.compute_null = False
        self.permutations_count = 10
        self.auto_commit = False
        self.selectNBest = 20
        self.selectPValue = 0.01
        self.data_changed_flag = False
        self.add_scores_to_output = True
        self.thresholds = {
            "fold change": (0.5, 2.),
            "log2 fold change": (-1, 1),
            "t-test": (-2, 2),
            "t-test p-value": (0.01, 0.01),
        }

        self.oneTailTestHi = oneTailTestHi = lambda array, low, hi: array >= hi
        self.oneTailTestLow = oneTailTestLow = lambda array, low, hi: array <= low
        self.twoTailTest = twoTailTest = lambda array, low, hi: (array >= hi) | (array <= low)
        self.middleTest = middleTest = lambda array, low, hi: (array <= hi) | (array >= low)
        
        self.histType = {oneTailTestHi:"hiTail", oneTailTestLow:"lowTail", twoTailTest:"twoTail", middleTest:"middle"}

        # [(name, func, tail test, two sample test), ...]
        self.score_methods = [("fold change", ExpressionSignificance_FoldChange, twoTailTest, True),
                             ("log2 fold change", ExpressionSignificance_Log2FoldChange, twoTailTest, True),
                             ("t-test", ExpressionSignificance_TTest_T, twoTailTest, True),
                             ("t-test p-value", ExpressionSignificance_TTest_PValue, oneTailTestLow, True),
                             ("anova", ExpressionSignificance_ANOVA_F, oneTailTestHi, False),
                             ("anova p-value", ExpressionSignificance_ANOVA_PValue, oneTailTestLow, False),
                             ("signal to noise ratio", ExpressionSignificance_SignalToNoise, twoTailTest, True),
                             ("info gain", ExpressionSignificance_Info, oneTailTestHi, True),
                             ("chi-square", ExpressionSignificance_ChiSquare, oneTailTestHi, True),
                             ("mann-whitney", ExpressionSignigicance_MannWhitneyu_U, oneTailTestLow, True)]

        boxHistogram = OWGUI.widgetBox(self.mainArea)
        self.histogram = ScoreHist(self, boxHistogram)
        boxHistogram.layout().addWidget(self.histogram)
        self.histogram.show()
        
        box = OWGUI.widgetBox(self.controlArea, "Info")
        self.dataInfoLabel = OWGUI.widgetLabel(box, "\n\n")
        self.dataInfoLabel.setWordWrap(True)
        self.selectedInfoLabel = OWGUI.widgetLabel(box, "")

        box1 = OWGUI.widgetBox(self.controlArea, "Scoring Method")
        self.testRadioBox = OWGUI.comboBox(box1, self, "method_index",
                                    items=[sm[0] for sm in self.score_methods],
                                    callback=[self.on_scoring_method_changed, self.update_scores])
        
        box = OWGUI.widgetBox(self.controlArea, "Target Labels")
        self.label_selection_widget = LabelSelectionWidget(self)
        self.label_selection_widget.setMaximumHeight(150)
        box.layout().addWidget(self.label_selection_widget)
        self.connect(self.label_selection_widget,
                     SIGNAL("selection_changed()"),
                     self.on_target_changed)
        
        self.connect(self.label_selection_widget,
                     SIGNAL("label_activated(int)"),
                     self.on_label_activated)
        
        self.genes_in_columns_check = OWGUI.checkBox(box, self, "genes_in_columns",
                                                  "Genes in columns",
                                                  callback=self.on_genes_in_columns_change)

        box = OWGUI.widgetBox(self.controlArea, "Selection")
        box.layout().setSpacing(0)

        self.upperBoundarySpin = OWGUI.doubleSpin(box, self, "histogram.upperBoundary",
                                                  min=-1e6, max=1e6, step= 1e-6,
                                                  label="Upper threshold:", 
                                                  callback=self.update_boundary, 
                                                  callbackOnReturn=True)
        
        self.lowerBoundarySpin = OWGUI.doubleSpin(box, self, "histogram.lowerBoundary", 
                                                  min=-1e6, max=1e6, step= 1e-6, 
                                                  label="Lower threshold:", 
                                                  callback=self.update_boundary, 
                                                  callbackOnReturn=True)
        
        check = OWGUI.checkBox(box, self, "compute_null", "Compute null distribution",
                               callback=self.update_scores)

        check.disables.append(OWGUI.spin(box, self, "permutations_count", min=1, max=10, 
                                         label="Permutations:", callback=self.update_scores, 
                                         callbackOnReturn=True))

        box1 = OWGUI.widgetBox(box, orientation='horizontal')
        check.disables.append(OWGUI.doubleSpin(box1, self, "selectPValue", 
                                               min=2e-7, max=1.0, step=1e-7, 
                                               label="P-value:"))
        check.disables.append(OWGUI.button(box1, self, "Select", callback=self.select_p_best))
        check.makeConsistent()

        box1 = OWGUI.widgetBox(box, orientation='horizontal')
        OWGUI.spin(box1, self, "selectNBest", 0, 10000, step=1, label="Best Ranked:")
        OWGUI.button(box1, self, "Select", callback=self.select_n_best)

        box = OWGUI.widgetBox(self.controlArea, "Output")
        b = OWGUI.button(box, self, "&Commit", callback=self.commit)
        cb = OWGUI.checkBox(box, self, "auto_commit", "Commit on change")
        OWGUI.setStopper(self, b, cb, "data_changed_flag", self.commit)
        OWGUI.checkBox(box, self, "add_scores_to_output", "Add gene scores to output",
                       callback=self.commit_if) 
        
        OWGUI.rubber(self.controlArea)

        self.connect(self.graphButton, SIGNAL("clicked()"), self.histogram.saveToFile)
        
        self.loadSettings()

        self.data = None
        self.discData = None
        self.scoreCache = {}
        self.nullDistCache = {}
        self.cuts = {}
        self.null_dist = []
        self.targets = []
        self.scores = {}
        self.genes_in_columns = True
        self.target_selections = None
        
        self.on_scoring_method_changed()
        
        self.resize(800, 600)
Example #23
0
    def update_scores(self):
        """ Compute the scores and update the histogram.
        """
        self.clear_plot()
        self.error(0)
        label, values = self.current_target_selection
        if not self.data or label is None:
            return
        _, score_func, _, two_sample_test = self.score_methods[
            self.method_index]
        if two_sample_test:
            target = self.targets
            score_target = set(target)
            ind1, ind2 = score_func(
                self.data, self.genes_in_columns).test_indices(score_target)
            if not len(ind1) or not len(ind2):
                self.error(
                    0,
                    "Target labels most exclude/include at least one value.")
                return

        else:  # ANOVA should use all labels.
            target = dict(self.data_labels)[label]
            if self.genes_in_columns:
                target = [(label, t) for t in target]
            score_target = target


#            indices = score_func(self.data, self.genes_in_columns).test_indices(score_target)
# TODO: Check that each label has more than one measurement, raise warning otherwise.

        pb = OWGUI.ProgressBar(
            self, 4 + self.permutations_count if self.compute_null else 3)
        self.scores = dict(
            self.compute_scores(self.data,
                                score_func,
                                self.genes_in_columns,
                                score_target,
                                advance=pb.advance))
        pb.advance()
        if self.compute_null:
            self.null_dist = self.compute_null_distribution(
                self.data,
                score_func,
                self.genes_in_columns,
                score_target,
                self.permutations_count,
                advance=pb.advance)
        else:
            self.null_dist = []
        pb.advance()
        htype = self.histType[self.score_methods[self.method_index][2]]
        score_type = self.score_methods[self.method_index][0]
        self.histogram.type = htype
        if self.scores:
            self.histogram.setValues(self.scores.values())
            low, high = self.thresholds.get(score_type,
                                            (float("-inf"), float("inf")))
            minx, maxx = self.histogram.minx, self.histogram.maxx
            low, high = max(low, minx), min(high, maxx)

            if htype == "hiTail":
                low = high
            if htype == "lowTail":
                high = low

            self.histogram.setBoundary(low, high)

            if self.compute_null and self.null_dist:
                nullY, nullX = numpy.histogram(self.null_dist,
                                               bins=self.histogram.xData)
                nullY = nullY / self.permutations_count
                self.histogram.nullCurve = self.histogram.addCurve(
                    "nullCurve",
                    Qt.black,
                    Qt.black,
                    6,
                    symbol=QwtSymbol.NoSymbol,
                    style=QwtPlotCurve.Steps,
                    xData=nullX,
                    yData=nullY)

                minx = min(min(nullX), minx)
                maxx = max(max(nullX), maxx)
                miny = min(min(nullY), self.histogram.miny)
                maxy = max(max(nullY), self.histogram.maxy)
                spanx, spany = maxx - minx, maxy - miny
                self.histogram.setAxisScale(QwtPlot.xBottom,
                                            minx - 0.05 * spanx,
                                            maxx + 0.05 * spanx)
                self.histogram.setAxisScale(QwtPlot.yLeft, miny - 0.05 * spany,
                                            maxy + 0.05 * spany)

            state = dict(hiTail=(False, True),
                         lowTail=(True, False),
                         twoTail=(True, True))
            for spin, visible in zip(
                (self.upperBoundarySpin, self.lowerBoundarySpin),
                    state[self.histogram.type]):
                spin.setVisible(visible)

            # If this is a two sample test add markers to the left and right
            # plot indicating which target group is over-expressed in that
            # part
            if self.method_index in [0, 2, 6]:
                if self.method_index == 0:  ## fold change is centered on 1.0
                    x1, y1 = (self.histogram.minx + 1) / 2, self.histogram.maxy
                    x2, y2 = (self.histogram.maxx + 1) / 2, self.histogram.maxy
                else:
                    x1, y1 = (self.histogram.minx) / 2, self.histogram.maxy
                    x2, y2 = (self.histogram.maxx) / 2, self.histogram.maxy
                if self.genes_in_columns:
                    label = target[0][0]
                    target_values = [t[1] for t in target]
                    values = dict(self.data_labels)[label]
                else:
                    target_values = target
                    values = self.data_labels[0][1]

                left = ", ".join(v for v in values if v not in target_values)
                right = ", ".join(v for v in values if v in target_values)

                self.histogram.addMarker(left, x1, y1)
                self.histogram.addMarker(right, x2, y2)
            self.warning(0)
        else:
            self.warning(0, "No scores obtained.")
        self.histogram.replot()
        pb.advance()
        pb.finish()
        self.update_data_info_label()
Example #24
0
    def __init__(self, parent=None, signalManager=None, name="Gene selection"):
        OWWidget.__init__(self,
                          parent,
                          signalManager,
                          name,
                          wantGraph=True,
                          showSaveGraph=True)
        self.inputs = [("Examples", ExampleTable, self.set_data)]
        self.outputs = [("Example table with selected genes", ExampleTable),
                        ("Example table with remaining genes", ExampleTable),
                        ("Selected genes", ExampleTable)]

        self.method_index = 0
        self.genes_in_columns = False
        self.compute_null = False
        self.permutations_count = 10
        self.auto_commit = False
        self.selectNBest = 20
        self.selectPValue = 0.01
        self.data_changed_flag = False
        self.add_scores_to_output = True
        self.thresholds = {
            "fold change": (0.5, 2.),
            "log2 fold change": (-1, 1),
            "t-test": (-2, 2),
            "t-test p-value": (0.01, 0.01),
        }

        self.oneTailTestHi = oneTailTestHi = lambda array, low, hi: array >= hi
        self.oneTailTestLow = oneTailTestLow = lambda array, low, hi: array <= low
        self.twoTailTest = twoTailTest = lambda array, low, hi: (
            array >= hi) | (array <= low)
        self.middleTest = middleTest = lambda array, low, hi: (array <= hi) | (
            array >= low)

        self.histType = {
            oneTailTestHi: "hiTail",
            oneTailTestLow: "lowTail",
            twoTailTest: "twoTail",
            middleTest: "middle"
        }

        # [(name, func, tail test, two sample test), ...]
        self.score_methods = [
            ("fold change", ExpressionSignificance_FoldChange, twoTailTest,
             True),
            ("log2 fold change", ExpressionSignificance_Log2FoldChange,
             twoTailTest, True),
            ("t-test", ExpressionSignificance_TTest_T, twoTailTest, True),
            ("t-test p-value", ExpressionSignificance_TTest_PValue,
             oneTailTestLow, True),
            ("anova", ExpressionSignificance_ANOVA_F, oneTailTestHi, False),
            ("anova p-value", ExpressionSignificance_ANOVA_PValue,
             oneTailTestLow, False),
            ("signal to noise ratio", ExpressionSignificance_SignalToNoise,
             twoTailTest, True),
            ("info gain", ExpressionSignificance_Info, oneTailTestHi, True),
            ("chi-square", ExpressionSignificance_ChiSquare, oneTailTestHi,
             True),
            ("mann-whitney", ExpressionSignigicance_MannWhitneyu_U,
             oneTailTestLow, True)
        ]

        boxHistogram = OWGUI.widgetBox(self.mainArea)
        self.histogram = ScoreHist(self, boxHistogram)
        boxHistogram.layout().addWidget(self.histogram)
        self.histogram.show()

        box = OWGUI.widgetBox(self.controlArea, "Info")
        self.dataInfoLabel = OWGUI.widgetLabel(box, "\n\n")
        self.dataInfoLabel.setWordWrap(True)
        self.selectedInfoLabel = OWGUI.widgetLabel(box, "")

        box1 = OWGUI.widgetBox(self.controlArea, "Scoring Method")
        self.testRadioBox = OWGUI.comboBox(
            box1,
            self,
            "method_index",
            items=[sm[0] for sm in self.score_methods],
            callback=[self.on_scoring_method_changed, self.update_scores])

        box = OWGUI.widgetBox(self.controlArea, "Target Labels")
        self.label_selection_widget = LabelSelectionWidget(self)
        self.label_selection_widget.setMaximumHeight(150)
        box.layout().addWidget(self.label_selection_widget)
        self.connect(self.label_selection_widget,
                     SIGNAL("selection_changed()"), self.on_target_changed)

        self.connect(self.label_selection_widget,
                     SIGNAL("label_activated(int)"), self.on_label_activated)

        self.genes_in_columns_check = OWGUI.checkBox(
            box,
            self,
            "genes_in_columns",
            "Genes in columns",
            callback=self.on_genes_in_columns_change)

        box = OWGUI.widgetBox(self.controlArea, "Selection")
        box.layout().setSpacing(0)

        self.upperBoundarySpin = OWGUI.doubleSpin(
            box,
            self,
            "histogram.upperBoundary",
            min=-1e6,
            max=1e6,
            step=1e-6,
            label="Upper threshold:",
            callback=self.update_boundary,
            callbackOnReturn=True)

        self.lowerBoundarySpin = OWGUI.doubleSpin(
            box,
            self,
            "histogram.lowerBoundary",
            min=-1e6,
            max=1e6,
            step=1e-6,
            label="Lower threshold:",
            callback=self.update_boundary,
            callbackOnReturn=True)

        check = OWGUI.checkBox(box,
                               self,
                               "compute_null",
                               "Compute null distribution",
                               callback=self.update_scores)

        check.disables.append(
            OWGUI.spin(box,
                       self,
                       "permutations_count",
                       min=1,
                       max=10,
                       label="Permutations:",
                       callback=self.update_scores,
                       callbackOnReturn=True))

        box1 = OWGUI.widgetBox(box, orientation='horizontal')
        check.disables.append(
            OWGUI.doubleSpin(box1,
                             self,
                             "selectPValue",
                             min=2e-7,
                             max=1.0,
                             step=1e-7,
                             label="P-value:"))
        check.disables.append(
            OWGUI.button(box1, self, "Select", callback=self.select_p_best))
        check.makeConsistent()

        box1 = OWGUI.widgetBox(box, orientation='horizontal')
        OWGUI.spin(box1,
                   self,
                   "selectNBest",
                   0,
                   10000,
                   step=1,
                   label="Best Ranked:")
        OWGUI.button(box1, self, "Select", callback=self.select_n_best)

        box = OWGUI.widgetBox(self.controlArea, "Output")
        b = OWGUI.button(box, self, "&Commit", callback=self.commit)
        cb = OWGUI.checkBox(box, self, "auto_commit", "Commit on change")
        OWGUI.setStopper(self, b, cb, "data_changed_flag", self.commit)
        OWGUI.checkBox(box,
                       self,
                       "add_scores_to_output",
                       "Add gene scores to output",
                       callback=self.commit_if)

        OWGUI.rubber(self.controlArea)

        self.connect(self.graphButton, SIGNAL("clicked()"),
                     self.histogram.saveToFile)

        self.loadSettings()

        self.data = None
        self.discData = None
        self.scoreCache = {}
        self.nullDistCache = {}
        self.cuts = {}
        self.null_dist = []
        self.targets = []
        self.scores = {}
        self.genes_in_columns = True
        self.target_selections = None

        self.on_scoring_method_changed()

        self.resize(800, 600)
Example #25
0
    def __init__(self, parent=None, signalManager=None, name="Gene Info"):
        OWWidget.__init__(self, parent, signalManager, name)

        self.inputs = [("Examples", Orange.data.Table, self.setData)]
        self.outputs = [("Selected Examples", Orange.data.Table)]

        self.organismIndex = 0
        self.taxid = None
        self.geneAttr = 0
        self.useAttr = False
        self.autoCommit = False
        self.searchString = ""
        self.selectionChangedFlag = False
        self.useAltSource = 0
        self.loadSettings()

        self.__initialized = False
        self.initfuture = None
        self.itemsfuture = None

        self.infoLabel = OWGUI.widgetLabel(
            OWGUI.widgetBox(self.controlArea, "Info", addSpace=True),
            "Initializing\n"
        )

        self.organisms = None
        self.organismBox = OWGUI.widgetBox(
            self.controlArea, "Organism", addSpace=True)

        self.organismComboBox = OWGUI.comboBox(
            self.organismBox, self, "organismIndex",
            callback=self._onSelectedOrganismChanged,
            debuggingEnabled=0)

        # For now only support one alt source, with a checkbox
        # In the future this can be extended to multiple selections
        self.altSourceCheck = OWGUI.checkBox(self.organismBox, self,
                            "useAltSource", "Show information from dictyBase",
                            callback=self.onAltSourceChange,
#                            debuggingEnabled=0,
                            )
        self.altSourceCheck.hide()

        box = OWGUI.widgetBox(self.controlArea, "Gene names", addSpace=True)
        self.geneAttrComboBox = OWGUI.comboBox(
            box, self, "geneAttr",
            "Gene atttibute", callback=self.updateInfoItems
        )
        OWGUI.checkBox(box, self, "useAttr", "Use attribute names",
                       callback=self.updateInfoItems,
                       disables=[(-1, self.geneAttrComboBox)])

        self.geneAttrComboBox.setDisabled(bool(self.useAttr))

        box = OWGUI.widgetBox(self.controlArea, "Commit", addSpace=True)
        b = OWGUI.button(box, self, "Commit", callback=self.commit)
        c = OWGUI.checkBox(box, self, "autoCommit", "Commit on change")
        OWGUI.setStopper(self, b, c, "selectionChangedFlag",
                         callback=self.commit)

        # A label for dictyExpress link
        self.dictyExpressBox = OWGUI.widgetBox(
            self.controlArea, "Dicty Express")
        self.linkLabel = OWGUI.widgetLabel(self.dictyExpressBox, "")
        self.linkLabel.setOpenExternalLinks(False)
        self.connect(self.linkLabel, SIGNAL("linkActivated(QString)"),
                     self.onDictyExpressLink)
        self.dictyExpressBox.hide()

        OWGUI.rubber(self.controlArea)

        OWGUI.lineEdit(self.mainArea, self, "searchString", "Filter",
                       callbackOnType=True, callback=self.searchUpdate)

        self.treeWidget = QTreeView(self.mainArea)
        self.treeWidget.setRootIsDecorated(False)
        self.treeWidget.setSelectionMode(
            QAbstractItemView.ExtendedSelection)
        self.treeWidget.setItemDelegate(
            LinkStyledItemDelegate(self.treeWidget))
        self.treeWidget.setUniformRowHeights(True)
        self.treeWidget.viewport().setMouseTracking(True)
        self.treeWidget.setSortingEnabled(True)
        self.mainArea.layout().addWidget(self.treeWidget)

        box = OWGUI.widgetBox(self.mainArea, "",
                              orientation="horizontal")
        OWGUI.button(box, self, "Select Filtered",
                     callback=self.selectFiltered)
        OWGUI.button(box, self, "Clear Selection",
                     callback=self.treeWidget.clearSelection)

        self.resize(1000, 700)

        self.geneinfo = []
        self.cells = []
        self.row2geneinfo = {}
        self.data = None

        # : (# input genes, # matches genes)
        self.matchedInfo = 0, 0
        self.selectionUpdateInProgress = False

        self.setBlocking(True)
        self.executor = ThreadExecutor(self)

        self.progressBarInit()

        task = Task(
            function=partial(
                taxonomy.ensure_downloaded,
                callback=methodinvoke(self, "advance", ())
            )
        )

        task.resultReady.connect(self.initialize)
        task.exceptionReady.connect(self._onInitializeError)

        self.initfuture = self.executor.submit(task)
    def __init__(self,parent=None, signalManager = None):
        OWWidget.__init__(self, parent, signalManager, "Nomogram", 1)

        #self.setWFlags(Qt.WResizeNoErase | Qt.WRepaintNoErase) #this works like magic.. no flicker during repaint!
        self.parent = parent
#        self.setWFlags(self.getWFlags()+Qt.WStyle_Maximize)

        self.callbackDeposit = [] # deposit for OWGUI callback functions
        self.alignType = 0
        self.contType = 0
        self.yAxis = 0
        self.probability = 0
        self.verticalSpacing = 60
        self.verticalSpacingContinuous = 100
        self.diff_between_ordinal = 30
        self.fontSize = 9
        self.lineWidth = 1
        self.histogram = 0
        self.histogram_size = 10
        self.data = None
        self.cl = None
        self.confidence_check = 0
        self.confidence_percent = 95
        self.sort_type = 0

        self.loadSettings()

        self.pointsName = ["Total", "Total"]
        self.totalPointsName = ["Probability", "Probability"]
        self.bnomogram = None


        self.inputs=[("Classifier", orange.Classifier, self.classifier), ("Data", Orange.data.Table, self.data)]


        self.TargetClassIndex = 0
        self.targetCombo = OWGUI.comboBox(self.controlArea, self, "TargetClassIndex", " Target Class ", addSpace=True, tooltip='Select target (prediction) class in the model.', callback = self.setTarget)

        self.alignRadio = OWGUI.radioButtonsInBox(self.controlArea, self,  'alignType', ['Align left', 'Align by zero influence'], box='Attribute placement',
                                                  tooltips=['Attributes in nomogram are left aligned', 'Attributes are not aligned, top scale represents true (normalized) regression coefficient value'],
                                                  addSpace=True,
                                                  callback=self.showNomogram)
        self.verticalSpacingLabel = OWGUI.spin(self.alignRadio, self, 'verticalSpacing', 15, 200, label = 'Vertical spacing:',  orientation = 0, tooltip='Define space (pixels) between adjacent attributes.', callback = self.showNomogram)

        self.ContRadio = OWGUI.radioButtonsInBox(self.controlArea, self, 'contType',   ['1D projection', '2D curve'], 'Continuous attributes',
                                tooltips=['Continuous attribute are presented on a single scale', 'Two dimensional space is used to present continuous attributes in nomogram.'],
                                addSpace=True,
                                callback=[lambda:self.verticalSpacingContLabel.setDisabled(not self.contType), self.showNomogram])

        self.verticalSpacingContLabel = OWGUI.spin(OWGUI.indentedBox(self.ContRadio, sep=OWGUI.checkButtonOffsetHint(self.ContRadio.buttons[-1])), self, 'verticalSpacingContinuous', 15, 200, label = "Height", orientation=0, tooltip='Define space (pixels) between adjacent 2d presentation of attributes.', callback = self.showNomogram)
        self.verticalSpacingContLabel.setDisabled(not self.contType)

        self.yAxisRadio = OWGUI.radioButtonsInBox(self.controlArea, self, 'yAxis', ['Point scale', 'Log odds ratios'], 'Scale',
                                tooltips=['values are normalized on a 0-100 point scale','values on top axis show log-linear contribution of attribute to full model'],
                                addSpace=True,
                                callback=self.showNomogram)

        layoutBox = OWGUI.widgetBox(self.controlArea, "Display", orientation=1, addSpace=True)

        self.probabilityCheck = OWGUI.checkBox(layoutBox, self, 'probability', 'Show prediction',  tooltip='', callback = self.setProbability)

        self.CICheck, self.CILabel = OWGUI.checkWithSpin(layoutBox, self, 'Confidence intervals (%):', min=1, max=99, step = 1, checked='confidence_check', value='confidence_percent', checkCallback=self.showNomogram, spinCallback = self.showNomogram)

        self.histogramCheck, self.histogramLabel = OWGUI.checkWithSpin(layoutBox, self, 'Show histogram, size', min=1, max=30, checked='histogram', value='histogram_size', step = 1, tooltip='-(TODO)-', checkCallback=self.showNomogram, spinCallback = self.showNomogram)

        OWGUI.separator(layoutBox)
        self.sortOptions = ["No sorting", "Absolute importance", "Positive influence", "Negative influence"]
        self.sortBox = OWGUI.comboBox(layoutBox, self, "sort_type", label="Sort by ", items=self.sortOptions, callback = self.sortNomogram, orientation="horizontal")


        OWGUI.rubber(self.controlArea)

        self.connect(self.graphButton, SIGNAL("clicked()"), self.menuItemPrinter)



        #add a graph widget
        self.header = OWNomogramHeader(None, self.mainArea)
        self.header.setFixedHeight(60)
        self.header.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.header.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.graph = OWNomogramGraph(self.bnomogram, self.mainArea)
        self.graph.setMinimumWidth(200)
        self.graph.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.footer = OWNomogramHeader(None, self.mainArea)
        self.footer.setFixedHeight(60*2+10)
        self.footer.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.footer.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)

        self.mainArea.layout().addWidget(self.header)
        self.mainArea.layout().addWidget(self.graph)
        self.mainArea.layout().addWidget(self.footer)
        self.resize(700,500)
        #self.repaint()
        #self.update()

        # mouse pressed flag
        self.mousepr = False
Example #27
0
    def __init__(self, parent=None, signalManager=None):
        self.callbackDeposit = []  # deposit for OWGUI callback functions
        OWWidget.__init__(self, parent, signalManager,
                          'Impute & Loess Profiles')

        self._data = None  # exampleTable
        self._dataMA = None  # input 2d masked array
        self._chipdata = None  # [(dirname0, [et0, et1, ...]), ...]
        self._chipdataMA = []  # [(dirname0, [m2d0, m2d1, ...]), ...]
        self.impute = 1
        self.imputeK = 20
        self.smooth = 1
        self.windowSize = 3
        self.commitOnChange = 1

        # Settings
        self.loadSettings()

        # GUI
        self.mainArea.setFixedWidth(0)
        ca = QFrame(self.controlArea)
        gl = QGridLayout(ca, 4, 1, 5)
        # info
        box = QVGroupBox("Info", ca)
        gl.addWidget(box, 0, 0)
        self.infoa = QLabel("No examples on input", box)
        self.infob = QLabel("", box)
        QLabel("", box)
        self.infoc = QLabel("No structured data on input", box)
        self.infod = QLabel("", box)
        # KNN impute
        self.boxImpute = QVGroupBox("Impute missing values", ca)
        gl.addWidget(self.boxImpute, 1, 0)
        OWGUI.checkBox(
            self.boxImpute,
            self,
            "impute",
            "KNN impute",
            tooltip=
            "Impute missing values from values of K nearest neighbours.",
            callback=self.change)
        ##        self.sliderK = OWGUI.hSlider(self.boxImpute, self, "imputeK", box=None, minValue=1, maxValue=7744, step=1, callback=self.imputeChange, labelFormat=" K = %i", ticks=0)
        ##        self.sliderK = OWGUI.qwtHSlider(self.boxImpute, self, "imputeK", box=None, label="K", labelWidth=12, minValue=1, maxValue=7744, step=0.02, precision=0, callback=self.imputeChange, logarithmic=1, ticks=0, maxWidth=200)
        ##        self.sliderK = OWGUI.qwtHSlider(self.boxImpute, self, "imputeK", box=None, label="K", labelWidth=12, minValue=1, maxValue=100, step=1, precision=0, callback=self.imputeKChange, logarithmic=0, ticks=0, maxWidth=200)
        self.sliderK = OWGUI.qwtHSlider(self.boxImpute,
                                        self,
                                        "imputeK",
                                        box=None,
                                        label="K",
                                        labelWidth=15,
                                        minValue=1,
                                        maxValue=999,
                                        step=1,
                                        precision=0,
                                        callback=self.imputeKChange,
                                        logarithmic=0,
                                        ticks=0,
                                        maxWidth=None)
        self.boxImpute.setDisabled(1)
        # loess
        self.boxLoess = QVGroupBox("Smoothing", ca)
        gl.addWidget(self.boxLoess, 2, 0)
        OWGUI.checkBox(self.boxLoess,
                       self,
                       "smooth",
                       "Loess smoothing",
                       tooltip="Loess profiles, impute missing columns.",
                       callback=self.change)
        lbl = QLabel("Window size (number of points)", self.boxLoess)
        lbl.setAlignment(Qt.AlignHCenter)
        self.sliderW = OWGUI.qwtHSlider(self.boxLoess,
                                        self,
                                        "windowSize",
                                        box=None,
                                        label="W",
                                        labelWidth=15,
                                        minValue=1,
                                        maxValue=999,
                                        step=1,
                                        precision=0,
                                        callback=self.smoothWChange,
                                        logarithmic=0,
                                        ticks=0,
                                        maxWidth=None)
        self.boxLoess.setDisabled(1)
        # output
        box = QVGroupBox("Output", ca)
        gl.addWidget(box, 3, 0)
        OWGUI.checkBox(box, self, 'commitOnChange',
                       'Commit data on selection change')
        self.commitBtn = OWGUI.button(box,
                                      self,
                                      "Commit",
                                      callback=self.senddata,
                                      disabled=1)

        self.inputs = [("Examples", ExampleTable, self.data),
                       ("Structured Data", DataFiles, self.chipdata)]
        self.outputs = [("Examples", ExampleTable),
                        ("Structured Data", DataFiles)]

        # data dependent variables
        self.numRowsMissing = 0
        self.numRowsMissingChipData = 0
        self.resize(100, 100)
Example #28
0
    def __init__(self, parent=None, signalManager=None):
        OWWidget.__init__(self, parent, signalManager, "&Display Motifs", 0)

        # set default settings
        self.colorBy = None
        self.pvalThresholdIndex = None
        self.pvalThreshold = None

        #load settings
        self.loadSettings()

        # GUI
        self.graph = OWGraph(self.mainArea)
        self.graph.setYRlabels(None)
        self.graph.enableGridXB(0)
        self.graph.enableGridYL(1)
        self.graph.setAxisMaxMinor(QwtPlot.xBottom, 10)
        self.graph.setAxisMaxMajor(QwtPlot.xBottom, 10)
        self.graph.setAxisAutoScale(QwtPlot.xBottom)
        self.graph.setAxisScale(QwtPlot.xBottom, -1020, 0, 0)
        self.mainArea.layout().addWidget(self.graph)

        # inputs
        # data and graph temp variables
        self.inputs = [("Examples", ExampleTable, self.cdata, Default),
                       ("Genes", list, self.newGeneList, Default),
                       ("Motifs", list, self.newMotifList, Default)]

        self.data = None
        self.motifLines = []
        self.visibleValues = []
        self.valueToCurve = {}
        self.allGenes = []  ## genes displayed always in same order
        self.geneList = []  ## selected genes
        self.motifList = []  ## selected motifs
        self.valuesPresentInData = []

        self.clusterPostProbThreshold = 0

        # GUI
        self.selValues = OWGUI.widgetBox(self.controlArea, "Values")
        self.selcolorBy = OWGUI.widgetBox(self.controlArea, "Color By")

        self.colorByCombo = OWGUI.comboBox(self.selcolorBy,
                                           self,
                                           "colorBy",
                                           items=[],
                                           callback=self.colorByChanged)

        self.pvalThresholdCombo = OWGUI.comboBox(
            self.selValues,
            self,
            "pvalThresholdIndex",
            items=[],
            callback=self.pvalThresholdChanged)

        self.valuesQLB = QListWidget(self.selValues)
        self.valuesQLB.setSelectionMode(QListWidget.MultiSelection)
        self.connect(self.valuesQLB, SIGNAL("itemSelectionChanged()"),
                     self.valuesSelectionChange)
        self.selValues.layout().addWidget(self.valuesQLB)

        self.unselectAllQLB = OWGUI.button(self.selValues,
                                           self,
                                           "Unselect all",
                                           callback=self.unselAll)
Example #29
0
    def __init__(self, parent=None, signalManager = None):
        OWWidget.__init__(self, parent, signalManager, 'ANOVA')
        # input / output data: [("name1", [orange.ExampleTable1a,...]), ("name2", [orange.ExampleTable2a,...])]
        self.inputs = [("Structured Data", DataFiles, self.onDataInput)]
        self.outputs = [("Example Selection", ExampleSelection, Default), ("Selected Structured Data", DataFiles, Default), ("Other Structured Data", DataFiles)]

        # data, p-values, selected examples
        self.dataStructure = None   # input data
        self.numExamples = 0
        self.numVariables = 0
        self.ps = None              # p-values: 2D Numeric.array of shape (3, numExamples)
        self.selectorName = ""      # for Example Selection output: (self.selectorName, [0,1,0,...])

        # Settings
        self.anovaType = 0      # 0: single-sample t-test, 1: one-way (A), 2: one-way (B), 3: two-way (A,B), 4: ful factorial (A, B, A*B)
        self.compareToValue = 0 # single sample t-test, value to compare to
        self._interaction = 0    # 0: no interaction, 1: test for interaction effect (set this value manually !!!)
        self.selectorA = True
        self.selectorB = False
        self.selectorI = False
        self.alphaA = "0.05"
        self.alphaB = "0.05"
        self.alphaI = "0.05"
        self.autoUpdateSelName = 1
        self.sendNotSelectedData = 1
        self.sendProbabilities = 0
        self.commitOnChange = 0
        self.loadSettings()

        # GUI
        self.mainArea.setFixedWidth(0)
        ca = self.controlArea
       
        # info
        box = OWGUI.widgetBox(ca, "Info")
        #gl.addWidget(box,0,0)
        self.infoa = OWGUI.label(box, self, 'No data on input.')
        self.infob = OWGUI.label(box, self, "")
        self.infoc = OWGUI.label(box, self, "")

        # ANOVA type
        # group selection
        anovaTypes = ["Single sample t-test", 
            "Single-factor (A, variables)", 
            "Single-factor (B, data sets)", 
            "Two-factor", 
            "Two-factor with interaction effect"]

        self.boxAnovaType = OWGUI.widgetBox(ca, "Anova Type")
        self.anovaTypeS = OWGUI.radioButtonsInBox(self.boxAnovaType, self, "anovaType", btnLabels=anovaTypes)
        
        self.boxAnovaType.setDisabled(1)

        self.boxCompareTo = OWGUI.widgetBox(self.boxAnovaType)
        OWGUI.lineEdit(self.boxCompareTo, self, "compareToValue", callback=self.onCompareToChange, label="compare to")

        # selection of examples
        self.boxSelection = OWGUI.widgetBox(ca, "Example Selection")
        self.lblNumGenes = []   # list of labels

        # selector A
        self.boxSelectorA = OWGUI.widgetBox(self.boxSelection)
        self.cbSelectorA = OWGUI.checkBox(self.boxSelectorA, self, "selectorA", "Factor A (variables)", callback=self.onSelectionChange,
                                          tooltip='H0: The mean does not depend on factor A (represented by variables).')

        frmA = OWGUI.widgetBox(self.boxSelectorA)
        leA = OWGUI.lineEdit(frmA, self, "alphaA", orientation="horizontal", callback=lambda x=0: self.onAlphaChange(x), label= "p <= ")
        self.lblNumGenes.append(OWGUI.label(frmA, self, ""))

        # selector B
        self.boxSelectorB = OWGUI.widgetBox(self.boxSelection)
        self.cbSelectorB = OWGUI.checkBox(self.boxSelectorB, self, "selectorB", "Factor B (data sets)", callback=self.onSelectionChange,
                                          tooltip='H0: The mean does not depend on factor B (represented by data sets).')
 
        frmB = OWGUI.widgetBox(self.boxSelectorB)
        leB = OWGUI.lineEdit(frmB, self, "alphaB", orientation="horizontal", callback=lambda x=1: self.onAlphaChange(x), label= "p <= ")
        self.lblNumGenes.append(OWGUI.label(frmB, self, ""))

        # selector I
        self.boxSelectorI = OWGUI.widgetBox(self.boxSelection)
        self.cbSelectorI = OWGUI.checkBox(self.boxSelectorI, self, "selectorI", "Interaction (variables * data sets)", callback=self.onSelectionChange,
                                          tooltip='H0: There is no interaction between factor A and factor B.')
 
        frmI = OWGUI.widgetBox(self.boxSelectorI)
        leI = OWGUI.lineEdit(frmI, self, "alphaI", orientation="horizontal", callback=lambda x=2: self.onAlphaChange(x), label= "p <= ")
        self.lblNumGenes.append(OWGUI.label(frmI, self, ""))

        # output
        box = OWGUI.widgetBox(ca, "Output")
        self.leSelectorName = OWGUI.lineEdit(box, self, 'selectorName', label='Selector Name: ')
        self.leSelectorName.setReadOnly(self.autoUpdateSelName)
        OWGUI.checkBox(box, self, 'autoUpdateSelName', 'Automatically update selector name', callback=self.onAutoUpdateSelNameChange)
        OWGUI.checkBox(box, self, 'sendNotSelectedData', 'Send not selected data', callback=self.onSendNotSelectedChange)
        OWGUI.checkBox(box, self, 'sendProbabilities', 'Show p-values', callback=self.onSendProbabilitiesChange)
        OWGUI.checkBox(box, self, 'commitOnChange', 'Commit data on selection change', callback=lambda: self.onCommit(self.commitOnChange))
        self.btnCommit = OWGUI.button(box, self, "Commit", callback=self.onCommit)

        # enable/disable anova type box, example selection box, commit button, update the number of examples for individual selectors
        self.updateAnovaTypeBox()
        self.updateSelectorBox()
        self.updateSelectorInfos()
        self.updateSelectorName()

        self.resize(283, self.sizeHint().height())
Example #30
0
 def createSquarePixmap(color = Qt.black):
     return OWGUI.createAttributePixmap("", color)
Example #31
0
    def __init__(self, parent=None, signalManager = None, loaddata=1):
        OWWidget.__init__(self, parent, signalManager, 'Data Files', wantMainArea = 0, resizingEnabled = 1)

        self.callbackDeposit = []

        self.inputs = []
        self.outputs = [("Examples", ExampleTable), ("Structured Data", DataFiles)]

        self.dataStructure = []
        self.datasets = None
        self.lastSentIds = []

        # Settings
        self.recentDirs=[]  
        self.selectedDirName = "None"
        self.applyOnChange = 0
        self.loadSettings()

        # CONTROLS
        box = OWGUI.widgetBox(self.controlArea, "Directory", addSpace = True, orientation=0)
        self.dircombo=QComboBox(box)
        box.layout().addWidget(self.dircombo)
        button = OWGUI.button(box, self, '...', callback = self.browseDirectory, disabled=0)
        button.setMaximumWidth(25)
        # connecting GUI to code
        self.connect(self.dircombo,SIGNAL('activated(int)'),self.selectDir)

        # info
        box = OWGUI.widgetBox(self.controlArea, "Info", addSpace = True)
        self.infoa = OWGUI.widgetLabel(box, 'No data loaded.')
        self.infob = OWGUI.widgetLabel(box, '')
        self.infoc = OWGUI.widgetLabel(box, '')
            
        # LIST VIEW
        frmListView = OWGUI.widgetBox(self.controlArea, None, addSpace = True)
        self.tree = QTreeWidget(frmListView)
        self.tree.setSelectionMode(QAbstractItemView.MultiSelection)
        self.tree.setHeaderLabel("Directory/Data File")
        frmListView.layout().addWidget(self.tree)
        self.connect(self.tree,SIGNAL('itemSelectionChanged()'),self.selectionChanged)

        # Output
        box = OWGUI.widgetBox(self.controlArea, "Output", addSpace = True)
        OWGUI.checkBox(box, self, 'applyOnChange', 'Commit data on selection change')
        self.commitBtn = OWGUI.button(box, self, "Commit", callback=self.sendData, disabled=1)
        self.resize(300,600)

        # initial settings            
        self.recentDirs=filter(os.path.exists,self.recentDirs)
        self.setDirlist()
        self.dircombo.setCurrentIndex(0)
        if self.recentDirs!=[] and loaddata:
            self.loadData(self.recentDirs[0])
Example #32
0
    def compute(self, res=None, dm=None):

        collectionNames = [ self.geneSel[a] for a in self.gridSel ]

        organism = self.organismTaxids[self.organismIndex]

        if self.gsgo:
            collectionNames.append((("GO",),organism))
        if self.gskegg:
            collectionNames.append((("KEGG",),organism))

        self.geneSets = obiGeneSets.collections(*collectionNames)

        self.resultsOut(None)

        qApp.processEvents()
        self.res = res
        self.dm = dm

        clearListView(self.listView)
        self.addComment("Computing...")
        qApp.processEvents()

        self.phenVar = self.phenCands[self.selectedPhenVar][0]
        self.geneVar = self.geneCands[self.selectedGeneVar]

        if self.res == None and self.data:
            self.setSelMode(False)

            pb = OWGUI.ProgressBar(self, iterations=self.perms+2)

            if hasattr(self, "btnApply"):
                self.btnApply.setFocus()

            kwargs = {}
            dkwargs = {}

            dkwargs["phenVar"] = self.phenVar
            dkwargs["geneVar"] = self.geneVar

            if not obiGsea.already_have_correlations(self.data):

                selectedClasses = self.psel.getSelection()
                fc = "Phenotype group empty. Stopped."
                if len(selectedClasses[0]) == 0:
                    self.addComment(fc)
                    return
                elif len(selectedClasses[1]) == 0:
                    self.addComment(fc)
                    return

                dkwargs["classValues"] = selectedClasses

                dkwargs["atLeast"] = self.atLeast

                permtype = self.permutationTypes[self.ptype][1]
                kwargs["permutation"] = "class" if permtype == "p" else "genes"

            def ifr(case, t, f):
                if case: return t
                else: return f

            kwargs["minSize"] = \
                ifr(self.minSubsetSizeC, self.minSubsetSize, 1)
            kwargs["maxSize"] = \
                ifr(self.maxSubsetSizeC, self.maxSubsetSize, 1000000)
            kwargs["minPart"] = \
                ifr(self.minSubsetPartC, self.minSubsetPart/100.0, 0.0)


            #create gene matcher
            genematcher = obiGene.matcher([[obiGene.GMKEGG(organism)] + ([obiGene.GMDicty()] if organism == "352472"  else [])])

            #dkwargs["caseSensitive"] = self.csgm

            gso = obiGsea.GSEA(self.data, matcher=genematcher, **dkwargs)

            
            for gs in self.geneSets:
                gso.addGenesets([gs])
                qApp.processEvents()

            self.res = gso.compute(n=self.perms, callback=pb.advance, **kwargs)
            
            pb.finish()
Example #33
0
    def __init__(self, parent=None, signalManager=None, name=" GEO Data Sets"):
        OWWidget.__init__(self, parent, signalManager, name)

        self.outputs = [("Expression Data", ExampleTable)]

        ## Settings
        self.selectedAnnotation = 0
        self.includeIf = False
        self.minSamples = 3
        self.autoCommit = False
        self.outputRows = 1
        self.mergeSpots = True
        self.filterString = ""
        self.currentGds = None
        self.selectionChanged = False
        self.autoCommit = False
        self.gdsSelectionStates = {}
        self.splitterSettings = [
            '\x00\x00\x00\xff\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x01\xea\x00\x00\x00\xd7\x01\x00\x00\x00\x07\x01\x00\x00\x00\x02',
            '\x00\x00\x00\xff\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x01\xb5\x00\x00\x02\x10\x01\x00\x00\x00\x07\x01\x00\x00\x00\x01'
        ]
        self.datasetNames = {}
        self.loadSettings()

        self.datasetName = ""

        ## GUI
        self.infoBox = OWGUI.widgetLabel(
            OWGUI.widgetBox(self.controlArea, "Info", addSpace=True),
            "Initializing\n\n"
        )

        box = OWGUI.widgetBox(self.controlArea, "Output", addSpace=True)
        OWGUI.radioButtonsInBox(box, self, "outputRows",
                                ["Genes in rows", "Samples in rows"], "Rows",
                                callback=self.commitIf)
        OWGUI.checkBox(box, self, "mergeSpots", "Merge spots of same gene",
                       callback=self.commitIf)

        OWGUI.separator(box)
        self.nameEdit = OWGUI.lineEdit(
            box, self, "datasetName", "Data set name",
            tooltip="Override the default output data set name",
            callback=self.onNameEdited
        )
        self.nameEdit.setPlaceholderText("")

        box = OWGUI.widgetBox(self.controlArea, "Commit", addSpace=True)
        self.commitButton = OWGUI.button(box, self, "Commit",
                                         callback=self.commit)
        cb = OWGUI.checkBox(box, self, "autoCommit", "Commit on any change")
        OWGUI.setStopper(self, self.commitButton, cb, "selectionChanged",
                         self.commit)
        OWGUI.rubber(self.controlArea)

        self.filterLineEdit = OWGUIEx.lineEditHint(
            self.mainArea, self, "filterString", "Filter",
            caseSensitive=False, matchAnywhere=True,
            callback=self.filter,  delimiters=" ")

        splitter = QSplitter(Qt.Vertical, self.mainArea)
        self.mainArea.layout().addWidget(splitter)
        self.treeWidget = QTreeView(splitter)

        self.treeWidget.setSelectionMode(QAbstractItemView.SingleSelection)
        self.treeWidget.setRootIsDecorated(False)
        self.treeWidget.setSortingEnabled(True)
        self.treeWidget.setAlternatingRowColors(True)
        self.treeWidget.setUniformRowHeights(True)
        self.treeWidget.setEditTriggers(QTreeView.NoEditTriggers)

        linkdelegate = LinkStyledItemDelegate(self.treeWidget)
        self.treeWidget.setItemDelegateForColumn(1, linkdelegate)
        self.treeWidget.setItemDelegateForColumn(8, linkdelegate)
        self.treeWidget.setItemDelegateForColumn(
            0, OWGUI.IndicatorItemDelegate(self.treeWidget,
                                           role=Qt.DisplayRole))

        proxyModel = MySortFilterProxyModel(self.treeWidget)
        self.treeWidget.setModel(proxyModel)
        self.treeWidget.selectionModel().selectionChanged.connect(
            self.updateSelection
        )
        self.treeWidget.viewport().setMouseTracking(True)

        splitterH = QSplitter(Qt.Horizontal, splitter)

        box = OWGUI.widgetBox(splitterH, "Description")
        self.infoGDS = OWGUI.widgetLabel(box, "")
        self.infoGDS.setWordWrap(True)
        OWGUI.rubber(box)

        box = OWGUI.widgetBox(splitterH, "Sample Annotations")
        self.annotationsTree = QTreeWidget(box)
        self.annotationsTree.setHeaderLabels(
            ["Type (Sample annotations)", "Sample count"]
        )
        self.annotationsTree.setRootIsDecorated(True)
        box.layout().addWidget(self.annotationsTree)
        self.annotationsTree.itemChanged.connect(
            self.annotationSelectionChanged
        )
        self._annotationsUpdating = False
        self.splitters = splitter, splitterH

        for sp, setting in zip(self.splitters, self.splitterSettings):
            sp.splitterMoved.connect(self.splitterMoved)
            sp.restoreState(setting)

        self.searchKeys = ["dataset_id", "title", "platform_organism",
                           "description"]

        self.gds = []
        self.gds_info = None

        self.resize(1000, 600)

        self.setBlocking(True)
        self.setEnabled(False)
        self.progressBarInit()

        self._executor = ThreadExecutor()

        func = partial(get_gds_model,
                       methodinvoke(self, "_setProgress", (float,)))
        self._inittask = Task(function=func)
        self._inittask.finished.connect(self._initializemodel)
        self._executor.submit(self._inittask)

        self._datatask = None
Example #34
0
    def __init__(self, parent=None, signalManager=None, name=" GEO Data Sets"):
        OWWidget.__init__(self, parent, signalManager, name)

        self.outputs = [("Expression Data", ExampleTable)]

        ## Settings
        self.selectedAnnotation = 0
        self.includeIf = False
        self.minSamples = 3
        self.autoCommit = False
        self.outputRows = 0
        self.mergeSpots = True
        self.filterString = ""
        self.currentGds = None
        self.selectionChanged = False
        self.autoCommit = False
        self.gdsSelectionStates = {}
        self.splitterSettings = [
            '\x00\x00\x00\xff\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x01\xea\x00\x00\x00\xd7\x01\x00\x00\x00\x07\x01\x00\x00\x00\x02',
            '\x00\x00\x00\xff\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x01\xb5\x00\x00\x02\x10\x01\x00\x00\x00\x07\x01\x00\x00\x00\x01'
        ]
        self.datasetNames = {}
        self.loadSettings()

        self.datasetName = ""

        ## GUI
        self.infoBox = OWGUI.widgetLabel(
            OWGUI.widgetBox(self.controlArea, "Info", addSpace=True),
            "Initializing\n\n"
        )

        box = OWGUI.widgetBox(self.controlArea, "Output", addSpace=True)
        OWGUI.radioButtonsInBox(box, self, "outputRows",
                                ["Genes or spots", "Samples"], "Rows",
                                callback=self.commitIf)
        OWGUI.checkBox(box, self, "mergeSpots", "Merge spots of same gene",
                       callback=self.commitIf)

        OWGUI.separator(box)
        self.nameEdit = OWGUI.lineEdit(
            box, self, "datasetName", "Data set name",
            tooltip="Override the default output data set name",
            callback=self.onNameEdited
        )
        self.nameEdit.setPlaceholderText("")

        box = OWGUI.widgetBox(self.controlArea, "Commit", addSpace=True)
        self.commitButton = OWGUI.button(box, self, "Commit",
                                         callback=self.commit)
        cb = OWGUI.checkBox(box, self, "autoCommit", "Commit on any change")
        OWGUI.setStopper(self, self.commitButton, cb, "selectionChanged",
                         self.commit)
        OWGUI.rubber(self.controlArea)

        self.filterLineEdit = OWGUIEx.lineEditHint(
            self.mainArea, self, "filterString", "Filter",
            caseSensitive=False, matchAnywhere=True,
            callback=self.filter,  delimiters=" ")

        splitter = QSplitter(Qt.Vertical, self.mainArea)
        self.mainArea.layout().addWidget(splitter)
        self.treeWidget = QTreeView(splitter)

        self.treeWidget.setSelectionMode(QAbstractItemView.SingleSelection)
        self.treeWidget.setRootIsDecorated(False)
        self.treeWidget.setSortingEnabled(True)
        self.treeWidget.setAlternatingRowColors(True)
        self.treeWidget.setUniformRowHeights(True)
        self.treeWidget.setEditTriggers(QTreeView.NoEditTriggers)

        linkdelegate = LinkStyledItemDelegate(self.treeWidget)
        self.treeWidget.setItemDelegateForColumn(1, linkdelegate)
        self.treeWidget.setItemDelegateForColumn(8, linkdelegate)
        self.treeWidget.setItemDelegateForColumn(
            0, OWGUI.IndicatorItemDelegate(self.treeWidget,
                                           role=Qt.DisplayRole))

        proxyModel = MySortFilterProxyModel(self.treeWidget)
        self.treeWidget.setModel(proxyModel)
        self.treeWidget.selectionModel().selectionChanged.connect(
            self.updateSelection
        )
        self.treeWidget.viewport().setMouseTracking(True)

        splitterH = QSplitter(Qt.Horizontal, splitter)

        box = OWGUI.widgetBox(splitterH, "Description")
        self.infoGDS = OWGUI.widgetLabel(box, "")
        self.infoGDS.setWordWrap(True)
        OWGUI.rubber(box)

        box = OWGUI.widgetBox(splitterH, "Sample Annotations")
        self.annotationsTree = QTreeWidget(box)
        self.annotationsTree.setHeaderLabels(
            ["Type (Sample annotations)", "Sample count"]
        )
        self.annotationsTree.setRootIsDecorated(True)
        box.layout().addWidget(self.annotationsTree)
        self.annotationsTree.itemChanged.connect(
            self.annotationSelectionChanged
        )
        self._annotationsUpdating = False
        self.splitters = splitter, splitterH

        for sp, setting in zip(self.splitters, self.splitterSettings):
            sp.splitterMoved.connect(self.splitterMoved)
            sp.restoreState(setting)

        self.searchKeys = ["dataset_id", "title", "platform_organism",
                           "description"]

        self.gds = []
        self.gds_info = None

        self.resize(1000, 600)

        self.setBlocking(True)
        self.setEnabled(False)
        self.progressBarInit()

        self._executor = ThreadExecutor()

        func = partial(get_gds_model,
                       methodinvoke(self, "_setProgress", (float,)))
        self._inittask = Task(function=func)
        self._inittask.finished.connect(self._initializemodel)
        self._executor.submit(self._inittask)

        self._datatask = None
Example #35
0
    def __init__(self, parent=None, signalManager=None, name=" GEO Data Sets"):
        OWWidget.__init__(self, parent, signalManager, name)

        self.selectionChanged = False
        self.filterString = ""
        self.datasetName = ""

        ## GUI
        box = gui.widgetBox(self.controlArea, "Info", addSpace=True)
        self.infoBox = gui.widgetLabel(box, "Initializing\n\n")

        box = gui.widgetBox(self.controlArea, "Output", addSpace=True)
        gui.radioButtonsInBox(box, self, "outputRows",
                              ["Genes in rows", "Samples in rows"], "Rows",
                              callback=self.commitIf)

        gui.checkBox(box, self, "mergeSpots", "Merge spots of same gene",
                     callback=self.commitIf)

        gui.separator(box)
        self.nameEdit = gui.lineEdit(
            box, self, "datasetName", "Data set name",
            tooltip="Override the default output data set name",
            callback=self.onNameEdited
        )
        self.nameEdit.setPlaceholderText("")

        if sys.version_info < (3, ):
            box = gui.widgetBox(self.controlArea, "Commit", addSpace=True)
            self.commitButton = gui.button(
                box, self, "Commit", callback=self.commit)
            cb = gui.checkBox(box, self, "autoCommit", "Commit on any change")
            gui.setStopper(self, self.commitButton, cb, "selectionChanged",
                           self.commit)
        else:
            gui.auto_commit(self.controlArea, self, "autoCommit", "Commit",
                            box="Commit")
            self.commitIf = self.commit

        gui.rubber(self.controlArea)

        gui.widgetLabel(self.mainArea, "Filter")
        self.filterLineEdit = QLineEdit(
            textChanged=self.filter
        )
        self.completer = TokenListCompleter(
            self, caseSensitivity=Qt.CaseInsensitive
        )
        self.filterLineEdit.setCompleter(self.completer)

        self.mainArea.layout().addWidget(self.filterLineEdit)

        splitter = QSplitter(Qt.Vertical, self.mainArea)
        self.mainArea.layout().addWidget(splitter)
        self.treeWidget = QTreeView(splitter)

        self.treeWidget.setSelectionMode(QTreeView.SingleSelection)
        self.treeWidget.setRootIsDecorated(False)
        self.treeWidget.setSortingEnabled(True)
        self.treeWidget.setAlternatingRowColors(True)
        self.treeWidget.setUniformRowHeights(True)
        self.treeWidget.setEditTriggers(QTreeView.NoEditTriggers)

        linkdelegate = LinkStyledItemDelegate(self.treeWidget)
        self.treeWidget.setItemDelegateForColumn(1, linkdelegate)
        self.treeWidget.setItemDelegateForColumn(8, linkdelegate)
        self.treeWidget.setItemDelegateForColumn(
            0, gui.IndicatorItemDelegate(self.treeWidget,
                                         role=Qt.DisplayRole))

        proxyModel = MySortFilterProxyModel(self.treeWidget)
        self.treeWidget.setModel(proxyModel)
        self.treeWidget.selectionModel().selectionChanged.connect(
            self.updateSelection
        )
        self.treeWidget.viewport().setMouseTracking(True)

        splitterH = QSplitter(Qt.Horizontal, splitter)

        box = gui.widgetBox(splitterH, "Description")
        self.infoGDS = gui.widgetLabel(box, "")
        self.infoGDS.setWordWrap(True)
        gui.rubber(box)

        box = gui.widgetBox(splitterH, "Sample Annotations")
        self.annotationsTree = QTreeWidget(box)
        self.annotationsTree.setHeaderLabels(
            ["Type (Sample annotations)", "Sample count"]
        )
        self.annotationsTree.setRootIsDecorated(True)
        box.layout().addWidget(self.annotationsTree)
        self.annotationsTree.itemChanged.connect(
            self.annotationSelectionChanged
        )
        self._annotationsUpdating = False
        self.splitters = splitter, splitterH

        for sp, setting in zip(self.splitters, self.splitterSettings):
            sp.splitterMoved.connect(self.splitterMoved)
            sp.restoreState(setting)

        self.searchKeys = ["dataset_id", "title", "platform_organism",
                           "description"]

        self.gds = []
        self.gds_info = None

        self.resize(1000, 600)

        self.setBlocking(True)
        self.setEnabled(False)
        self.progressBarInit()

        self._executor = ThreadExecutor()

        func = partial(get_gds_model,
                       methodinvoke(self, "_setProgress", (float,)))
        self._inittask = Task(function=func)
        self._inittask.finished.connect(self._initializemodel)
        self._executor.submit(self._inittask)

        self._datatask = None
    def __init__(self,
                 parent=None,
                 signalManager=None,
                 title="Molecule visualizer"):
        super(OWMoleculeVisualizer, self).__init__(parent, signalManager,
                                                   title)

        self.colorFragments = 1
        self.showFragments = 0
        self.selectedFragment = ""
        self.moleculeSmiles = []
        self.fragmentSmiles = []
        self.defFragmentSmiles = []
        self.smiles_var = 0
        self.moleculeTitleAttr = 0
        self.moleculeTitleAttributeList = []
        self.selectedMoleculeTitleAttrs = []
        self.fragmentSmilesAttr = 0
        self.imageSize = 200
        self.numColumns = 4
        self.commitOnChange = 0

        ## GUI
        box = OWGUI.widgetBox(self.controlArea, "Info", addSpace=True)
        self.infoLabel = OWGUI.label(box, self, "Chemicals:")
        box = OWGUI.radioButtonsInBox(self.controlArea,
                                      self,
                                      "showFragments",
                                      ["Show molecules", "Show fragments"],
                                      "Show",
                                      callback=self.updateitems)

        self.showFragmentsRadioButton = box.buttons[-1]
        self.markFragmentsCheckBox = OWGUI.checkBox(box,
                                                    self,
                                                    "colorFragments",
                                                    "Mark fragments",
                                                    callback=self._update)
        box.setSizePolicy(QSizePolicy(QSizePolicy.Minimum,
                                      QSizePolicy.Maximum))
        OWGUI.separator(self.controlArea)

        self.moleculeSmilesCombo = OWGUI.comboBox(self.controlArea,
                                                  self,
                                                  "smiles_var",
                                                  "Molecule SMILES Attribute",
                                                  callback=self.updateitems)
        self.moleculeSmilesCombo.box.setSizePolicy(
            QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Maximum))
        self.smiles_var_model = VariableListModel(parent=self)
        self.moleculeSmilesCombo.setModel(self.smiles_var_model)

        OWGUI.separator(self.controlArea)
        box = OWGUI.widgetBox(self.controlArea,
                              "Molecule Title Attributes",
                              addSpace=True)

        self.title_var_view = QListView(
            selectionMode=QListView.ExtendedSelection)
        self.title_var_model = VariableListModel(parent=self)
        self.title_var_view.setModel(self.title_var_model)
        self.title_var_view.selectionModel().selectionChanged.connect(
            self._title_selection_changed)
        box.layout().addWidget(self.title_var_view)

        OWGUI.separator(self.controlArea)
        self.fragmentSmilesCombo = OWGUI.comboBox(
            self.controlArea,
            self,
            "fragmentSmilesAttr",
            "Fragment SMILES Attribute",
            callback=self.updateFragmentsListBox)

        self.fragmentSmilesCombo.setModel(VariableListModel(parent=self))
        self.fragmentSmilesCombo.box.setSizePolicy(
            QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Maximum))
        OWGUI.separator(self.controlArea)
        box = OWGUI.spin(self.controlArea,
                         self,
                         "imageSize",
                         50,
                         500,
                         10,
                         box="Image Size",
                         callback=self._image_size_changed)

        box.setSizePolicy(QSizePolicy(QSizePolicy.Minimum,
                                      QSizePolicy.Maximum))

        OWGUI.separator(self.controlArea)
        box = OWGUI.widgetBox(self.controlArea, "Selection", addSpace=True)
        OWGUI.checkBox(box, self, "commitOnChange", "Commit on change")

        self.selectMarkedMoleculesButton = OWGUI.button(
            box, self, "Select &matched molecules", self.select_marked)
        OWGUI.button(box, self, "&Commit", callback=self.commit, default=True)
        OWGUI.separator(self.controlArea)
        OWGUI.rubber(self.controlArea)

        spliter = QSplitter(Qt.Vertical)
        self.scrollArea = ScrollArea(spliter)

        self.grid = GridWidget()
        self.grid.selectionChanged.connect(self._on_selection_changed)

        self.scrollArea.setWidget(self.grid)
        self.scrollArea.setWidgetResizable(True)
        self.mainArea.layout().addWidget(spliter)

        if pybel:
            self.listBox = QListWidget(spliter)
        else:
            self.listBox = QListWidget(None)
            self.listBox.setHidden(True)

        self.listBox.itemClicked.connect(self.fragmentSelection)

        self.fragmentSmilesCombo.box.setDisabled(not pybel)

        self.data = None
        self.data_subset = []
        self.fragment_data = None
        self.resize(800, 600)
        self.listBox.setMaximumHeight(150)
        self.fragmentSmilesCombo.setDisabled(True)
        self.selectMarkedMoleculesButton.setDisabled(True)
        self.markFragmentsCheckBox.setDisabled(True)
        self.showFragmentsRadioButton.setDisabled(True)

        self.loadSettings()

        if not pybel:
            self.showFragments = 0
            self.warning(
                10, "Pybel module not installed. To view molecule fragments\n"
                "please install openbabel python extension.")

        self.__loop = None
Example #37
0
    def __init__(self, parent=None, signalManager=None):
        OWWidget.__init__(self, parent, signalManager, "MeshBrowser")
        self.inputs = [("Reference data", ExampleTable, self.getReferenceData), ("Cluster data", ExampleTable, self.getClusterData)]
        self.outputs = [("Selected examples", ExampleTable)]

        # widget variables
        self.loadedRef = 0
        self.loadedClu = 0
        self.maxPValue = 0.05
        self.minExamplesInTerm = 5
        self.multi = 1
        self.reference = None
        self.cluster = None
        self.loadSettings()
        self.mesh = obiMeSH() # main object is created
        self.dataLoaded = self.mesh.dataLoaded

        # left pane
        box = OWGUI.widgetBox(self.controlArea, "Info")
        #box = QGroupBox("Info", self.controlArea)
        self.infoa = OWGUI.label(box, self, "No reference data.")
        self.infob = OWGUI.label(box, self, "No cluster data.")
        self.ratio = OWGUI.label(box, self, "")
        self.ref_att = OWGUI.label(box, self, "")
        self.clu_att = OWGUI.label(box, self, "")
        self.resize(960, 600)
        OWGUI.separator(self.controlArea)

        self.optionsBox = OWGUI.widgetBox(self.controlArea, "Options")
        self.maxp = OWGUI.lineEdit(self.optionsBox, self, "maxPValue", label="threshold:", orientation="horizontal", labelWidth=120, valueType=float)
        self.minf = OWGUI.lineEdit(self.optionsBox, self, "minExamplesInTerm", label="min. frequency:", orientation="horizontal", labelWidth=120, valueType=int)
        #OWGUI.checkBox(self.optionsBox, self, 'multi', 'Multiple selection', callback= self.checkClicked)
        OWGUI.button(self.optionsBox, self, "Refresh", callback=self.refresh)

        # right pane
        self.col_size = [280, 84, 84, 100, 110]
        self.sort_col = 0
        self.sort_dir = True
        self.columns = ['MeSH term', '# reference', '# cluster', 'p value', 'fold enrichment'] # both datasets

        self.splitter = QSplitter(Qt.Vertical, self.mainArea)
        self.mainArea.layout().addWidget(self.splitter)

        # list view
        self.meshLV = QTreeWidget(self.splitter)
        #self.meshLV.setSelectionMode(QAbstractItemView.MultiSelection)
        self.meshLV.setAllColumnsShowFocus(1)
        self.meshLV.setColumnCount(len(self.columns))
        self.meshLV.setHeaderLabels(self.columns)

        self.meshLV.header().setClickable(True)
        #self.meshLV.header().setSortIndicatorShown(True)
        #self.meshLV.setSortingEnabled(True)
        self.meshLV.setRootIsDecorated(True)
        self.connect(self.meshLV, SIGNAL("itemSelectionChanged()"), self.viewSelectionChanged)
        #self.meshLV.setItemDelegateForColumn(3, EnrichmentColumnItemDelegate(self))
        #self.tooltips = ListViewToolTip(self.meshLV,0, self.mesh.toDesc)

        # table of significant mesh terms
        self.sigTermsTable = QTableWidget(self.splitter)
        self.sigTermsTable.setColumnCount(len(self.columns))
        self.sigTermsTable.setRowCount(4)
        ## hide the vertical header
        self.sigTermsTable.verticalHeader().hide()
        #self.sigTermsTable.setLeftMargin(0)
        #self.sigTermsTable.setSelectionMode(QAbstractItemView.MultiSelection)

        for i in range(0, len(self.columns)):
            self.sigTermsTable.horizontalHeader().resizeSection(i, self.col_size[i])
            self.meshLV.header().resizeSection(i, self.col_size[i])

        self.sigTermsTable.setHorizontalHeaderLabels(self.columns)

        self.connect(self.sigTermsTable, SIGNAL("itemSelectionChanged()"), self.tableSelectionChanged)
        self.connect(self.sigTermsTable, SIGNAL("clicked(int,int,int,const QPoint&)"), self.tableClicked)
        self.splitter.show()
        self.optionsBox.setDisabled(1)
Example #38
0
    def __init__(self, parent=None, signalManager=None, name=" GEO Data Sets"):
        OWWidget.__init__(self, parent, signalManager, name)

        self.selectionChanged = False
        self.filterString = ""
        self.datasetName = ""

        ## GUI
        box = gui.widgetBox(self.controlArea, "Info", addSpace=True)
        self.infoBox = gui.widgetLabel(box, "Initializing\n\n")

        box = gui.widgetBox(self.controlArea, "Output", addSpace=True)
        gui.radioButtonsInBox(box,
                              self,
                              "outputRows",
                              ["Genes in rows", "Samples in rows"],
                              "Rows",
                              callback=self.commitIf)

        gui.checkBox(box,
                     self,
                     "mergeSpots",
                     "Merge spots of same gene",
                     callback=self.commitIf)

        gui.separator(box)
        self.nameEdit = gui.lineEdit(
            box,
            self,
            "datasetName",
            "Data set name",
            tooltip="Override the default output data set name",
            callback=self.onNameEdited)
        self.nameEdit.setPlaceholderText("")

        if sys.version_info < (3, ):
            box = gui.widgetBox(self.controlArea, "Commit", addSpace=True)
            self.commitButton = gui.button(box,
                                           self,
                                           "Commit",
                                           callback=self.commit)
            cb = gui.checkBox(box, self, "autoCommit", "Commit on any change")
            gui.setStopper(self, self.commitButton, cb, "selectionChanged",
                           self.commit)
        else:
            gui.auto_commit(self.controlArea,
                            self,
                            "autoCommit",
                            "Commit",
                            box="Commit")
            self.commitIf = self.commit

        gui.rubber(self.controlArea)

        gui.widgetLabel(self.mainArea, "Filter")
        self.filterLineEdit = QLineEdit(textChanged=self.filter)
        self.completer = TokenListCompleter(self,
                                            caseSensitivity=Qt.CaseInsensitive)
        self.filterLineEdit.setCompleter(self.completer)

        self.mainArea.layout().addWidget(self.filterLineEdit)

        splitter = QSplitter(Qt.Vertical, self.mainArea)
        self.mainArea.layout().addWidget(splitter)
        self.treeWidget = QTreeView(splitter)

        self.treeWidget.setSelectionMode(QTreeView.SingleSelection)
        self.treeWidget.setRootIsDecorated(False)
        self.treeWidget.setSortingEnabled(True)
        self.treeWidget.setAlternatingRowColors(True)
        self.treeWidget.setUniformRowHeights(True)
        self.treeWidget.setEditTriggers(QTreeView.NoEditTriggers)

        linkdelegate = LinkStyledItemDelegate(self.treeWidget)
        self.treeWidget.setItemDelegateForColumn(1, linkdelegate)
        self.treeWidget.setItemDelegateForColumn(8, linkdelegate)
        self.treeWidget.setItemDelegateForColumn(
            0, gui.IndicatorItemDelegate(self.treeWidget, role=Qt.DisplayRole))

        proxyModel = MySortFilterProxyModel(self.treeWidget)
        self.treeWidget.setModel(proxyModel)
        self.treeWidget.selectionModel().selectionChanged.connect(
            self.updateSelection)
        self.treeWidget.viewport().setMouseTracking(True)

        splitterH = QSplitter(Qt.Horizontal, splitter)

        box = gui.widgetBox(splitterH, "Description")
        self.infoGDS = gui.widgetLabel(box, "")
        self.infoGDS.setWordWrap(True)
        gui.rubber(box)

        box = gui.widgetBox(splitterH, "Sample Annotations")
        self.annotationsTree = QTreeWidget(box)
        self.annotationsTree.setHeaderLabels(
            ["Type (Sample annotations)", "Sample count"])
        self.annotationsTree.setRootIsDecorated(True)
        box.layout().addWidget(self.annotationsTree)
        self.annotationsTree.itemChanged.connect(
            self.annotationSelectionChanged)
        self._annotationsUpdating = False
        self.splitters = splitter, splitterH

        for sp, setting in zip(self.splitters, self.splitterSettings):
            sp.splitterMoved.connect(self.splitterMoved)
            sp.restoreState(setting)

        self.searchKeys = [
            "dataset_id", "title", "platform_organism", "description"
        ]

        self.gds = []
        self.gds_info = None

        self.resize(1000, 600)

        self.setBlocking(True)
        self.setEnabled(False)
        self.progressBarInit()

        self._executor = ThreadExecutor()

        func = partial(get_gds_model,
                       methodinvoke(self, "_setProgress", (float, )))
        self._inittask = Task(function=func)
        self._inittask.finished.connect(self._initializemodel)
        self._executor.submit(self._inittask)

        self._datatask = None
Example #39
0
    def __init__(self, parent=None, signalManager=None,
                 title="Venn Diagram"):
        super(OWVennDiagram, self).__init__(parent, signalManager, title,
                                            wantGraph=True)

        self.autocommit = False
        # Selected disjoint subset indices
        self.selection = []

        # Stored input set hints
        # {(index, inputname, attributes): (selectedattrname, itemsettitle)}
        # The 'selectedattrname' can be None
        self.inputhints = {}

        # Use identifier columns for instance matching
        self.useidentifiers = 1

        self.loadSettings()

        # Output changed flag
        self._changed = False
        # Diagram update is in progress
        self._updating = False
        # Input update is in progress
        self._inputUpdate = False
        # All input tables have the same domain.
        self.samedomain = True
        # Input datasets in the order they were 'connected'.
        self.data = OrderedDict()
        # Extracted input item sets in the order they were 'connected'
        self.itemsets = OrderedDict()

        # GUI
        box = OWGUI.widgetBox(self.controlArea, "Info")
        self.info = OWGUI.widgetLabel(box, "No data on input\n")

        self.identifiersBox = OWGUI.radioButtonsInBox(
            self.controlArea, self, "useidentifiers", [],
            box="Data Instance Identifiers",
            callback=self._on_useidentifiersChanged
        )
        self.useequalityButton = OWGUI.appendRadioButton(
            self.identifiersBox, self, "useidentifiers",
            "Use instance equality"
        )
        rb = OWGUI.appendRadioButton(
            self.identifiersBox, self, "useidentifiers",
            "Use identifiers"
        )
        self.inputsBox = OWGUI.indentedBox(
            self.identifiersBox, sep=OWGUI.checkButtonOffsetHint(rb)
        )
        self.inputsBox.setEnabled(self.useidentifiers == 1)

        for i in range(5):
            box = OWGUI.widgetBox(self.inputsBox, "Data set #%i" % (i + 1),
                                  flat=True)
            model = OWItemModels.VariableListModel(parent=self)
            cb = QComboBox()
            cb.setModel(model)
            cb.activated[int].connect(self._on_inputAttrActivated)
            box.setEnabled(False)
            # Store the combo in the box for later use.
            box.combo_box = cb
            box.layout().addWidget(cb)

        OWGUI.rubber(self.controlArea)

        box = OWGUI.widgetBox(self.controlArea, "Output")
        cb = OWGUI.checkBox(box, self, "autocommit", "Commit on any change")
        b = OWGUI.button(box, self, "Commit", callback=self.commit,
                         default=True)
        OWGUI.setStopper(self, b, cb, "_changed", callback=self.commit)

        # Main area view
        self.scene = QGraphicsScene()
        self.view = QGraphicsView(self.scene)
        self.view.setRenderHint(QPainter.Antialiasing)
        self.view.setBackgroundRole(QPalette.Window)
        self.view.setFrameStyle(QGraphicsView.StyledPanel)

        self.mainArea.layout().addWidget(self.view)
        self.vennwidget = VennDiagram()
        self.vennwidget.resize(400, 400)
        self.vennwidget.itemTextEdited.connect(self._on_itemTextEdited)
        self.scene.selectionChanged.connect(self._on_selectionChanged)

        self.scene.addItem(self.vennwidget)

        self.resize(self.controlArea.sizeHint().width() + 550,
                    max(self.controlArea.sizeHint().height(), 550))

        self._queue = []
        self.graphButton.clicked.connect(self.saveImage)
Example #40
0
    def __init__(self, parent=None, signalManager = None, name='Approximate Profiles'):
        self.callbackDeposit = [] # deposit for OWGUI callback functions
        OWWidget.__init__(self, parent, signalManager, name)

        self._data = None       # exampleTable
        self._dataN = None      # 2d numeric array
        self._chipdata = None       # [(dirname0, [et0, et1, ...]), ...]
        self._chipdataN = None      # 3d numeric array
        self.kernel = 0
        self.kernels = ["Orthogonal polynomials", "Trigonometric functions"]
        self.kernelSize = None
        self.kernelSizes = [    ["Const"] + map(lambda x: "degree <= %i"%x, range(1,99)),
                                ["Const", "cos x", "sin x"] + reduce(lambda x,y: x+[y[0],y[1]], map(lambda i: ("cos %ix"%i, "sin %ix"%i), range(2,99)), [])
                            ]
        self.useSignificance = 0
        self.alpha = 3
        self.alphas = [0.0001, 0.001, 0.01, 0.05, 0.1, 0.2, 0.5]
        self.commitOnChange = 1
               
        # Settings
        self.loadSettings()

        # GUI: info, comboKernelSize, cbUseSignificance, vboxSignificance, commitBtn
        # info
        box = QVGroupBox("Info", self.controlArea)
        self.infoa = QLabel("No examples on input", box)
        OWGUI.separator(box,250)
        self.infob = QLabel("No structured data on input", box)
        OWGUI.separator(self.controlArea)

        # kernel selection
        box = QVGroupBox("Kernel functions", self.controlArea)
        OWGUI.comboBox(box, self, "kernel", items=self.kernels, callback=self.kernelChange)
        OWGUI.separator(self.controlArea)

        # kernel settings
        box = QVGroupBox("Kernel settings", self.controlArea)
        self.comboKernelSize = OWGUI.comboBox(box, self, "kernelSize", callback=self.kernelSizeChange, label="Number of kernel functions", labelWidth=135, orientation="horizontal", valueType=int)
        self.comboKernelSize.setDisabled(1)
        self.cbUseSignificance = OWGUI.checkBox(box, self, "useSignificance", "Significance of coefficients (F-statistics)", callback=self.useSignificanceChange, tooltip="Use kernels with coefficients significantly different from 0.")
        self.vboxSignificance = QVBox(box)
        OWGUI.comboBox(self.vboxSignificance, self, "alpha", items = self.alphas, callback=self.alphaChange, label="p <", labelWidth=20, orientation="horizontal")
        OWGUI.separator(self.controlArea)

        # output
        box = QVGroupBox("Output", self.controlArea)
        OWGUI.checkBox(box, self, 'commitOnChange', 'Commit data on selection change')
        self.commitBtn = OWGUI.button(box, self, "Commit", callback=self.senddata, disabled=1)

        self.inputs = [("Examples", ExampleTable, self.data), ("Structured Data", DataFiles, self.chipdata)]
        self.outputs = [("Approximated Examples", ExampleTable, Default), ("Approximation Coefficients", ExampleTable), ("Approximated Structured Data", DataFiles, Default), ("Structured Approximation Coefficients", DataFiles)]
        self.resize(200,100)
    def __init__(self, parent=None, signalManager = None):
#        self.callbackDeposit = [] # deposit for OWGUI callback functions
        OWWidget.__init__(self, parent, signalManager, 'Expression Profiles', 1)

        #set default settings
        self.ShowAverageProfile = 1
        self.ShowSingleProfiles = 0
        self.PointWidth = 2
        self.CurveWidth = 1
        self.AverageCurveWidth = 4
        self.BoxPlotWidth = 2
        self.SelectedClasses = []
        self.Classes = []
        self.autoSendSelected = 0
        self.selectionChangedFlag = False

        self.CutLow = 0; self.CutHigh = 0; self.CutEnabled = 0
        
        self.profileLabel = None

        #load settings
        self.loadSettings()

        # GUI
        self.graph = profilesGraph(self, self.mainArea, "")
        self.mainArea.layout().addWidget(self.graph)
        self.graph.hide()
        self.connect(self.graphButton, SIGNAL("clicked()"), self.graph.saveToFile)

        # GUI definition
        self.tabs = OWGUI.tabWidget(self.space)

        # GRAPH TAB
        GraphTab = OWGUI.createTabPage(self.tabs, "Graph")

        ## display options
        self.infoLabel = OWGUI.widgetLabel(OWGUI.widgetBox(GraphTab, "Info"), "No data on input.")
        displayOptBox = OWGUI.widgetBox(GraphTab, "Display") #QVButtonGroup("Display", GraphTab)
        displayOptButtons = ['Majority Class', 'Majority Class Probability', 'Target Class Probability', 'Number of Instances']
        OWGUI.checkBox(displayOptBox, self, 'ShowSingleProfiles', 'Expression Profiles', tooltip='', callback=self.updateShowSingleProfiles)
        OWGUI.checkBox(displayOptBox, self, 'ShowAverageProfile', 'Box Plot', tooltip='', callback=self.updateShowAverageProfile)

        ## class selection (classQLB)
        self.classQVGB = OWGUI.widgetBox(GraphTab, "Classes") #QVGroupBox(GraphTab)
##        self.classQVGB.setTitle("Classes")
        self.classQLB = OWGUI.listBox(self.classQVGB, self, "SelectedClasses", "Classes", selectionMode=QListWidget.MultiSelection, callback=self.classSelectionChange) #QListBox(self.classQVGB)
##        self.classQLB.setSelectionMode(QListBox.Multi)
        self.unselectAllClassedQLB = OWGUI.button(self.classQVGB, self, "Unselect all", callback=self.SUAclassQLB) #QPushButton("(Un)Select All", self.classQVGB)
##        self.connect(self.unselectAllClassedQLB, SIGNAL("clicked()"), self.SUAclassQLB)
##        self.connect(self.classQLB, SIGNAL("selectionChanged()"), self.classSelectionChange)

        ## show single/average profile
##        self.showAverageQLB = QPushButton("Box Plot", self.classQVGB)
##        self.showAverageQLB.setToggleButton(1)
##        self.showAverageQLB.setOn(self.ShowAverageProfile)
##        self.showSingleQLB = QPushButton("Single Profiles", self.classQVGB)
##        self.showSingleQLB.setToggleButton(1)
##        self.showSingleQLB.setOn(self.ShowSingleProfiles)
##        self.connect(self.showAverageQLB, SIGNAL("toggled(bool)"), self.updateShowAverageProfile)
##        self.connect(self.showSingleQLB, SIGNAL("toggled(bool)"), self.updateShowSingleProfiles)

##        self.tabs.insertTab(GraphTab, "Graph")

        # SETTINGS TAB
        SettingsTab = OWGUI.createTabPage(self.tabs, "Settings") #QVGroupBox(self)

        self.profileLabelComboBox = OWGUI.comboBox(SettingsTab, self, 'profileLabel', 'Profile Labels', sendSelectedValue=True, valueType=str)
        OWGUI.hSlider(SettingsTab, self, 'PointWidth', box='Point Width', minValue=0, maxValue=9, step=1, callback=self.updatePointWidth, ticks=1)
        OWGUI.hSlider(SettingsTab, self, 'CurveWidth', box='Profile Width', minValue=1, maxValue=9, step=1, callback=self.updateCurveWidth, ticks=1)
        OWGUI.hSlider(SettingsTab, self, 'AverageCurveWidth', box='Average Profile Width', minValue=1, maxValue=9, step=1, callback=self.updateAverageCurveWidth, ticks=1)
        OWGUI.hSlider(SettingsTab, self, 'BoxPlotWidth', box='Box Plot Width', minValue=0, maxValue=9, step=1, callback=self.updateBoxPlotWidth, ticks=1)
        OWGUI.checkBox(SettingsTab, self, 'graph.renderAntialiased', "Render antialiased", callback=self.graph.setCurveRenderHints)


    ## graph y scale
        box = OWGUI.widgetBox(SettingsTab, "Threshold/ Values") #QVButtonGroup("Threshol/ Values", SettingsTab)
        OWGUI.checkBox(box, self, 'CutEnabled', "Enabled", callback=self.setCutEnabled)
        self.sliderCutLow = OWGUI.qwtHSlider(box, self, 'CutLow', label='Low:', labelWidth=33, minValue=-20, maxValue=0, step=0.1, precision=1, ticks=0, maxWidth=80, callback=self.updateYaxis)
        self.sliderCutHigh = OWGUI.qwtHSlider(box, self, 'CutHigh', label='High:', labelWidth=33, minValue=0, maxValue=20, step=0.1, precision=1, ticks=0, maxWidth=80, callback=self.updateYaxis)
        if not self.CutEnabled:
            self.sliderCutLow.box.setDisabled(1)
            self.sliderCutHigh.box.setDisabled(1)

##        self.tabs.insertTab(SettingsTab, "Settings")

        self.toolbarSelection = ZoomSelectToolbar(self, self.controlArea, self.graph, self.autoSendSelected, buttons=(ZoomSelectToolbar.IconZoom, ZoomSelectToolbar.IconPan, ZoomSelectToolbar.IconSelect, ZoomSelectToolbar.IconSpace,
                                                                       ZoomSelectToolbar.IconRemoveLast, ZoomSelectToolbar.IconRemoveAll, ZoomSelectToolbar.IconSendSelection))
        cb = OWGUI.checkBox(self.controlArea, self, "autoSendSelected", "Auto send on selection change")
        OWGUI.setStopper(self, self.toolbarSelection.buttonSendSelections, cb, "selectionChangedFlag", self.commit)
        
        # inputs
        # data and graph temp variables
        
        self.inputs = [("Examples", ExampleTable, self.data, Default + Multiple)]
        self.outputs = [("Examples", ExampleTable, Default)]

        # temp variables
        self.MAdata = []
        self.classColor = None
        self.classBrighterColor = None
        self.numberOfClasses  = 0
        self.classValues = []
        self.ctrlPressed = False
        self.attrIcons = self.createAttributeIconDict()

        self.graph.canvas().setMouseTracking(1)

#        self.zoomStack = []
##        self.connect(self.graph,
##                     SIGNAL('plotMousePressed(const QMouseEvent&)'),
##                     self.onMousePressed)
##        self.connect(self.graph,
##                     SIGNAL('plotMouseReleased(const QMouseEvent&)'),
##                     self.onMouseReleased)
        self.resize(800,600)
Example #42
0
    def __init__(self,
                 parent=None,
                 signalManager=None,
                 name="Normalize Expression Array"):
        OWWidget.__init__(self, parent, signalManager, name, wantGraph=True)

        self.inputs = [("Expression array", ExampleTable, self.setData)]
        self.outputs = [("Normalized expression array", ExampleTable, Default),
                        ("Filtered expression array", ExampleTable)]

        self.selectedGroup = 0
        self.selectedCenterMethod = 0
        self.selectedMergeMethod = 0
        self.zCutoff = 1.96
        self.appendZScore = False
        self.appendRIValues = False
        self.autoCommit = False

        self.loadSettings()
        ## GUI
        self.infoBox = OWGUI.widgetLabel(
            OWGUI.widgetBox(self.controlArea, "Info", addSpace=True),
            "No data on input.")

        box = OWGUI.widgetBox(self.controlArea, "Split by", addSpace=True)
        self.groupCombo = OWGUI.comboBox(box,
                                         self,
                                         "selectedGroup",
                                         callback=self.onGroupSelection)

        self.centerCombo = OWGUI.comboBox(
            self.controlArea,
            self,
            "selectedCenterMethod",
            box="Center Fold-change Using",
            items=[name for name, _ in self.CENTER_METHODS],
            callback=self.onCenterMethodChange,
            addSpace=True)

        self.mergeCombo = OWGUI.comboBox(
            self.controlArea,
            self,
            "selectedMergeMethod",
            box="Merge Replicates",
            items=[name for name, _ in self.MERGE_METHODS],
            tooltip="Select the method for replicate merging",
            callback=self.onMergeMethodChange,
            addSpace=True)

        box = OWGUI.doubleSpin(self.controlArea,
                               self,
                               "zCutoff",
                               0.0,
                               3.0,
                               0.01,
                               box="Z-Score Cutoff",
                               callback=[self.replotMA, self.commitIf])

        OWGUI.separator(self.controlArea)

        box = OWGUI.widgetBox(self.controlArea, "Ouput")
        OWGUI.checkBox(box,
                       self,
                       "appendZScore",
                       "Append Z-Scores",
                       tooltip="Append calculated Z-Scores to output",
                       callback=self.commitIf)

        OWGUI.checkBox(
            box,
            self,
            "appendRIValues",
            "Append Log Ratio and Intensity values",
            tooltip=
            "Append calculated Log Ratio and Intensity values to output data",
            callback=self.commitIf)

        cb = OWGUI.checkBox(box,
                            self,
                            "autoCommit",
                            "Commit on change",
                            tooltip="Commit data on any change",
                            callback=self.commitIf)

        b = OWGUI.button(box, self, "Commit", callback=self.commit)
        OWGUI.setStopper(self, b, cb, "changedFlag", callback=self.commit)

        self.connect(self.graphButton, SIGNAL("clicked()"), self.saveGraph)

        OWGUI.rubber(self.controlArea)
        self.graph = OWGraph(self.mainArea)
        self.graph.setAxisTitle(QwtPlot.xBottom,
                                "Intensity: log<sub>10</sub>(R*G)")
        self.graph.setAxisTitle(QwtPlot.yLeft,
                                "Log ratio: log<sub>2</sub>(R/G)")
        self.graph.showFilledSymbols = True
        self.mainArea.layout().addWidget(self.graph)
        self.groups = []
        self.split_data = None, None
        self.merged_splits = None, None
        self.centered = None, None
        self.changedFlag = False
        self.data = None

        self.resize(800, 600)
Example #43
0
    def __init__(self, parent=None, signalManager = None, name='GSEA'):
        OWWidget.__init__(self, parent, signalManager, name)

        self.inputs = [("Examples", ExampleTable, self.setData)]
        self.outputs = [("Examples with selected genes only", ExampleTable), ("Results", ExampleTable), ("Distance Matrix", orange.SymMatrix) ]

        self.res = None
        self.dm = None
        
        self.name = 'GSEA'
        self.minSubsetSize = 3
        self.minSubsetSizeC = True
        self.maxSubsetSize = 1000
        self.maxSubsetSizeC = True
        self.minSubsetPart = 10
        self.minSubsetPartC = True
        self.perms = 100
        self.csgm = False
        self.gsgo = False
        self.gskegg = False
        self.buildDistances = False
        self.selectedPhenVar = 0
        self.organismIndex = 0
        self.atLeast = 3

        self.permutationTypes =  [("Phenotype", "p"),("Gene", "g") ]
        self.ptype = 0

        self.correlationTypes = [ ("Signal2Noise", "s2n") ]
        self.ctype = 0
        
        self.data = None
        self.geneSets = {}

        self.tabs = OWGUI.tabWidget(self.controlArea)

        ca = OWGUI.createTabPage(self.tabs, "Basic")

        box = OWGUI.widgetBox(ca, 'Organism')
        #FROM KEGG WIDGET - organism selection
        self.organismTaxids = []
        self.organismComboBox = cb = OWGUI.comboBox(box, self, "organismIndex", items=[], debuggingEnabled=0) #changed
        cb.setMaximumWidth(200)

        #OWGUI.checkBox(box, self, "csgm", "Case sensitive gene matching")

        box2 = OWGUI.widgetBox(ca, "Descriptors")
        self.phenCombo = OWGUI.comboBox(box2, self, "selectedPhenVar", items=[], callback=self.phenComboChange, label="Phenotype:")
        self.geneCombo = OWGUI.comboBox(box2, self, "selectedGeneVar", items=[], label = "Gene:")

        self.allowComboChangeCallback = False

        ma = self.mainArea

        self.listView = QTreeWidget(ma)
        ma.layout().addWidget(self.listView)
        self.listView.setAllColumnsShowFocus(1)
        self.listView.setColumnCount(9)
        self.listView.setHeaderLabels(["Collection", "Geneset", "NES", "ES", "P-value", "FDR", "Size", "Matched Size", "Genes"])
        
        self.listView.header().setStretchLastSection(True)
        self.listView.header().setClickable(True)
        self.listView.header().setSortIndicatorShown(True)
        self.listView.setSortingEnabled(True)
        #self.listView.header().setResizeMode(0, QHeaderView.Stretch)
        
        self.listView.setSelectionMode(QAbstractItemView.NoSelection)
        self.connect(self.listView, SIGNAL("itemSelectionChanged()"), self.newPathwaySelected)

        OWGUI.separator(ca)

        OWGUI.widgetLabel(ca, "Phenotype selection:")
        self.psel = PhenotypesSelection(ca)
        
        self.resize(600,50)
 
        OWGUI.separator(ca)

        OWGUI.checkBox(ca, self, "buildDistances", "Compute geneset distances")

        self.btnApply = OWGUI.button(ca, self, "&Compute", callback = self.compute, disabled=0)
        
        fileBox = OWGUI.widgetBox(ca, orientation='horizontal')
        OWGUI.button(fileBox, self, "Load", callback = self.loadData, disabled=0, debuggingEnabled=0)
        OWGUI.button(fileBox, self, "Save", callback = self.saveData, disabled=0, debuggingEnabled=0)
 
        #ca.layout().addStretch(1)

        ca = OWGUI.createTabPage(self.tabs, "Gene sets")
        
        box = OWGUI.widgetBox(ca)

        self.gridSel = []
        self.geneSel = []  #FIXME temporary disabled - use the same as in new "David" widget
        self.lbgs = OWGUI.listBox(box, self, "gridSel", "geneSel", selectionMode = QListWidget.MultiSelection)
        OWGUI.button(box, self, "From &File", callback = self.addCollection, disabled=0, debuggingEnabled=0)

        box = OWGUI.widgetBox(box, "Additional sources:")
        OWGUI.checkBox(box, self, "gskegg", "KEGG pathways")
        OWGUI.checkBox(box, self, "gsgo", "GO terms")
 
        #ca.layout().addStretch(1)

        ca = OWGUI.createTabPage(self.tabs, "Settings")
        box = OWGUI.widgetBox(ca, 'Properties')

        self.permTypeF = OWGUI.comboBoxWithCaption(box, self, "ptype", items=nth(self.permutationTypes, 0), \
            tooltip="Permutation type.", label="Permute")
        _ = OWGUI.spin(box, self, "perms", 50, 1000, orientation="horizontal", label="Times")
        self.corTypeF = OWGUI.comboBoxWithCaption(box, self, "ctype", items=nth(self.correlationTypes, 0), \
            tooltip="Correlation type.", label="Correlation")


        box = OWGUI.widgetBox(ca, 'Subset Filtering')

        _,_ = OWGUI.checkWithSpin(box, self, "Min. Subset Size", 1, 10000, "minSubsetSizeC", "minSubsetSize", "") #TODO check sizes
        _,_ = OWGUI.checkWithSpin(box, self, "Max. Subset Size", 1, 10000, "maxSubsetSizeC", "maxSubsetSize", "")
        _,_ = OWGUI.checkWithSpin(box, self, "Min. Subset Part (%)", 1, 100, "minSubsetPartC", "minSubsetPart", "")

        box = OWGUI.widgetBox(ca, 'Gene Filtering')

        _ = OWGUI.spin(box, self, "atLeast", 2, 10, label="Min. Values in Group")

        ca.layout().addStretch(1)

        self.addComment("Computation was not started.")

        if sys.platform == "darwin":
            self.loadFileName = os.path.expanduser("~/")
        else:
            self.loadFileName = "."

        self.gridSels = []
        self.loadSettings()

        self.setBlocking(True)
        QTimer.singleShot(0, self.UpdateOrganismComboBox)

        def cleanInvalid(maxn):
            """
            Removes invalid gene set selection
            """
            notAllOk = True

            while notAllOk:
                self.gridSels = getattr(self, "gridSels")
                notAllOk = False
                for i,a in enumerate(self.gridSels):
                    if a >= maxn:
                        self.gridSels.pop(i)
                        notAllOk = True
                        break
        
        cleanInvalid(len(self.geneSel))

        self.gridSel = self.gridSels
        self.gridSels = self.gridSel
    def __init__(self, parent=None, signalManager=None, title="Gene Atlas Tissue Expression"):
        OWWidget.__init__(self, parent, signalManager, title)
        
        self.inputs = [("Example Table", Orange.data.Table, self.set_data)]
        self.outputs = [("Selected Genes", Orange.data.Table)]
        
        self.selected_organism = "H**o sapiens"
        self.selected_gene_attr = 0
        self.genes_in_columns = False
        self.selected_ef = 0
        self.selected_ef_value = 0
        
        self.loadSettings()
        
        #####
        # GUI
        #####
        box = OWGUI.widgetBox(self.controlArea, "Info", addSpace=True)
        self.info_label = OWGUI.widgetLabel(box, "No data on input.\n")
        
        box = OWGUI.widgetBox(self.controlArea, "Organism", addSpace=True)
        cb = OWGUI.comboBox(box, self, "selected_organism",
                            items=self.ORGANISMS,
                            tooltip="Organism name",
                            callback=self.on_organism_change,
                            sendSelectedValue=True,
                            valueType=str
                            )
        cb.setMaximumWidth(250)
        
        box = OWGUI.widgetBox(self.controlArea, "Gene Attribute", addSpace=True)
        self.gene_attr_cb = OWGUI.comboBox(box, self, "selected_gene_attr",
                              tooltip="Attribute (column) containing the gene names.",
                              callback=self.on_gene_attr_change,
                              )
        self.gene_attr_cb.setMaximumWidth(250)
        
        cb = OWGUI.checkBox(box, self, "genes_in_columns", "Use attribute names",
                       tooltip="Gene names in columns.",
                       callback=self.on_genes_change,)
        cb.disables.append((-1, self.gene_attr_cb))
        cb.makeConsistent()
        
        box = OWGUI.widgetBox(self.controlArea, "Tissues", addSpace=True)
        self.categories_cb = OWGUI.comboBox(box, self, "selected_ef",
                                box="Categories", 
                                items=self.FACTORS,
                                tooltip="Experimental factor.",
                                callback=self.on_ef_change,
                                )
        self.categories_cb.box.setFlat(True)
        
        self.values_cb = OWGUI.comboBox(box, self, "selected_ef_value",
                                box="Values",
                                tooltip="Experimental factor value.",
                                callback=self.on_ef_value_change
                                )
        self.values_cb.setMaximumWidth(250)
        self.values_cb.box.setFlat(True)
        
        box = OWGUI.widgetBox(self.controlArea, "Cache", addSpace=True)
        OWGUI.button(box, self, "Clear cache",
                     callback=self.on_cache_clear,
                     tooltip="Clear Gene Atlas cache.")
        
        OWGUI.rubber(self.controlArea)
        
        OWGUI.button(self.controlArea, self, label="Commit",
                     callback=self.commit,
                     tooltip="Send selected genes")
        
        self.report_view = QTreeView(self.mainArea)
        self.report_view.setSelectionMode(QTreeView.ExtendedSelection)
        self.report_view.setSortingEnabled(True)
        self.report_view.setRootIsDecorated(False)
        self.report_view.setAlternatingRowColors(True)
        self.report_view.setEditTriggers(QTreeView.NoEditTriggers)
        self.mainArea.layout().addWidget(self.report_view)
        self.report_header = ["Gene symbol", "Up", "Down"]
        
        model = QStandardItemModel()
        model.setHorizontalHeaderLabels(self.report_header)
        self.report_view.setModel(model)
        
        self.data = None
        self.candidate_vars = []
        self.candidate_var_names = []
        self.results = {}, {}, {}
        
        self.ensembl_info = None
        self.gene_matcher = obiGene.GMDirect()
        self.loaded_matcher_taxid = None
        self.unknown_genes = []
        self.query_genes = []
        
#        self.set_organism(self.selected_organism, update_results=False)
        
        self.get_atlas_summary = obiGeneAtlas.get_atlas_summary
        
        #Cached construct_matcher
        @lru_cache(maxsize=3)
        def my_cached_matcher(org):
            return obiGeneAtlas.default_gene_matcher(org)
        self.construct_matcher = my_cached_matcher
Example #45
0
    def __init__(self, parent=None, signalManager=None,
                 name="Databases update", domains=None):
        OWWidget.__init__(self, parent, signalManager, name,
                          wantMainArea=False)

        self.searchString = ""
        self.accessCode = ""
        self.domains = domains or DOMAINS
        self.serverFiles = serverfiles.ServerFiles()

        fbox = gui.widgetBox(self.controlArea, "Filter")
        self.completer = TokenListCompleter(
            self, caseSensitivity=Qt.CaseInsensitive)
        self.lineEditFilter = QLineEdit(textChanged=self.SearchUpdate)
        self.lineEditFilter.setCompleter(self.completer)

        fbox.layout().addWidget(self.lineEditFilter)

        box = gui.widgetBox(self.controlArea, "Files")

        self.filesView = QTreeWidget(self)
        self.filesView.setHeaderLabels(
            ["", "Data Source", "Update", "Last Updated", "Size"])

        self.filesView.setRootIsDecorated(False)
        self.filesView.setUniformRowHeights(True)
        self.filesView.setSelectionMode(QAbstractItemView.NoSelection)
        self.filesView.setSortingEnabled(True)
        self.filesView.sortItems(1, Qt.AscendingOrder)
        self.filesView.setItemDelegateForColumn(
            0, UpdateOptionsItemDelegate(self.filesView))

        self.filesView.model().layoutChanged.connect(self.SearchUpdate)

        box.layout().addWidget(self.filesView)

        box = gui.widgetBox(self.controlArea, orientation="horizontal")
        self.updateButton = gui.button(
            box, self, "Update all",
            callback=self.UpdateAll,
            tooltip="Update all updatable files",
         )

        self.downloadButton = gui.button(
            box, self, "Download all",
            callback=self.DownloadFiltered,
            tooltip="Download all filtered files shown"
        )

        self.cancelButton = gui.button(
            box, self, "Cancel", callback=self.Cancel,
            tooltip="Cancel scheduled downloads/updates."
        )

        self.retryButton = gui.button(
            box, self, "Reconnect", callback=self.RetrieveFilesList
        )
        self.retryButton.hide()

        gui.rubber(box)

        gui.lineEdit(box, self, "accessCode", "Access Code",
                     orientation="horizontal",
                     callback=self.RetrieveFilesList)

        self.warning(0)

        box = gui.widgetBox(self.controlArea, orientation="horizontal")
        gui.rubber(box)

        self.infoLabel = QLabel()
        self.infoLabel.setAlignment(Qt.AlignCenter)

        self.controlArea.layout().addWidget(self.infoLabel)
        self.infoLabel.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)

        self.updateItems = []

        self.resize(800, 600)

        self.progress = ProgressState(self, maximum=3)
        self.progress.valueChanged.connect(self._updateProgress)
        self.progress.rangeChanged.connect(self._updateProgress)
        self.executor = ThreadExecutor(
            threadPool=QThreadPool(maxThreadCount=2)
        )

        task = Task(self, function=self.RetrieveFilesList)
        task.exceptionReady.connect(self.HandleError)
        task.start()

        self._tasks = []
        self._haveProgress = False
Example #46
0
    def __init__(self, parent=None, signalManager=None, title="Gene Network"):
        super(OWGeneNetwork, self).__init__(
            parent, signalManager, title, wantMainArea=False,
            resizingEnabled=False
        )

        self.taxid = "9606"
        self.gene_var_index = -1
        self.use_attr_names = False
        self.network_source = 1
        self.include_neighborhood = True
        self.autocommit = False
        self.min_score = 0.9
        self.loadSettings()

        self.taxids = taxonomy.common_taxids()
        self.current_taxid_index = self.taxids.index(self.taxid)

        self.data = None
        self.geneinfo = None
        self.nettask = None
        self._invalidated = False

        box = OWGUI.widgetBox(self.controlArea, "Info")
        self.info = OWGUI.widgetLabel(box, "No data on input\n")

        box = OWGUI.widgetBox(self.controlArea, "Organism")
        self.organism_cb = OWGUI.comboBox(
            box, self, "current_taxid_index",
            items=map(taxonomy.name, self.taxids),
            callback=self._update_organism
        )
        box = OWGUI.widgetBox(self.controlArea, "Genes")
        self.genes_cb = OWGUI.comboBox(
            box, self, "gene_var_index", callback=self._update_query_genes
        )
        self.varmodel = OWItemModels.VariableListModel()
        self.genes_cb.setModel(self.varmodel)

        OWGUI.checkBox(
            box, self, "use_attr_names",
            "Use attribute names",
            callback=self._update_query_genes
        )

        box = OWGUI.widgetBox(self.controlArea, "Network")
        OWGUI.comboBox(
            box, self, "network_source",
            items=[s.name for s in SOURCES],
            callback=self._on_source_db_changed
        )
        OWGUI.checkBox(
            box, self, "include_neighborhood",
            "Include immediate gene neighbors",
            callback=self.invalidate
        )
        self.score_spin = OWGUI.doubleSpin(
            box, self, "min_score", 0.0, 1.0, step=0.001,
            label="Minimal edge score",
            callback=self.invalidate
        )
        self.score_spin.setEnabled(SOURCES[self.network_source].score_filter)

        box = OWGUI.widgetBox(self.controlArea, "Commit")
        OWGUI.button(box, self, "Commit", callback=self.commit, default=True)

        self.executor = ThreadExecutor()
Example #47
0
    def __init__(self, parent=None, signalManager=None):
        OWWidget.__init__(self, parent, signalManager, 'Epistasis Analysis')

        self.inputs = [("Examples", ExampleTable, self.dataset, Multiple),
                       ("Structured  Data", DataFiles, self.chipdata, 1)]
        self.outputs = [("Gene Selection", ExampleSelection),
                        ("Examples A->B", ExampleTable),
                        ("Examples B->A", ExampleTable),
                        ("Examples A||B", ExampleTable)]

        self.data = []
        self.selectedFile = None
        self.A, self.B, self.AB = (None, None, None)
        self.epiA, self.epiB, self.para = (0, 0, 0)
        self.distype = 0
        #set default settings
        self.loadSettings()

        # Selection of data files
        box = OWGUI.widgetBox(self.controlArea, "Data files", addSpace=True)
        #        box = QVButtonGroup("Data Files", self.controlArea)
        #        self.fileLB = OWGUI.listBox(box, self, "selectedFile", "files",
        #                                    tooltip="Select example table",
        ##                                    callback=self.fileSelectionChanged,
        #                                    selectionMode=QListWidget.SingleSelection,
        #                                    )
        #        self.connect(self.fileLB, SIGNAL("currentRowChanged(int)"), self.fileSelectionChanged)
        self.fileLB = QListWidget()
        #        self.fileLB.setMaximumWidth(10)
        self.connect(self.fileLB, SIGNAL("highlighted(int)"),
                     self.fileSelectionChanged)
        #        self.connect(self.fileLB, SIGNAL("selected(int)"), self.setFileReferenceBySelection)
        box.layout().addWidget(self.fileLB)

        hbox = OWGUI.widgetBox(box, "", orientation="horizontal")
        #        hbox = QHBox(box)
        self.markBtns = []
        for (i, lbl) in enumerate(["A", "B", "D"]):
            btn = OWGUI.button(hbox,
                               self,
                               lbl,
                               callback=lambda i=i: self.setMark(i),
                               disabled=1)
            #            btn.setMaximumWidth(45)
            #            btn.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Fixed)
            self.markBtns.append(btn)

        # Relations, checkbox for gene selection
        self.sbox = OWGUI.widgetBox(self.controlArea,
                                    "Relations (Gene Selection)")
        #        self.sbox = QVButtonGroup("Relations (Gene Selection)", self.controlArea)
        self.selChkbox = []
        self.cbinfo = (("epiA", "A -> B", "Gene B is epistatic to gene A"),
                       ("epiB", "B -> A", "Gene A is epistatic to gene B"),
                       ("para", "A || B",
                        "Genes A and B are on parallel pathways"))
        for (i, cb) in enumerate(self.cbinfo):
            cb = OWGUI.checkBox(self.sbox,
                                self,
                                cb[0],
                                cb[1],
                                tooltip=cb[2],
                                callback=self.filterSelectionChanged)
            self.selChkbox.append(cb)
        self.infochi = OWGUI.widgetLabel(self.sbox, "")  #QLabel(self.sbox, '')
        self.sbox.setDisabled(1)

        OWGUI.radioButtonsInBox(self.controlArea,
                                self,
                                "distype",
                                ["Average By Gene", "Average By Measurement"],
                                box="Distance",
                                tooltips=None,
                                callback=self.analysis)

        # scene
        self.scene = QGraphicsScene()
        self.sceneView = QGraphicsView()
        self.sceneView.setScene(self.scene)
        self.scene.setSceneRect(QRectF(0, 0, canvasW, canvasW))
        self.mainArea.layout().addWidget(self.sceneView)

        # canvas
        #        self.canvas = QCanvas()
        #        self.layout = QVBoxLayout(self.mainArea)
        #        self.canvasView = QCanvasView(self.canvas, self.mainArea)
        #        self.canvas.resize(canvasW, canvasW)
        #        self.layout.add(self.canvasView)

        self.resize(420, 350)
Example #48
0
    def __init__(self, parent=None, signalManager=None, name="Vulcano Plot"):
        OWWidget.__init__(self, parent, signalManager, name, wantGraph=True)

        self.inputs = [("Examples", ExampleTable, self.setData)]
        self.outputs = [("Examples with selected attributes", ExampleTable)]

        self.genes_in_columns = False

        self.showXTitle = True
        self.showYTitle = True

        self.auto_commit = False
        self.selection_changed_flag = False
        self.target_group = None, []
        self.label_selections = []

        self.graph = VulcanoGraph(self)
        self.connect(self.graph, SIGNAL("selectionChanged()"),
                     self.on_selection_changed)
        self.mainArea.layout().addWidget(self.graph)

        self.loadSettings()

        ## GUI
        box = OWGUI.widgetBox(self.controlArea, "Info")
        self.infoLabel = OWGUI.label(box, self, "")
        self.infoLabel.setText("No data on input")
        self.infoLabel2 = OWGUI.label(box, self, "")
        self.infoLabel2.setText("0 selected genes")
        
        box = OWGUI.widgetBox(self.controlArea, "Target Labels")
        
        self.target_widget = LabelSelectionWidget(self)
        self.connect(self.target_widget,
                     SIGNAL("selection_changed(PyQt_PyObject, PyQt_PyObject)"),
                     self.on_target_changed)
        self.connect(self.target_widget,
                     SIGNAL("label_activated(int)"),
                     self.on_label_activated)
        
        box.layout().addWidget(self.target_widget)
        
        self.genesInColumnsCheck = OWGUI.checkBox(box, self, "genes_in_columns",
                                    "Genes in columns", 
                                    callback=[self.init_from_data, self.plot])

        box = OWGUI.widgetBox(self.controlArea, "Settings")
        OWGUI.hSlider(box, self, "graph.symbolSize", label="Symbol size:   ", minValue=2, maxValue=20, step=1, callback = self.graph.updateSymbolSize)
        OWGUI.checkBox(box, self, "showXTitle", "X axis title", callback=self.setAxesTitles)
        OWGUI.checkBox(box, self, "showYTitle", "Y axis title", callback=self.setAxesTitles)
        
        toolbar = ZoomSelectToolbar(self, self.controlArea, self.graph, buttons=[ZoomSelectToolbar.IconSelect, ZoomSelectToolbar.IconZoom, ZoomSelectToolbar.IconPan])
        
        top_layout = toolbar.layout()
        top_layout.setDirection(QBoxLayout.TopToBottom)
        button_layotu = QHBoxLayout()
        top_layout.insertLayout(0, button_layotu)
        
        for i in range(1, top_layout.count()):
            item = top_layout.itemAt(1)
            top_layout.removeItem(item)
            button_layotu.addItem(item)
        
        OWGUI.checkBox(toolbar, self, "graph.symetricSelections", "Symetric selection", callback=self.graph.reselect)

        box = OWGUI.widgetBox(self.controlArea, "Commit")
        b = OWGUI.button(box, self, "Commit", callback=self.commit, default=True)
        cb = OWGUI.checkBox(box, self, "auto_commit", "Commit automatically")
        OWGUI.setStopper(self, b, cb, "selection_changed_flag", self.commit_if)

        self.connect(self.graphButton, SIGNAL("clicked()"), self.graph.saveToFile)
        
        OWGUI.rubber(self.controlArea)

        self.data = None
        self.target_group = None, []
        self.current_selection = []

        self.graph.reselect(True)
        self.resize(800, 600)
    def __init__(self, parent=None, signalManager=None,
                 name="Databases update"):
        OWWidget.__init__(self, parent, signalManager, name,
                          wantMainArea=False)

        self.searchString = ""

        fbox = gui.widgetBox(self.controlArea, "Filter")
        self.completer = TokenListCompleter(
            self, caseSensitivity=Qt.CaseInsensitive)
        self.lineEditFilter = QLineEdit(textChanged=self.SearchUpdate)
        self.lineEditFilter.setCompleter(self.completer)

        fbox.layout().addWidget(self.lineEditFilter)

        box = gui.widgetBox(self.controlArea, "Files")

        self.filesView = QTreeWidget(self)
        self.filesView.setHeaderLabels(
            ["", "Data Source", "Update", "Last Updated", "Size"])

        self.filesView.setRootIsDecorated(False)
        self.filesView.setUniformRowHeights(True)
        self.filesView.setSelectionMode(QAbstractItemView.NoSelection)
        self.filesView.setSortingEnabled(True)
        self.filesView.sortItems(1, Qt.AscendingOrder)
        self.filesView.setItemDelegateForColumn(
            0, UpdateOptionsItemDelegate(self.filesView))

        self.filesView.model().layoutChanged.connect(self.SearchUpdate)

        box.layout().addWidget(self.filesView)

        box = gui.widgetBox(self.controlArea, orientation="horizontal")
        self.updateButton = gui.button(
            box, self, "Update all",
            callback=self.UpdateAll,
            tooltip="Update all updatable files",
         )

        self.downloadButton = gui.button(
            box, self, "Download all",
            callback=self.DownloadFiltered,
            tooltip="Download all filtered files shown"
        )

        self.cancelButton = gui.button(
            box, self, "Cancel", callback=self.Cancel,
            tooltip="Cancel scheduled downloads/updates."
        )

        self.retryButton = gui.button(
            box, self, "Reconnect", callback=self.RetrieveFilesList
        )
        self.retryButton.hide()

        gui.rubber(box)
        self.warning(0)

        box = gui.widgetBox(self.controlArea, orientation="horizontal")
        gui.rubber(box)

        self.infoLabel = QLabel()
        self.infoLabel.setAlignment(Qt.AlignCenter)

        self.controlArea.layout().addWidget(self.infoLabel)
        self.infoLabel.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)

        self.updateItems = []

        self.resize(800, 600)

        self.progress = ProgressState(self, maximum=3)
        self.progress.valueChanged.connect(self._updateProgress)
        self.progress.rangeChanged.connect(self._updateProgress)
        self.executor = ThreadExecutor(
            threadPool=QThreadPool(maxThreadCount=2)
        )

        task = Task(self, function=self.RetrieveFilesList)
        task.exceptionReady.connect(self.HandleError)
        task.start()

        self._tasks = []
        self._haveProgress = False
    def __init__(self, parent=None, signalManager=None, title="Expression Profile Distances"):
        OWWidget.__init__(self, parent, signalManager, title)

        self.inputs = [("Example Table", ExampleTable, self.set_data)]
        self.outputs = [("Distances", Orange.core.SymMatrix), ("Sorted Example Table", ExampleTable)]

        self.distance_measure = 0
        self.auto_commit = False
        self.changed_flag = False

        self.loadSettings()

        ########
        # GUI
        ########

        self.info_box = OWGUI.widgetLabel(
            OWGUI.widgetBox(self.controlArea, "Input", addSpace=True), "No data on input\n"
        )

        box = OWGUI.widgetBox(self.controlArea, "Separate By", addSpace=True)
        self.separate_view = QListView()
        self.separate_view.setSelectionMode(QListView.MultiSelection)
        box.layout().addWidget(self.separate_view)

        box = OWGUI.widgetBox(self.controlArea, "Sort By", addSpace=True)
        self.relevant_view = QListView()
        self.relevant_view.setSelectionMode(QListView.MultiSelection)
        box.layout().addWidget(self.relevant_view)

        self.distance_view = OWGUI.comboBox(
            self.controlArea,
            self,
            "distance_measure",
            box="Distance Measure",
            items=[d[0] for d in self.DISTANCE_FUNCTIONS],
        )

        OWGUI.rubber(self.controlArea)

        box = OWGUI.widgetBox(self.controlArea, "Commit")
        cb = OWGUI.checkBox(
            box,
            self,
            "auto_commit",
            "Commit on any change",
            tooltip="Compute and send the distances on any change.",
            callback=self.commit_if,
        )

        b = OWGUI.button(
            box,
            self,
            "Commit",
            tooltip="Compute the distances and send the output signals.",
            callback=self.commit,
            default=True,
        )

        OWGUI.setStopper(self, b, cb, "changed_flag", callback=self.commit)

        self.groups_box = OWGUI.widgetBox(self.mainArea, "Groups")
        self.groups_scroll_area = QScrollArea()
        self.groups_box.layout().addWidget(self.groups_scroll_area)

        self.data = None
        self.partitions = []
        self.matrix = None
        self.split_groups = []
        self._disable_updates = False

        self.resize(800, 600)
Example #51
0
    def __init__(self, parent=None, signalManager = None):
        OWWidget.__init__(self, parent, signalManager, 'Epistasis Analysis') 
        
        self.inputs = [("Examples", ExampleTable, self.dataset, Multiple), ("Structured  Data", DataFiles, self.chipdata, 1)]
        self.outputs = [("Gene Selection", ExampleSelection), ("Examples A->B", ExampleTable), ("Examples B->A", ExampleTable), ("Examples A||B", ExampleTable)]

        self.data = []
        self.selectedFile = None
        self.A, self.B, self.AB = (None, None, None)
        self.epiA, self.epiB, self.para = (0, 0, 0)
        self.distype = 0
        #set default settings
        self.loadSettings()

        # Selection of data files
        box = OWGUI.widgetBox(self.controlArea, "Data files", addSpace=True)
#        box = QVButtonGroup("Data Files", self.controlArea)
#        self.fileLB = OWGUI.listBox(box, self, "selectedFile", "files", 
#                                    tooltip="Select example table",
##                                    callback=self.fileSelectionChanged,
#                                    selectionMode=QListWidget.SingleSelection,
#                                    )
#        self.connect(self.fileLB, SIGNAL("currentRowChanged(int)"), self.fileSelectionChanged)
        self.fileLB = QListWidget()
#        self.fileLB.setMaximumWidth(10)
        self.connect(self.fileLB, SIGNAL("highlighted(int)"), self.fileSelectionChanged)
#        self.connect(self.fileLB, SIGNAL("selected(int)"), self.setFileReferenceBySelection)
        box.layout().addWidget(self.fileLB)
        
        hbox = OWGUI.widgetBox(box, "", orientation="horizontal")
#        hbox = QHBox(box)
        self.markBtns = []
        for (i, lbl) in enumerate(["A","B","D"]):
            btn = OWGUI.button(hbox, self, lbl,
                               callback=lambda i=i: self.setMark(i),
                               disabled=1)
#            btn.setMaximumWidth(45)
#            btn.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Fixed)
            self.markBtns.append(btn)

        # Relations, checkbox for gene selection
        self.sbox = OWGUI.widgetBox(self.controlArea, "Relations (Gene Selection)")
#        self.sbox = QVButtonGroup("Relations (Gene Selection)", self.controlArea)
        self.selChkbox = []
        self.cbinfo = (("epiA", "A -> B", "Gene B is epistatic to gene A"),
                       ("epiB", "B -> A", "Gene A is epistatic to gene B"),
                       ("para", "A || B", "Genes A and B are on parallel pathways"))
        for (i, cb) in enumerate(self.cbinfo):
            cb = OWGUI.checkBox(self.sbox, self, cb[0], cb[1],
                                tooltip=cb[2],
                                callback=self.filterSelectionChanged)
            self.selChkbox.append(cb)
        self.infochi = OWGUI.widgetLabel(self.sbox, "") #QLabel(self.sbox, '')
        self.sbox.setDisabled(1)

        OWGUI.radioButtonsInBox(self.controlArea, self, "distype", ["Average By Gene", "Average By Measurement"],
                                box="Distance", tooltips=None, callback=self.analysis)

        # scene
        self.scene = QGraphicsScene()
        self.sceneView = QGraphicsView()
        self.sceneView.setScene(self.scene)
        self.scene.setSceneRect(QRectF(0, 0, canvasW, canvasW))
        self.mainArea.layout().addWidget(self.sceneView)
        
        # canvas
#        self.canvas = QCanvas()
#        self.layout = QVBoxLayout(self.mainArea)
#        self.canvasView = QCanvasView(self.canvas, self.mainArea)
#        self.canvas.resize(canvasW, canvasW)
#        self.layout.add(self.canvasView)

        self.resize(420,350)
Example #52
0
    def __init__(self, parent=None, signalManager = None):
        OWWidget.__init__(self, parent, signalManager, 'Process Chip Data')
        self.callbackDeposit = []

        self.inputs = [("Structured Data", DataFiles, self.chipdata)]
        self.outputs = [("Structured Data", DataFiles)]

        self.chipdata = None; self.datasets = None
        self.std = [("No preprocessing", None),
                    ("Array-based standardization", chipstat.standardize_arrays),
                    ("Gene-based standardization", chipstat.standardize_genes),
                    ("First array-, then gene-based standardization", lambda e,r: chipstat.standardize_genes(chipstat.standardize_arrays(e,r),r)),
                    ("First gene-, then array-based standardization", lambda e,r: chipstat.standardize_arrays(chipstat.standardize_genes(e,r),r))]
        # Settings
        self.data = None
        self.preStdMethod = 0; self.preStdRob = 1
        self.postStdMethod = 0; self.postStdRob = 1
        
        self.mergeType = 0
        self.commitOnChange = 0
        self.loadSettings()

        # GUI
        # info
        box = QVGroupBox("Info", self.controlArea)
        self.infoa = QLabel('No data on input.', box)
        self.infob = QLabel('', box)
        
        # preprocessing
        OWGUI.separator(self.controlArea)
        box = QVGroupBox("Preprocessing", self.controlArea)
        labels = [x[0] for x in self.std]
        OWGUI.comboBox(box, self, 'preStdMethod', label=None, labelWidth=None, orientation='vertical', items=labels, callback=self.selectionChange)
        self.preRobBtn = OWGUI.checkBox(box, self, "preStdRob", "Robust standardization", callback=self.selectionChange)
        
        # merge
        OWGUI.separator(self.controlArea)
        self.mergeTypes = [(0, "No merging"), ('mean', 'Mean'), ('median', 'Median'), ('min', 'Minimum expression'), ('max', 'Maximum expression')]
        labels = [x[1] for x in self.mergeTypes]
        OWGUI.radioButtonsInBox(self.controlArea, self, 'mergeType', labels, box='Merge Replicas', tooltips=None, callback=self.selectionChange)

        # postprocessing
        OWGUI.separator(self.controlArea)
        self.boxPostproc = QVGroupBox("Postprocessing", self.controlArea)
        labels = [x[0] for x in self.std]
        OWGUI.comboBox(self.boxPostproc, self, 'postStdMethod', label=None, labelWidth=None, orientation='vertical', items=labels, callback=self.selectionChange)
        self.postRobBtn = OWGUI.checkBox(self.boxPostproc, self, "postStdRob", "Robust standardization", callback=self.selectionChange)

        # output
        OWGUI.separator(self.controlArea)
        box = QVGroupBox("Output", self.controlArea)
        OWGUI.checkBox(box, self, 'commitOnChange', 'Commit data on selection change')
        self.commitBtn = OWGUI.button(box, self, "Commit", callback=self.selectionChange, disabled=1)

        self.setBtnsState()
        self.resize(100,100)