示例#1
0
 def setUpClass(cls):
     args = parser.parse_args('')
     args.ref_ld = DIR + '/simulate_test/ldscore/twold_onefile'
     args.w_ld = DIR + '/simulate_test/ldscore/w'
     args.rg = ','.join(
         (DIR + '/simulate_test/sumstats/' + str(i) for i in xrange(N_REP)))
     args.out = DIR + '/simulate_test/1'
     x = s.estimate_rg(args, log)
     args.intercept_gencov = ','.join(('0' for _ in xrange(N_REP)))
     args.intercept_h2 = ','.join(('1' for _ in xrange(N_REP)))
     y = s.estimate_rg(args, log)
     cls.rg = x
     cls.rg_noint = y
示例#2
0
 def test_no_check_alleles(self):
     args = parser.parse_args('')
     args.ref_ld = DIR + '/simulate_test/ldscore/oneld_onefile'
     args.w_ld = DIR + '/simulate_test/ldscore/w'
     args.rg = ','.join(
         [DIR + '/simulate_test/sumstats/1' for _ in xrange(2)])
     args.out = DIR + '/simulate_test/1'
     x = s.estimate_rg(args, log)[0]
     args.no_check_alleles = True
     y = s.estimate_rg(args, log)[0]
     assert_equal(x.rg_ratio, y.rg_ratio)
     assert_almost_equal(x.rg_jknife, y.rg_jknife)
     assert_equal(x.rg_se, y.rg_se)
示例#3
0
 def test_no_check_alleles(self):
     args = parser.parse_args('')
     args.ref_ld = DIR + '/simulate_test/ldscore/oneld_onefile'
     args.w_ld = DIR + '/simulate_test/ldscore/w'
     args.rg = ','.join(
         [DIR + '/simulate_test/sumstats/1' for _ in xrange(2)])
     args.out = DIR + '/simulate_test/1'
     x = s.estimate_rg(args, log)[0]
     args.no_check_alleles = True
     y = s.estimate_rg(args, log)[0]
     assert_equal(x.rg_ratio, y.rg_ratio)
     assert_almost_equal(x.rg_jknife, y.rg_jknife)
     assert_equal(x.rg_se, y.rg_se)
示例#4
0
 def setUpClass(cls):
     args = parser.parse_args('')
     args.ref_ld = DIR + '/simulate_test/ldscore/twold_onefile'
     args.w_ld = DIR + '/simulate_test/ldscore/w'
     args.rg = ','.join(
         (DIR + '/simulate_test/sumstats/' + str(i) for i in xrange(N_REP)))
     args.out = DIR + '/simulate_test/1'
     x = s.estimate_rg(args, log)
     args.intercept_gencov = ','.join(('0' for _ in xrange(N_REP)))
     args.intercept_h2 = ','.join(('1' for _ in xrange(N_REP)))
     y = s.estimate_rg(args, log)
     cls.rg = x
     cls.rg_noint = y
示例#5
0
 def test_twostep_rg(self):
     # make sure two step isn't going crazy
     args = parser.parse_args('')
     args.ref_ld_chr = DIR + '/simulate_test/ldscore/oneld_onefile'
     args.w_ld = DIR + '/simulate_test/ldscore/w'
     args.rg = ','.join(
         [DIR + '/simulate_test/sumstats/1' for _ in xrange(2)])
     args.out = DIR + '/simulate_test/rg'
     args.two_step = 999
     x = s.estimate_rg(args, log)[0]
     args.two_step = 99999
     y = s.estimate_rg(args, log)[0]
     assert_allclose(x.rg_ratio, y.rg_ratio, atol=1e-5)
     assert_allclose(x.gencov.tot, y.gencov.tot, atol=1e-5)
示例#6
0
 def test_twostep_h2(self):
     # make sure two step isn't going crazy
     args = parser.parse_args('')
     args.ref_ld = DIR + '/simulate_test/ldscore/oneld_onefile'
     args.w_ld = DIR + '/simulate_test/ldscore/w'
     args.h2 = DIR + '/simulate_test/sumstats/1'
     args.out = DIR + '/simulate_test/1'
     args.chisq_max = 9999999
     args.two_step = 999
     x = s.estimate_h2(args, log)
     args.chisq_max = 9999
     args.two_step = 99999
     y = s.estimate_h2(args, log)
     assert_allclose(x.tot, y.tot, atol=1e-5)
