예제 #1
0
파일: s3.py 프로젝트: bh0085/compbio
def all_siblings(name = default_name, reset = 0):
    
    donp = True
    hardcopy = True
    if not reset:
        out, sxs = nw.rn2(default_name, 
                          np = donp, hardcopy = hardcopy)
    if reset or not sxs:
        
        trgs, tfs = nu.parse_net(reset=mod(reset,2))
        na = nu.net_affinity(reset = mod(reset,2))
    

    
        na_thr = greater(na, min_thr)
        nrms =  sqrt(sum(power(na_thr,2),1))[:,newaxis]
        nrms[equal(nrms,0)] = 1
        nnn = array(na_thr,float)/nrms
        gg = dot(nnn,nnn.T)

        sibs = array(greater(gg, sib_thr), bool)
    
        nw.wn2(default_name, sibs,
               np = donp,
               hardcopy = hardcopy)
        out = sibs
    return out
예제 #2
0
파일: sush2.py 프로젝트: bh0085/compbio
def test_subs(nmax = 2000,reset = 0, name = default_name):
    if not reset:
        out,sxs = nw.rn2(name)
        if not sxs: raise Exception()
        tgls,tfls = out
    else:
        tfls = []
        tgls = []
        for cidx in range(nmax):
            tgs, tfs = get_subs(cidx)
            tgls.append(len(tgs))
            tfls.append(len(tfs))
        nw.wn2(name, (tgls,tfls))
    return tgls, tfls
예제 #3
0
def net_cluster_ggsvdV(k = k,reset = 0):
    hardcopy = True
    try:
        if reset: raise Exception('compute')
        out,sxs =  nw.rn2(name, hardcopy = hardcopy)
        if not sxs: raise Exception()

    except Exception as e:
        if e.args[0] != 'compute': raise Exception()
        nw.claim_reset()
        gg = ns.net_ggsvd_V().T
        kmeans = mlpy.Kmeans(k)
        clustered = kmeans.compute(gg[0:maxgenes,:])
        means = kmeans.means
        nw.wn2(name, (clustered, means) ,hardcopy = hardcopy) 
    return out
예제 #4
0
def net_cluster_genes_by_tf(k= k, reset = 0):
    hardcopy = True
    try:
        if reset: raise Exception('compute')
        out,sxs =  nw.rn2(name, hardcopy = hardcopy)
        if not sxs: raise Exception()

    except Exception as e:
        if e.args[0] != 'compute': raise Exception()
        nw.claim_reset()    
        gg = nu.net_affinity(reset = mod(reset,2))
        kmeans = mlpy.Kmeans(k)
        clustered = kmeans.compute(gg[0:maxgenes,:])
        means = kmeans.means
        out = (clustered,means)
        nw.wn2(name, (clustered, means) ,hardcopy = hardcopy) 
    return out
예제 #5
0
파일: s3.py 프로젝트: bh0085/compbio
def sib_lists(name = default_name, reset = 0, punish = True):

    if not reset:
        out, sxs = nw.rn2(name = name, hardcopy = True, np = True)
        if not sxs: raise Exception()
    else:
        if punish:
            sibs = all_siblings_punish_hubs(name, reset = mod(reset,2))
        else:
            sibs = all_siblings(name, reset = mod(reset,2))

        counts = zeros(len(sibs))
        for i in sibs:
            counts[i] = len(nonzero(i)[0])
    
        f = plt.figure(2)
        f.clear()
        ax = f.add_subplot(111)
        ax.plot(sort(counts))
        nw.wn2(name , sibs, hardcopy  = True, np = True)
        out = sibs
        
    return out