Exemplo n.º 1
0
 def OnCluster(self, event):
     """
     Handles all clustering requests.
     
     Clustering requests are handled in the following method:
         1. Passes the requested clustering method to 
            L{cluster.dialogs.ClusterOptionsDialog.showDialog} method 
         2. Passes the data and the returned method options to L{cluster.methods.cluster}
         3. Passes the returned cluster membership list to the FacsPlotPanel for display
     """
     dlg = cDlgs.getClusterDialog(event.GetId(), self)
     if dlg.ShowModal() == wx.ID_OK:
         if (DataStore.getCurrentDataSet() is not None):
             self.statusbar.SetStatusText('Running %s clustering...' % cMthds.methods[event.GetId()][1], 0)
             fcs = DataStore.getCurrentDataSet()
             data = fcs.data
             # Remove columns from analysis as specified by the user
             if len(fcs.selDims) > 0:
                 data = dh.filterData(data, fcs.selDims)
             clusterIDs, msg = cMthds.cluster(event.GetId(), data, **dlg.getMethodArgs())
             DataStore.addClustering(event.GetId(), clusterIDs, dlg.getMethodArgs())
             clusteringIndex = DataStore.getCurrentDataSet().clustering.keys()[-1]
             self.statusbar.SetStatusText(msg, 0)
             if (dlg.isApplyChecked()):
                 if self.facsPlotPanel.SelectedSubplotIndex is not None:
                     self.facsPlotPanel.CurrentSubplot = dv.Subplot(self.facsPlotPanel.SelectedSubplotIndex, 
                                                                    DataStore.getCurrentIndex(), clusteringIndex)
                     self.facsPlotPanel.draw()
                 else:
                     self.facsPlotPanel.addSubplot(DataStore.getCurrentIndex(), clusteringIndex)
             self.treeCtrlPanel.updateTree()
     dlg.Destroy()