def renameItem(self): """ Give a new display name to the currently selected data item """ item = self.getSanitizedItemSelectionData() if item is None: return if (item[0] is DATA_SET_ITEM): data = DataStore.get(item[1]) dlg = EditNameDialog(self.Parent, data.displayname) if dlg.ShowModal() == wx.ID_OK: data.displayname = dlg.Text dlg.Destroy() if (item[0] is FIGURE_SET_ITEM): figure = FigureStore.get(item[1]) dlg = EditNameDialog(self.Parent, figure.name) if dlg.ShowModal() == wx.ID_OK: figure.name = dlg.Text dlg.Destroy() item = self.tree.GetSelection() item.SetText(dlg.Text) self.tree.RefreshSelected() item.SetHilight(False) item.SetHilight(True)
def scatterplot2D(subplot, figure, dims): # set default plot options if necessary opts = subplot.opts if len(opts) == 0: opts['xRange'] = () opts['xRangeAuto'] = True opts['yRange'] = () opts['yRangeAuto'] = True opts['xTransform'] = '' opts['yTransform'] = '' opts['transformAuto'] = True # Set axes transforms if (opts['transformAuto']): fcData = DataStore.get(subplot.dataIndex) tf = ('xTransform', 'yTransform') for i, dim in enumerate(dims): t = fcData.getDefaultTransform(dim) if (t is not None) and ('log' in t.lower()): opts[tf[i]] = 'log' else: opts[tf[i]] = 'linear' if opts['xRangeAuto']: opts['xRange'] = (1, np.max(subplot.Data[:,dims[0]])*1.5) if opts['yRangeAuto']: opts['yRange'] = (1, np.max(subplot.Data[:,dims[1]])*1.5) # create the subplot and set its attributes subplot.axes = figure.add_subplot(subplot.mnp, xlim=opts['xRange'], ylim=opts['yRange'], autoscale_on=False) subplot.axes.set_xscale(opts['xTransform'], nonposx='clip') subplot.axes.set_yscale(opts['yTransform'], nonposy='clip') subplot.axes.set_xlabel(subplot.Labels[dims[0]]) subplot.axes.set_ylabel(subplot.Labels[dims[1]]) subplot.axes.set_title(subplot.Title) # draw the supplied FACS data if (not subplot.isDataClustered()): subplot.axes.plot(subplot.Data[:,dims[0]], subplot.Data[:,dims[1]], '.', ms=1, color='black') else: data = separate(subplot.Data, subplot.Clustering) for i in range(len(data)): xs = data[i][:,dims[0]] ys = data[i][:,dims[1]] subplot.axes.plot(xs, ys, '.', ms=1, color=methods.plotColors[i])
def saveState(dir, filename): """ Save a representation of the system state: All the loaded data sets, their clusterings, any transformations or analyses (future), and all plots. The state is saved in JSON format based on a dict of the following form: data: list of IDs binfile: the filename of the binary file used to store all the actual data data-dID: dict of settings belonging to a FacsData instance clust-dID-cID: a dict of attributes belonging to a clustering figures: list of figureID strings fig-ID: A dict for each figure keyed on the ID. The subplot attribute here is replaced with a list of fig-ID-p-ID strings for locating subplot dicts fig-ID-p-ID: A dict for each subplot in each figure keyed on fig ID and plot ID. current-data: data ID current-figure: figure ID """ store = shelve.open(os.path.join(dir, filename)) #store = dbopen(os.path.join(dir, filename), 'c', format='csv') # The actual numeric data will be stored in a separate binary file using # the numpy savez() method allowing for efficient storage/retrieval of data binfile = '%s.npz' % filename bindata = {} store['data'] = DataStore.getData().keys() store['binfile'] = binfile for dID in DataStore.getData(): fdata = DataStore.get(dID) dStr = 'data-%i' % dID dfname = fdata.filename if (fdata.filename is not '') else binfile bindata[dStr] = fdata.data store[dStr] = {'filename': dfname, 'displayname': fdata.displayname, 'labels': fdata.labels, 'annotations': fdata.annotations, 'analysis': fdata.analysis, 'ID': fdata.ID, 'parent': fdata.parent, 'children': fdata.children, 'selDims': fdata.selDims, 'clustering': fdata.clustering.keys(), 'nodeExpanded': fdata.nodeExpanded, 'selectedClustering': fdata.selectedClustering} # clusterings for cID in fdata.clustering: cStr = 'clust-%i-%i' % (dID, cID) csett = {'method': fdata.methodIDs[cID], 'opts': fdata.clusteringOpts[cID], 'clusteringSelDims': fdata.clusteringSelDims[cID], 'infoExpanded': fdata.infoExpanded[cID]} store[cStr] = csett bindata[cStr] = fdata.clustering[cID] # figures sfigs = [] for figID in FigureStore.getFigures(): fig = FigureStore.get(figID) fStr = 'fig-%i' % figID d = dict(fig.__dict__) splots = packSubplots(store, figID, fig.subplots) d['subplots'] = splots store[fStr] = d sfigs.append(fStr) store['figures'] = list(sfigs) # other store['current-data'] = DataStore.getCurrentIndex() store['current-figure'] = FigureStore.getSelectedIndex() # write out settings data store.close() # write out numeric data to binary file np.savez(os.path.join(dir, binfile), **bindata)
def clearClusteringSelection(self): item = self.getSanitizedItemSelectionData() if item is not None and item[0] is DATA_SET_ITEM: DataStore.get(item[1]).selectedClustering = None self.updateTree()
def displayDataInfo(self): item = self.getSanitizedItemSelectionData() if item is not None and item[0] is DATA_SET_ITEM: data = DataStore.get(item[1]) dlg = DataInfoDialog(self.Parent, data) dlg.Show()