Пример #1
0
def _rg(sumstats, args, log, M_annot, ref_ld_cnames, w_ld_cname, i):
    '''Run the regressions.'''
    n_snp = len(sumstats)
    s = lambda x: np.array(x).reshape((n_snp, 1))
    if args.chisq_max is not None:
        ii = sumstats.Z1**2 * sumstats.Z2**2 < args.chisq_max**2
        n_snp = np.sum(ii)  # lambdas are late binding, so this works
        sumstats = sumstats[ii]

    n_blocks = min(args.n_blocks, n_snp)
    ref_ld = sumstats.as_matrix(columns=ref_ld_cnames)
    intercepts = [
        args.intercept_h2[0], args.intercept_h2[i + 1],
        args.intercept_gencov[i + 1]
    ]
    rghat = reg.RG(s(sumstats.Z1),
                   s(sumstats.Z2),
                   ref_ld,
                   s(sumstats[w_ld_cname]),
                   s(sumstats.N1),
                   s(sumstats.N2),
                   M_annot,
                   intercept_hsq1=intercepts[0],
                   intercept_hsq2=intercepts[1],
                   intercept_gencov=intercepts[2],
                   n_blocks=n_blocks,
                   twostep=args.two_step)

    return rghat
Пример #2
0
 def setUp(self):
     self.ld = np.abs(np.random.normal(size=100).reshape((50, 2))) + 2
     self.z1 = (np.sum(self.ld, axis=1) * 10).reshape((50, 1))
     self.w_ld = np.random.normal(size=50).reshape((50, 1))
     self.N1 = 9 * np.ones((50, 1))
     self.N2 = 7 * np.ones((50, 1))
     self.M = np.matrix((700, 222))
     self.hsq1 = 0.5
     self.hsq2 = 0.6
     self.rg = reg.RG(self.z1, -self.z1, self.ld, self.w_ld, self.N1, self.N1,
                      self.M, 1.0, 1.0, 0, n_blocks=20)
Пример #3
0
 def test_negative_h2(self):
     ld = np.arange(50).reshape((50, 1)) + 0.1
     z1 = (1 / np.sum(ld, axis=1) * 10).reshape((50, 1))
     w_ld = np.ones((50, 1))
     N1 = 9 * np.ones((50, 1))
     M = np.matrix((-700))
     rg = reg.RG(z1, -z1, ld, w_ld, N1, N1, M, 1.0, 1.0, 0, n_blocks=20)
     assert rg._negative_hsq
     # check no runtime errors when _negative_hsq is True
     print rg.summary()
     print rg.summary(silly=True)
     assert rg.rg_ratio == 'NA'
     assert rg.rg_se == 'NA'
     assert rg.rg == 'NA'
     assert rg.p == 'NA'
     assert rg.z == 'NA'