X = f['genotype'][:]
    X-= X.mean(0); X/=X.std(0)
    G = X[:,0:200]

    Y = genPheno(G=G,X=X,var_g=0.10,var_x=0.40,P=P)
    XX = SP.dot(X,X.T)
    XX/= XX.diagonal().mean()
    XX+= 1e-4*SP.eye(XX.shape[0])
    GG = SP.dot(G,G.T)
    GG/= GG.diagonal().mean()
    GG+= 1e-4*SP.eye(GG.shape[0])

    C1 = freeform(P)
    C2 = freeform(P)
    Cn = freeform(P)
    gp = gp3kronSumApprox(Y=Y,C1=C1,C2=C2,Cn=Cn,R1=GG,R2=XX,tol=1e-16) 

    if 0:
        Kinit = SP.cov(Y.T)/3 
        C1.setCovariance(Kinit)
        C2.setCovariance(Kinit)
        Cn.setCovariance(Kinit)
    else:
        C1.setRandomParams()
        C2.setRandomParams()
        Cn.setRandomParams()
    params = gp.getParams()
    gp.setParams(params)

    gp.checkGradient()
    X = f['genotype'][:]
    X-= X.mean(0); X/=X.std(0)
    G = X[:,0:200]

    Y = genPheno(G=G,X=X,var_g=0.10,var_x=0.40,P=P)
    XX = SP.dot(X,X.T)
    XX/= XX.diagonal().mean()
    XX+= 1e-4*SP.eye(XX.shape[0])
    GG = SP.dot(G,G.T)
    GG/= GG.diagonal().mean()
    GG+= 1e-4*SP.eye(GG.shape[0])

    Cr = freeform(P)
    Cg = freeform(P)
    Cn = freeform(P)
    gp = gp3kronSumApprox(Y=Y,Cr=Cr,Cg=Cg,Cn=Cn,XX=XX,GG=GG) 
    n_rips = 10
    for rip in range(n_rips):

        Cr.setRandomParams()
        Cg.setRandomParams()
        Cn.setRandomParams()
        params = gp.getParams()
        gp.setParams(params)

        conv,info = OPT.opt_hyper(gp,params,factr=1e3)
        print conv

        print 'Cr'
        print Cr.K()
        print 'Cg'
Example #3
0
    X -= X.mean(0)
    X /= X.std(0)
    G = X[:, 0:200]

    Y = genPheno(G=G, X=X, var_g=0.10, var_x=0.40, P=P)
    XX = SP.dot(X, X.T)
    XX /= XX.diagonal().mean()
    XX += 1e-4 * SP.eye(XX.shape[0])
    GG = SP.dot(G, G.T)
    GG /= GG.diagonal().mean()
    GG += 1e-4 * SP.eye(GG.shape[0])

    Cr = freeform(P)
    Cg = freeform(P)
    Cn = freeform(P)
    gp = gp3kronSumApprox(Y=Y, Cr=Cr, Cg=Cg, Cn=Cn, XX=XX, GG=GG)
    n_rips = 10
    for rip in range(n_rips):

        Cr.setRandomParams()
        Cg.setRandomParams()
        Cn.setRandomParams()
        params = gp.getParams()
        gp.setParams(params)

        conv, info = OPT.opt_hyper(gp, params, factr=1e3)
        print conv

        print 'Cr'
        print Cr.K()
        print 'Cg'
Example #4
0
    X = f['genotype'][:]
    X-= X.mean(0); X/=X.std(0)
    G = X[:,0:200]

    Y = genPheno(G=G,X=X,var_g=0.10,var_x=0.40,P=P)
    XX = SP.dot(X,X.T)
    XX/= XX.diagonal().mean()
    XX+= 1e-4*SP.eye(XX.shape[0])
    GG = SP.dot(G,G.T)
    GG/= GG.diagonal().mean()
    GG+= 1e-4*SP.eye(GG.shape[0])

    C1 = freeform(P)
    C2 = freeform(P)
    Cn = freeform(P)
    gp = gp3kronSumApprox(Y=Y,C1=C1,C2=C2,Cn=Cn,R1=GG,R2=XX,tol=1e-16) 

    if 0:
        Kinit = SP.cov(Y.T)/3 
        C1.setCovariance(Kinit)
        C2.setCovariance(Kinit)
        Cn.setCovariance(Kinit)
    else:
        C1.setRandomParams()
        C2.setRandomParams()
        Cn.setRandomParams()
    params = gp.getParams()
    gp.setParams(params)

    gp.checkGradient()