示例#7
0
 def test_twostep_rg(self):
     # make sure two step isn't going crazy
     args = parser.parse_args('')
     args.ref_ld_chr = DIR + '/simulate_test/ldscore/oneld_onefile'
     args.w_ld = DIR + '/simulate_test/ldscore/w'
     args.rg = ','.join(
         [DIR + '/simulate_test/sumstats/1' for _ in xrange(2)])
     args.out = DIR + '/simulate_test/rg'
     args.two_step = 999
     x = s.estimate_rg(args, log)[0]
     args.two_step = 99999
     y = s.estimate_rg(args, log)[0]
     assert_allclose(x.rg_ratio, y.rg_ratio, atol=1e-5)
     assert_allclose(x.gencov.tot, y.gencov.tot, atol=1e-5)
示例#8
0
 def test_twostep_h2(self):
     # make sure two step isn't going crazy
     args = parser.parse_args('')
     args.ref_ld = DIR + '/simulate_test/ldscore/oneld_onefile'
     args.w_ld = DIR + '/simulate_test/ldscore/w'
     args.h2 = DIR + '/simulate_test/sumstats/1'
     args.out = DIR + '/simulate_test/1'
     args.chisq_max = 9999999
     args.two_step = 999
     x = s.estimate_h2(args, log)
     args.chisq_max = 9999
     args.two_step = 99999
     y = s.estimate_h2(args, log)
     assert_allclose(x.tot, y.tot, atol=1e-5)
示例#9
0
 def test_rg_M(self):
     args = parser.parse_args('')
     args.ref_ld = DIR + '/simulate_test/ldscore/oneld_onefile'
     args.w_ld = DIR + '/simulate_test/ldscore/w'
     args.rg = ','.join(
         [DIR + '/simulate_test/sumstats/1' for _ in xrange(2)])
     args.out = DIR + '/simulate_test/1'
     x = s.estimate_rg(args, log)[0]
     args.M = open(DIR + '/simulate_test/ldscore/oneld_onefile.l2.M_5_50',
                   'rb').read().rstrip('\n')
     y = s.estimate_rg(args, log)[0]
     assert_array_almost_equal(x.rg_ratio, y.rg_ratio)
     assert_array_almost_equal(x.rg_se, y.rg_se)
     args.M = '1,2'
     assert_raises(ValueError, s.estimate_rg, args, log)
     args.M = 'foo_bar'
     assert_raises(ValueError, s.estimate_rg, args, log)
示例#10
0
    def setUpClass(cls):
        args = parser.parse_args('')
        args.ref_ld = DIR + '/simulate_test/ldscore/twold_onefile'
        args.w_ld = DIR + '/simulate_test/ldscore/w'
        args.chisq_max = 99999
        h2 = []
        h2_noint = []
        for i in xrange(N_REP):
            args.intercept_h2 = None
            args.h2 = DIR + '/simulate_test/sumstats/' + str(i)
            args.out = DIR + '/simulate_test/1'
            h2.append(s.estimate_h2(args, log))
            args.intercept_h2 = 1
            h2_noint.append(s.estimate_h2(args, log))

        cls.h2 = h2
        cls.h2_noint = h2_noint
示例#11
0
    def setUpClass(cls):
        args = parser.parse_args('')
        args.ref_ld = DIR + '/simulate_test/ldscore/twold_onefile'
        args.w_ld = DIR + '/simulate_test/ldscore/w'
        args.chisq_max = 99999
        h2 = []
        h2_noint = []
        for i in xrange(N_REP):
            args.intercept_h2 = None
            args.h2 = DIR + '/simulate_test/sumstats/' + str(i)
            args.out = DIR + '/simulate_test/1'
            h2.append(s.estimate_h2(args, log))
            args.intercept_h2 = 1
            h2_noint.append(s.estimate_h2(args, log))

        cls.h2 = h2
        cls.h2_noint = h2_noint
