Example #1
0
def non_normal_cluster_expr(trg_ssnames, tf_ssnames, ctype = False, random_tfs = False):
    if random_tfs:
        tf_kidxs = nu.net_tf_keyidxs()
        r =np.random.random_integers(0,len(tf_kidxs.keys()),len(tf_ssnames))
        tf_ssnames = []
        print 'Randomizing TFs'
        for i in r:
            tf_ssnames.append(tf_kidxs.keys()[i])

    n = nu.parse_net()
    ts = nu.load_TS()
    if ctype:
        cl = nu.load_CL()
        tf_vals = array([ts[k] + cl[k] for k in tf_ssnames]).T
        tg_vals = array([ts[k] + cl[k] for k in trg_ssnames]).T
    else:
        tf_vals = array([ts[k]  for k in tf_ssnames]).T
        tg_vals = array([ts[k]  for k in trg_ssnames]).T        
    
    tf_vals -= np.mean(tf_vals,0)[:]
    tg_vals -= np.mean(tg_vals,0)[:]
    tf_vals /= np.std(tf_vals,0)[:]
    tg_vals /= np.std(tg_vals,0)[:]
        
    return [tg_vals, tf_vals]
Example #2
0
def show_binary(idx = 0):
    tsb = nu.expr_TS_binary(reset = 0)
    tsvals = nu.load_TS()

    net = nu2.get_net()
    tgs = net[1]
    tfs = net[0]

    f = plt.figure(0)
    f.clear()
    ax = f.add_subplot(111)


    
    for k in tsb.keys()[idx:]:
        
        my_tfs = tgs.get(k,[])
        ct = mycolors.getct(len(my_tfs))
        tgseries = tsvals[k]

        if not my_tfs: continue

        for i in range(len(my_tfs)):
            tf = my_tfs[i][0]
            
            series = tsvals.get(tf)
            if not series: continue
            binary = tsb.get(tf)
            #if not binary: 
            #    print 'no ts for ' + tg
            #    continue
            npts = len(binary)

            xax = tgseries
            cmap = equal(binary,0)[:,newaxis]*[1,0,0] + equal(binary,1)[:,newaxis]*[0,1,0]
        
            print my_tfs[i][1]
            ax.scatter(xax, series,  500, 
                       color = cmap,
                       alpha = my_tfs[i][1],
                       edgecolor = '0')
        break
    return
Example #3
0
def viewclusters(cands, fig = 5):
    
    #clusters = get_candidates(get_candidates(10))
    
    f = plt.figure(fig)
    f.clear()
    ax1 = f.add_subplot(111)


    f2 = plt.figure(fig+1)
    f2.clear()
    ax2 = f2.add_subplot(111)

    for index in cands:
        trg_ssnames = get_trg_ss(cluster = index )
        tf_ssnames = get_tf_ss( trgnames = trg_ssnames)    

        n = nu.parse_net()
        ts = nu.load_TS()
        
        tf_vals = array([ts[k] for k in tf_ssnames]).T
        tg_vals = array([ts[k] for k in trg_ssnames]).T
        

        vals = tf_vals
        mvals = np.mean(vals,1)
        vals -= mvals[:,newaxis]
        svals = np.std(vals,1)
        if len(nonzero(equal(svals,0))[0]):
            raise Exception('only one tf...')

        vals /= svals[:,newaxis]

        for v in vals.T:
            v -= mean(v)
            v /= std(v)
        

        ax1.plot(vals)
        
        break
Example #4
0
def normalize_cluster_expr(trg_ssnames, tf_ssnames, ctype = False, random_tfs = False):
    if random_tfs:
        tf_kidxs = nu.net_tf_keyidxs()
        r =np.random.random_integers(0,len(tf_kidxs.keys()),len(tf_ssnames))
        tf_ssnames = []
        print 'Randomizing TFs'
        for i in r:
            tf_ssnames.append(tf_kidxs.keys()[i])

    n = nu.parse_net()
    ts = nu.load_TS()
    if ctype:
        cl = nu.load_CL()
        tf_vals = array([ts[k] + cl[k] for k in tf_ssnames]).T
        tg_vals = array([ts[k] + cl[k] for k in trg_ssnames]).T
    else:
        tf_vals = array([ts[k]  for k in tf_ssnames]).T
        tg_vals = array([ts[k]  for k in trg_ssnames]).T        

    all_exprs = []
    for vstart in [tg_vals, tf_vals]:
        vals = vstart
        mvals = np.mean(vals,1)
        vals -= mvals[:,newaxis]
        svals = np.std(vals,1)
        if len(nonzero(equal(svals,0))[0]):
            raise Exception('only one tf...')
    
        vals /= svals[:,newaxis]
        
        for v in vals.T:
            v -= mean(v)
            v /= std(v)
        all_exprs.append(vals)
        

    #raise Exception()
    return all_exprs