def scatter_blake(a, b, which='circles', classes=[0,1], colors=['k','r'],
        maxval=None, **kwargs):
    if maxval:
        a,b = filter_valpairs(a,b,maxval)
    defaults = {'s': 50, 'alpha':.2, 'lw':0}
    kwargs = ut.dict_set_defaults(kwargs, defaults)
    if type(a[0]) == list or type(a[0]) == tuple:
        # second value is presumed to be class--should be 0 or 1, which will be
        # mapped to the colormap cmap.
        # Also need to clean a and b to just be values rather than values and
        # classes.
        print 'using classes'
        assert ut.i1(a) == ut.i1(b), "Classes not the same between a and b"
        kwargs['c'] = [colors[0] if x==classes[0] else colors[1] for x in
                ut.i1(a)]
        a,b = ut.i0(a), ut.i0(b)
    else:
        c = 'k'
    if which=='pointcloud':
        scatter(a, b, s=50, alpha=0.08, lw=0)
        scatter(a, b, **kwargs)
    elif which=='points':
        scatter(a, b, **kwargs)
    elif which=='fadepoints':
        scatter(a, b, **kwargs)
    elif which=='circles':
        del kwargs['lw']
        scatter(a, b, facecolors='none', edgecolors=c, **kwargs)
    title('R-squared: %0.3f' % ut.r_squared(a,b))
def profiles_cxs(e, cxs, **kwargs):
    # blue/yellow/red map: 'jet'
    defaults = {'interpolation': 'nearest', 'cmap':'hot', 'vmin':1}
    kwargs = ut.dict_set_defaults(kwargs, defaults)
    arr = np.array(e.mat)
    dinds = ut.list_inv_to_dict(e.prots)
    useps = [p for c in cxs for p in c]
    useinds = [dinds[p] for p in useps if p in dinds]
    vals = np.clip(np.log2(arr[useinds,:]),0,100)
    imshow(vals, **kwargs)
    return vals
Beispiel #3
0
def cluster(tested, negmult, cltype, max_pval=0.2, **kwargs):
    kwargs = ut.dict_set_defaults(kwargs, clust_defaults)
    command = c1_command if cltype=='c1' else mcl_command
    if 'runid' in kwargs: # keep temp files separate
        runid = str(kwargs['runid']) 
        kwargs['fin'] = ut.pre_ext(kwargs['fin'], runid)
        kwargs['fout'] = ut.pre_ext(kwargs['fout'], runid)
    export_cxs(tested, kwargs['fin'],negmult)
    command = command % kwargs
    print command
    shell_call(command)
    if cltype=='c1':
        cxs, pvals, cx_details = read_clust_output(kwargs['fout'], max_pval)
    elif cltype=='mcl':
        cxs = read_mcl_output(kwargs['fout'])
        pvals,cx_details=None,None
    else:
        assert False, "Wrong cluster type: %s" %cltype
    return Struct(cxs=cxs, pvals=pvals, cx_details=cx_details)
def hexbin_blake(a, b, maxval=None, **kwargs):
    defaults = {'cmap': 'binary', 'bins':'log', 'gridsize':np.floor(sqrt(len(a))/2) }
    kwargs = ut.dict_set_defaults(kwargs, defaults)
    if maxval:
        a,b = filter_valpairs(a,b,maxval)
    hexbin(a, b, **kwargs)