示例#12
0
 def test_rg_M(self):
     args = parser.parse_args('')
     args.ref_ld = DIR + '/simulate_test/ldscore/oneld_onefile'
     args.w_ld = DIR + '/simulate_test/ldscore/w'
     args.rg = ','.join(
         [DIR + '/simulate_test/sumstats/1' for _ in xrange(2)])
     args.out = DIR + '/simulate_test/1'
     x = s.estimate_rg(args, log)[0]
     args.M = open(
         DIR + '/simulate_test/ldscore/oneld_onefile.l2.M_5_50', 'rb').read().rstrip('\n')
     y = s.estimate_rg(args, log)[0]
     assert_array_almost_equal(x.rg_ratio, y.rg_ratio)
     assert_array_almost_equal(x.rg_se, y.rg_se)
     args.M = '1,2'
     assert_raises(ValueError, s.estimate_rg, args, log)
     args.M = 'foo_bar'
     assert_raises(ValueError, s.estimate_rg, args, log)
示例#13
0
 def test_h2_M(self):  # check --M works
     args = parser.parse_args('')
     args.ref_ld = DIR + '/simulate_test/ldscore/oneld_onefile'
     args.w_ld = DIR + '/simulate_test/ldscore/w'
     args.h2 = DIR + '/simulate_test/sumstats/1'
     args.out = DIR + '/simulate_test/1'
     args.print_cov = True  # right now just check no runtime errors
     args.print_delete_vals = True
     x = s.estimate_h2(args, log)
     args.M = str(
         float(open(DIR + '/simulate_test/ldscore/oneld_onefile.l2.M_5_50').read()))
     y = s.estimate_h2(args, log)
     assert_array_almost_equal(x.tot, y.tot)
     assert_array_almost_equal(x.tot_se, y.tot_se)
     args.M = '1,2'
     assert_raises(ValueError, s.estimate_h2, args, log)
     args.M = 'foo_bar'
     assert_raises(ValueError, s.estimate_h2, args, log)
示例#14
0
 def test_h2_M(self):  # check --M works
     args = parser.parse_args('')
     args.ref_ld = DIR + '/simulate_test/ldscore/oneld_onefile'
     args.w_ld = DIR + '/simulate_test/ldscore/w'
     args.h2 = DIR + '/simulate_test/sumstats/1'
     args.out = DIR + '/simulate_test/1'
     args.print_cov = True  # right now just check no runtime errors
     args.print_delete_vals = True
     x = s.estimate_h2(args, log)
     args.M = str(
         float(open(DIR + '/simulate_test/ldscore/oneld_onefile.l2.M_5_50').read()))
     y = s.estimate_h2(args, log)
     assert_array_almost_equal(x.tot, y.tot)
     assert_array_almost_equal(x.tot_se, y.tot_se)
     args.M = '1,2'
     assert_raises(ValueError, s.estimate_h2, args, log)
     args.M = 'foo_bar'
     assert_raises(ValueError, s.estimate_h2, args, log)
示例#15
0
 def test_rg_ref_ld(self):
     args = parser.parse_args('')
     args.ref_ld_chr = DIR + '/simulate_test/ldscore/twold_onefile'
     args.w_ld = DIR + '/simulate_test/ldscore/w'
     args.rg = ','.join(
         [DIR + '/simulate_test/sumstats/1' for _ in xrange(2)])
     args.out = DIR + '/simulate_test/1'
     args.print_cov = True  # right now just check no runtime errors
     args.print_delete_vals = True
     x = s.estimate_rg(args, log)[0]
     args.ref_ld = DIR + '/simulate_test/ldscore/twold_firstfile,' + \
         DIR + '/simulate_test/ldscore/twold_secondfile'
     y = s.estimate_rg(args, log)[0]
     args.ref_ld_chr = DIR + '/simulate_test/ldscore/twold_firstfile,' + \
         DIR + '/simulate_test/ldscore/twold_secondfile'
     z = s.estimate_rg(args, log)[0]
     assert_almost_equal(x.rg_ratio, y.rg_ratio)
     assert_almost_equal(y.rg_jknife, z.rg_jknife)
     assert_almost_equal(x.rg_se, y.rg_se)
