示例#1
0
文件: find.py 项目: smdabdoub/find
 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()
示例#2
0
文件: util.py 项目: smdabdoub/find
def reassignClusterIDs(src, dst):
    """
    Given the cluster centers for two clusterings, determine the centers most 
    similar to each other and reassign the cluster ids to match.
    """
    srcFCS = DataStore.getData()[src[0]]
    dstFCS = DataStore.getData()[dst[0]]
    
    srcdata = srcFCS.data
    if srcFCS.selDims:
        srcdata = dh.filterData(srcFCS.data, srcFCS.selDims)
    srcids = srcFCS.clustering[src[1]]
    srccenters = pc.clustercentroids(srcdata, clusterid=srcids)[0]
    
    dstdata = dstFCS.data
    if dstFCS.selDims:
        dstdata = dh.filterData(dstFCS.data, dstFCS.selDims)
    dstids = dstFCS.clustering[dst[1]]
    dstcenters = pc.clustercentroids(dstdata, clusterid=dstids)[0]
    
    srcsep = separate(srcdata, srcids)
    dstsep = separate(dstdata, dstids)

    centerEQ = {}
    taken = []
    # Fill the map with the closest source center for each destination center
    for i,dc in enumerate(dstcenters):
        bestDist = -1
        for j,sc in enumerate(srccenters):
            if (j not in taken):
                dist = nonSymmetricClusterDistance(dstsep[i], srcsep[j])
                if (bestDist < 0) or (dist < bestDist):
                    bestDist = dist
                    centerEQ[i] = j
        taken.append(centerEQ[i])
    
    # Renumber the cluster IDs in the destination to match the IDs of the closest src center
    tmp = [centerEQ[id] for id in dstids]
    DataStore.getData()[dst[0]].clustering[dst[1]] = tmp
示例#3
0
文件: find.py 项目: smdabdoub/find
 def OnAnalyze(self, event):
     """
     Handles all requests for analysis methods; built-in and plugins.
     
     Currently, analysis methods expect data, a list of dimensions
     available to use in analysis, and a window ref in order to 
     display a subwindow/dialog with results or options.
     
     Analysis methods are expected to return data and/or a status
     message. Currently returned data is only used when called from
     code, not from the menu; which this method represents.
     """
     if (DataStore.getCurrentDataSet() is not None):
             strID = aMthds.strID(event.GetId())
             self.statusbar.SetStatusText('Running %s...' % aMthds.AvailableMethods()[strID][2], 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)
             args = {'parentWindow': self}
             _, msg = aMthds.getMethod(strID)(data, **args)
             self.statusbar.SetStatusText(msg, 0)