Example #1
0
def net_ggsvd(name=nu.default_name, reset=0):
    hardcopy = False
    try:
        if reset:
            raise Exception("compute")
        return nw.readnet(name, hardcopy=hardcopy)

    except Exception as e:
        if e.args[0] != "compute":
            raise Exception()
        nw.claim_reset()
        ggn = nu.net_genegene_norm(reset=mod(reset, 2))

        U, S, Vh = lin.svd(ggn)
        V = Vh.T
        dosave = (U, S, V)
        nw.writenet(name, dosave, hardcopy=hardcopy)

        print """
Ran ggsvd.

No hardcopies have been saved yet"""
        if reset:
            net_ggsvd_U(reset=2)
            net_ggsvd_V(reset=2)
            net_ggsvd_S(reset=2)
            print """
...saved hardcopies of U,S,V
"""
        return dosave
Example #2
0
def draw_ggn():
    ggn = nu.net_genegene_norm()
    f = plt.figure(cfig)
    f.clear()
    ax = f.add_axes([0,0,1,1])
    sums = np.sum(ggn,0)
    ax.plot(sums)
Example #3
0
def smear_ggn():
    ggn = nu.net_genegene_norm()
    img = array(ggn)
    s = shape(img)
    for i in range(s[1]):
        img[:,i] = np.sort(img[:,i])[::-1]/ np.max(img[:,i])
    sums = np.sum(img ** 2,0)
    img = img[:, np.argsort(sums)[::-1]]
    draw_smear(img[::xskip,::yskip])    
Example #4
0
def net_cluster_ggn(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_genegene_norm(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