def gate_cache(data): ax = services.get_ax() all_markers = None if datatable: all_markers = datatable.dims data.text = ax.figure.text(0.01, 0.01, '', picker=1, size='x-small') data.gater = Gater(ax, all_markers, rect, data.text)
def gate(x_marker, y_marker, rect, color_marker=None, datatable=None): ax = services.get_ax() def gate_cache(data): ax = services.get_ax() all_markers = None if datatable: all_markers = datatable.dims data.text = ax.figure.text(0.01, 0.01, '', picker=1, size='x-small') data.gater = Gater(ax, all_markers, rect, data.text) data = services.cache((ax), gate_cache, True, False) ax.set_xlabel(x_marker) ax.set_ylabel(y_marker) if color_marker: data.text.set_text('Color: %s' % str(color_marker)) data.gater.renew_rect(rect) if not rect: rect = [None, None, None, None] dim_ranges = [ DimRange(x_marker, rect[0], rect[2]), DimRange(y_marker, rect[1], rect[3]) ] #if title: # data.ax.set_title(title) return (dim_ranges, x_marker, y_marker, rect, color_marker)
def gate(x_marker, y_marker, rect, color_marker=None, datatable=None): ax = services.get_ax() def gate_cache(data): ax = services.get_ax() all_markers = None if datatable: all_markers = datatable.dims data.text = ax.figure.text(0.01, 0.01, '', picker=1, size='x-small') data.gater = Gater(ax, all_markers, rect, data.text) data = services.cache((ax), gate_cache, True, False) ax.set_xlabel(x_marker) ax.set_ylabel(y_marker) if color_marker: data.text.set_text('Color: %s' % str(color_marker)) data.gater.renew_rect(rect) if not rect: rect = [None, None, None, None] dim_ranges = [ DimRange(x_marker, rect[0], rect[2]), DimRange(y_marker, rect[1], rect[3])] #if title: # data.ax.set_title(title) return (dim_ranges, x_marker, y_marker, rect, color_marker)
def kde2d(datatable, markers, range, title=None, norm_axis=None, norm_axis_thresh=0.1, *args, **kargs): ax = services.get_ax() #markers = biology.markers.normalize_markers(markers) def cached(data): from mlabwrap import mlab a, w = datatable.get_cols(markers[0], markers[1]) if range: min_a = range[0] max_a = range[2] min_w = range[1] max_w = range[3] else: min_w = min(w) max_w = max(w) min_a = min(a) max_a = max(a) points = datatable.get_points(markers[0], markers[1]) bandwidth, data.density, data.X, data.Y = mlab.kde2d(points, 256, [[min_a, min_w]], [[max_a, max_w]], nout=4) data = services.cache((datatable, markers, range, args, kargs), cached, True, False) display_data = data.density if norm_axis == 'x': max_dens_x = np.array([np.max(data.density, axis=1)]).T if norm_axis_thresh: max_dens_x[max_dens_x < norm_axis_thresh] = np.inf data.density_x = data.density / max_dens_x display_data = data.density_x elif norm_axis == 'y': max_dens_y = np.array([np.max(data.density, axis=0)]) if norm_axis_thresh: max_dens_y[max_dens_y < norm_axis_thresh] = np.inf data.density_y = data.density / max_dens_y display_data = data.density_y if title: data.ax.set_title(title) ax.set_xlabel(str(markers[0]) + ' ') ax.set_ylabel(str(markers[1]) + ' ') display_image( display_data, origin='lower', extent=[data.X[0, 0], data.X[0, -1], data.Y[0, 0], data.Y[-1, 0]], interpolation=None, *args, **kargs) ax.figure.canvas.draw()
def color_table(datatable, dim_x=None, dim_y=None): def cache(data): ax = services.get_ax() Picker(ax, datatable.dims) ax = services.get_ax() services.cache(ax, cache, True, False) #print dim_x #print dim_y display_matrix(datatable.data, cmap=cm.jet) ax.set_xticks(np.arange(len(datatable.dims))) ax.set_yticks(np.arange(-1, len(datatable.dims)+1)) ax.set_xticklabels(datatable.dims) ax.set_yticklabels([''] + datatable.dims) ylabels = ax.yaxis.get_ticklabels() xlabels = ax.xaxis.get_ticklabels() for i in xrange(len(ylabels)): x_index = i-1 ylabels[i].set_fontsize('xx-small') if ylabels[i].get_text() == dim_y: ylabels[i].set_weight('bold') else: ylabels[i].set_weight('normal') if x_index >=0 and x_index < len(xlabels): xlabels[x_index].set_fontsize('xx-small') if ylabels[i].get_text() == dim_x : xlabels[x_index].set_weight('bold') else: xlabels[x_index].set_weight('normal') xlabels[x_index].set_rotation(90) #ax.update_params(left=0, bottom=0) ax.figure.canvas.draw() return (dim_x, dim_y)
def create_data(data): data.ax = services.get_ax() data.line, = data.ax.plot([0], [0]) data.predefined_axes = False if not None in (x_min, x_max, y_min, y_max): data.predefined_axes = True data.ax.set_xlim(x_min, x_max) data.ax.set_ylim(y_min, y_max)
def create_data(data): #logging.info('yoooo') data.ax = services.get_ax() #from matplotlib.colors import LightSource #ls = LightSource(azdeg=0,altdeg=65) #rgb = ls.shade(Z, cm.jet) data.image = data.ax.imshow(Z, extent=extent, *args, **kargs) data.colorbar = data.ax.figure.colorbar(data.image) data.ax.set_aspect('auto')
def kde2d(datatable, markers, range, title=None, norm_axis=None, norm_axis_thresh = 0.1, *args, **kargs): ax = services.get_ax() #markers = biology.markers.normalize_markers(markers) def cached(data): from mlabwrap import mlab a, w = datatable.get_cols(markers[0], markers[1]) if range: min_a = range[0] max_a = range[2] min_w = range[1] max_w = range[3] else: min_w = min(w) max_w = max(w) min_a = min(a) max_a = max(a) points = datatable.get_points(markers[0], markers[1]) bandwidth,data.density, data.X, data.Y = mlab.kde2d( points, 256, [[min_a, min_w]], [[max_a, max_w]], nout=4) data = services.cache((datatable, markers, range, args, kargs), cached, True, False) display_data = data.density if norm_axis == 'x': max_dens_x = np.array([np.max(data.density, axis=1)]).T if norm_axis_thresh: max_dens_x[max_dens_x < norm_axis_thresh] = np.inf data.density_x = data.density / max_dens_x display_data = data.density_x elif norm_axis == 'y': max_dens_y = np.array([np.max(data.density, axis=0)]) if norm_axis_thresh: max_dens_y[max_dens_y < norm_axis_thresh] = np.inf data.density_y = data.density / max_dens_y display_data = data.density_y if title: data.ax.set_title(title) ax.set_xlabel(str(markers[0]) + ' ') ax.set_ylabel(str(markers[1]) + ' ') display_image( display_data, origin='lower', extent=[ data.X[0,0], data.X[0,-1], data.Y[0,0], data.Y[-1,0]], interpolation=None, *args, **kargs) ax.figure.canvas.draw()
def dim_choose(x_marker, y_marker, datatable=None): ax = services.get_ax() def gate_cache(data): ax = services.get_ax() all_markers = None if datatable: all_markers = datatable.dims data.gater = Gater(ax, all_markers, None, None, False, True) data = services.cache((ax), gate_cache, True, False) ax.set_ylabel(y_marker) ax.set_xlabel(x_marker) return (x_marker, y_marker)
def dim_color_choose(x_marker, y_marker, color_marker, datatable=None): ax = services.get_ax() def gate_cache(data): ax = services.get_ax() all_markers = None if datatable: all_markers = datatable.dims data.text = ax.figure.text(0.01, 0.01, '', picker=1, size='x-small') data.gater = Gater(ax, all_markers, None, data.text, False, True) data = services.cache((ax), gate_cache, True, False) ax.set_ylabel(y_marker) ax.set_xlabel(x_marker) data.text.set_text('Color: %s' % str(color_marker)) return (x_marker, y_marker, color_marker)
def gatex(x_marker, y_text, rect, datatable=None): ax = services.get_ax() def gate_cache(data): ax = services.get_ax() all_markers = None if datatable: all_markers = datatable.dims data.gater = Gater(ax, all_markers, rect, None, True) data = services.cache((ax), gate_cache, True, False) ax.set_xlabel(x_marker) ax.set_ylabel(y_text) data.gater.renew_rect(rect) if not rect: rect = [None, None] dim_ranges = [DimRange(x_marker, rect[0], rect[1])] return (dim_ranges, x_marker, rect)
def color_table(datatable, dim_x=None, dim_y=None): def cache(data): ax = services.get_ax() Picker(ax, datatable.dims) ax = services.get_ax() services.cache(ax, cache, True, False) #print dim_x #print dim_y display_matrix(datatable.data, cmap=cm.jet) ax.set_xticks(np.arange(len(datatable.dims))) ax.set_yticks(np.arange(-1, len(datatable.dims) + 1)) ax.set_xticklabels(datatable.dims) ax.set_yticklabels([''] + datatable.dims) ylabels = ax.yaxis.get_ticklabels() xlabels = ax.xaxis.get_ticklabels() for i in xrange(len(ylabels)): x_index = i - 1 ylabels[i].set_fontsize('xx-small') if ylabels[i].get_text() == dim_y: ylabels[i].set_weight('bold') else: ylabels[i].set_weight('normal') if x_index >= 0 and x_index < len(xlabels): xlabels[x_index].set_fontsize('xx-small') if ylabels[i].get_text() == dim_x: xlabels[x_index].set_weight('bold') else: xlabels[x_index].set_weight('normal') xlabels[x_index].set_rotation(90) #ax.update_params(left=0, bottom=0) ax.figure.canvas.draw() return (dim_x, dim_y)
def cache(data): ax = services.get_ax() Picker(ax, datatable.dims)
def gate_cache(data): ax = services.get_ax() all_markers = None if datatable: all_markers = datatable.dims data.gater = Gater(ax, all_markers, rect, None, True)
def create_data(data): data.ax = services.get_ax() data.image = data.ax.matshow(Z, *args, **kargs)
def fix_axis(): ax = services.get_ax()