示例#16
0
 def test_rg_ref_ld(self):
     args = parser.parse_args('')
     args.ref_ld_chr = DIR + '/simulate_test/ldscore/twold_onefile'
     args.w_ld = DIR + '/simulate_test/ldscore/w'
     args.rg = ','.join(
         [DIR + '/simulate_test/sumstats/1' for _ in xrange(2)])
     args.out = DIR + '/simulate_test/1'
     args.print_cov = True  # right now just check no runtime errors
     args.print_delete_vals = True
     x = s.estimate_rg(args, log)[0]
     args.ref_ld = DIR + '/simulate_test/ldscore/twold_firstfile,' + \
         DIR + '/simulate_test/ldscore/twold_secondfile'
     y = s.estimate_rg(args, log)[0]
     args.ref_ld_chr = DIR + '/simulate_test/ldscore/twold_firstfile,' + \
         DIR + '/simulate_test/ldscore/twold_secondfile'
     z = s.estimate_rg(args, log)[0]
     assert_almost_equal(x.rg_ratio, y.rg_ratio)
     assert_almost_equal(y.rg_jknife, z.rg_jknife)
     assert_almost_equal(x.rg_se, y.rg_se)
示例#17
0
    def test_h2_ref_ld(self):  # test different ways of reading ref ld
        args = parser.parse_args('')
        args.ref_ld_chr = DIR + '/simulate_test/ldscore/twold_onefile'
        args.w_ld = DIR + '/simulate_test/ldscore/w'
        args.h2 = DIR + '/simulate_test/sumstats/555'
        args.out = DIR + '/simulate_test/'
        x = s.estimate_h2(args, log)
        args.ref_ld = DIR + '/simulate_test/ldscore/twold_firstfile,' + \
            DIR + '/simulate_test/ldscore/twold_secondfile'
        y = s.estimate_h2(args, log)
        args.ref_ld_chr = DIR + '/simulate_test/ldscore/twold_firstfile,' + \
            DIR + '/simulate_test/ldscore/twold_secondfile'
        z = s.estimate_h2(args, log)
        assert_almost_equal(x.tot, y.tot)
        assert_array_almost_equal(y.cat, z.cat)
        assert_array_almost_equal(x.prop, y.prop)
        assert_array_almost_equal(y.coef, z.coef)

        assert_array_almost_equal(x.tot_se, y.tot_se)
        assert_array_almost_equal(y.cat_se, z.cat_se)
        assert_array_almost_equal(x.prop_se, y.prop_se)
        assert_array_almost_equal(y.coef_se, z.coef_se)
示例#18
0
    def test_h2_ref_ld(self):  # test different ways of reading ref ld
        args = parser.parse_args('')
        args.ref_ld_chr = DIR + '/simulate_test/ldscore/twold_onefile'
        args.w_ld = DIR + '/simulate_test/ldscore/w'
        args.h2 = DIR + '/simulate_test/sumstats/555'
        args.out = DIR + '/simulate_test/'
        x = s.estimate_h2(args, log)
        args.ref_ld = DIR + '/simulate_test/ldscore/twold_firstfile,' + \
            DIR + '/simulate_test/ldscore/twold_secondfile'
        y = s.estimate_h2(args, log)
        args.ref_ld_chr = DIR + '/simulate_test/ldscore/twold_firstfile,' + \
            DIR + '/simulate_test/ldscore/twold_secondfile'
        z = s.estimate_h2(args, log)
        assert_almost_equal(x.tot, y.tot)
        assert_array_almost_equal(y.cat, z.cat)
        assert_array_almost_equal(x.prop, y.prop)
        assert_array_almost_equal(y.coef, z.coef)

        assert_array_almost_equal(x.tot_se, y.tot_se)
        assert_array_almost_equal(y.cat_se, z.cat_se)
        assert_array_almost_equal(x.prop_se, y.prop_se)
        assert_array_almost_equal(y.coef_se, z.coef_se)