def test_two(self):
        '''
        Lock in results on arbitrary data -- because meaningful runs take too long to run.
        '''
        fn = "two.txt"
        logging.info(fn)
        tmpOutfile = self.file_name(fn)

        snpreader = self.snpreader_whole[:10, :]

        spatial_coor = [[i, -i] for i in xrange(snpreader.iid_count)]
        alpha_list = alpha_list_big = [
            int(v) for v in np.logspace(2, np.log10(4000), 2)
        ]
        dataframe = heritability_spatial_correction(snpreader,
                                                    spatial_coor,
                                                    snpreader.iid,
                                                    alpha_list,
                                                    2,
                                                    self.pheno_whole,
                                                    jackknife_count=2,
                                                    permute_plus_count=1,
                                                    permute_times_count=1,
                                                    just_testing=False)

        dataframe.to_csv(tmpOutfile, sep="\t", index=False)
        referenceOutfile = TestFeatureSelection.reference_file(
            "heritability_spatial_correction/" + fn)
        out, msg = ut.compare_files(tmpOutfile, referenceOutfile, tolerance)
        self.assertTrue(
            out,
            "msg='{0}', ref='{1}', tmp='{2}'".format(msg, referenceOutfile,
                                                     tmpOutfile))
Ejemplo n.º 2
0
    def blocking_cov_pcs(self,strategy):
        currentFolder = os.path.dirname(os.path.realpath(__file__))
        cov_fn = currentFolder + "/examples/toydata.cov"
        output_dir="tmp"
        try:
            os.mkdir(output_dir)
        except:
            pass
        output_dir = output_dir + "/feature_selection"
        try:
            os.mkdir(output_dir)
        except:
            pass
        self.blocking(self.snpreader_bed, cov_fn, num_pcs=3, strategy=strategy, output_prefix=os.path.join(output_dir,strategy))

        for outfile in os.listdir(output_dir):
            referenceOutfile = TestFeatureSelection.reference_file(outfile)

            import fastlmm.util.util as ut
            if outfile.lower().endswith(".pdf") or outfile == "output_prefix_report.txt" or outfile.lower().endswith("_k_pcs.txt"):
                self.assertTrue(os.path.exists(referenceOutfile))
            else:
                delimiter = "," if outfile.lower().endswith(".csv") else "\t"
                tmpOutfile=os.path.join(output_dir,outfile)
                out,msg=ut.compare_files(tmpOutfile, referenceOutfile, self.tolerance,delimiter=delimiter)
                #if not out:
                    #import pdb; pdb.set_trace() #This will mess up LocalMultiProc runs
                self.assertTrue(out, "msg='{0}', ref='{1}', tmp='{2}'".format(msg, referenceOutfile, tmpOutfile))
Ejemplo n.º 3
0
    def runTest(self):
        os.chdir( os.path.dirname( os.path.realpath(__file__) ) )
        tmpOutfile = self._tmpOutfile()
        referenceOutfile = self._referenceOutfile()
        with open('inputs/'+self._infile) as f:
            filecontent = f.read()

        runner = Local()
        exec(filecontent)        
        runner.run(distributable)                               
                
        out,msg=ut.compare_files(tmpOutfile, referenceOutfile, tolerance)                
        self.assertTrue(out, "msg='{0}', ref='{1}', tmp='{2}'".format(msg, referenceOutfile, tmpOutfile))
Ejemplo n.º 4
0
    def runTest(self):
        os.chdir( os.path.dirname( os.path.realpath(__file__) ) )
        tmpOutfile = self._tmpOutfile()
        referenceOutfile = self._referenceOutfile()
        with open('inputs/'+self._infile) as f:
            filecontent = f.read()

        runner = Local()
        exec(filecontent)        
        runner.run(distributable)                               
                
        out,msg=ut.compare_files(tmpOutfile, referenceOutfile, tolerance)                
        self.assertTrue(out, "msg='{0}', ref='{1}', tmp='{2}'".format(msg, referenceOutfile, tmpOutfile))
Ejemplo n.º 5
0
    def runTest(self):
        os.chdir( os.path.dirname( os.path.realpath(__file__) ) )
        tmpOutfile = self._tmpOutfile()
        referenceOutfile = self._referenceOutfile()
        with open('inputs/'+self._infile) as f:
            filecontent = f.read()

        runner = Local()
        exec(filecontent)        
        runner.run(distributable)                               
                
        out,msg=ut.compare_files(tmpOutfile, referenceOutfile, tolerance)                
        self.assertTrue(out,msg)#msg='Files %s and %s are different.' % (tmpOutfile, referenceOutfile))
Ejemplo n.º 6
0
    def test_one(self):
        logging.info("TestSnpSet test_one")

        fn = "lrt_one_kernel_fixed_mixed_effect_linear_qqfit.N300.txt"
        tmpOutfile = self.file_name(fn)
        referenceOutfile = self._referenceOutfile(fn)

        result_dataframe = snp_set(
            test_snps = self.currentFolder+'/../../../tests/datasets/all_chr.maf0.001.N300',
            set_list = self.currentFolder+'/../../../tests/datasets/set_input.23.txt',
            pheno = self.currentFolder+'/../../../tests/datasets/phenSynthFrom22.23.N300.txt',
            output_file_name = tmpOutfile
            )


        out,msg=ut.compare_files(tmpOutfile, referenceOutfile, tolerance)                
        self.assertTrue(out, "msg='{0}', ref='{1}', tmp='{2}'".format(msg, referenceOutfile, tmpOutfile))
Ejemplo n.º 7
0
    def test_one(self):
        logging.info("TestSnpSet test_one")

        fn = "lrt_one_kernel_fixed_mixed_effect_linear_qqfit.N300.txt"
        tmpOutfile = self.file_name(fn)
        referenceOutfile = self._referenceOutfile(fn)

        result_dataframe = snp_set(
            test_snps = self.currentFolder+'/../../../tests/datasets/all_chr.maf0.001.N300',
            set_list = self.currentFolder+'/../../../tests/datasets/set_input.23.txt',
            pheno = self.currentFolder+'/../../../tests/datasets/phenSynthFrom22.23.N300.txt',
            output_file_name = tmpOutfile
            )


        out,msg=ut.compare_files(tmpOutfile, referenceOutfile, tolerance)                
        self.assertTrue(out, "msg='{0}', ref='{1}', tmp='{2}'".format(msg, referenceOutfile, tmpOutfile))
    def test_two(self):
        '''
        Lock in results on arbitrary data -- because meaningful runs take too long to run.
        '''
        fn = "two.txt"
        logging.info(fn)
        tmpOutfile = self.file_name(fn)

        snpreader = self.snpreader_whole[:10,:]

        spatial_coor = [[i,-i] for i in xrange(snpreader.iid_count)]
        alpha_list = alpha_list_big=[int(v) for v in np.logspace(2,np.log10(4000), 2)]
        dataframe = heritability_spatial_correction(snpreader,spatial_coor,snpreader.iid,alpha_list,self.pheno_whole,jackknife_count=2,permute_plus_count=1,permute_times_count=1,just_testing=False)

        dataframe.to_csv(tmpOutfile,sep="\t",index=False)
        referenceOutfile = TestFeatureSelection.reference_file("heritability_spatial_correction/"+fn)
        out,msg=ut.compare_files(tmpOutfile, referenceOutfile, tolerance)                
        self.assertTrue(out, "msg='{0}', ref='{1}', tmp='{2}'".format(msg, referenceOutfile, tmpOutfile))
Ejemplo n.º 9
0
    def test_three(self):
        logging.info("TestSnpSet test_three")

        fn = "sc_davies_one_kernel_linear_qqfit.N300.txt"
        tmpOutfile = self.file_name(fn)
        referenceOutfile = self._referenceOutfile(fn)

        result_dataframe = snp_set(
            test_snps = self.currentFolder+'/../../../tests/datasets/all_chr.maf0.001.N300',
            set_list = self.currentFolder+'/../../../tests/datasets/set_input.small.txt',
            pheno = self.currentFolder+'/../../../tests/datasets/phenSynthFrom22.23.N300.txt',
            test = "sc_davies",
            output_file_name = tmpOutfile
            )


        out,msg=ut.compare_files(tmpOutfile, referenceOutfile, tolerance)                
        self.assertTrue(out,msg)#msg='Files %s and %s are different.' % (tmpOutfile, referenceOutfile))
Ejemplo n.º 10
0
    def test_four(self):
        logging.info("TestSnpSet test_four")

        fn = "sc_davies_two_kernel_linear_qqfit.N300.noautoselect.txt"
        tmpOutfile = self.file_name(fn)
        referenceOutfile = self._referenceOutfile(fn)

        result_dataframe = snp_set(
            test_snps = self.currentFolder+'/../../../tests/datasets/all_chr.maf0.001.N300',
            set_list = self.currentFolder+'/../../../tests/datasets/set_input.small.txt',
            pheno = self.currentFolder+'/../../../tests/datasets/phenSynthFrom22.23.N300.randcidorder.txt',
            G0 = self.currentFolder+'/../../../tests/datasets/all_chr.maf0.001.chr22.23.N300.bed',
            test = 'sc_davies',
            output_file_name = tmpOutfile
            )


        out,msg=ut.compare_files(tmpOutfile, referenceOutfile, tolerance)                
        self.assertTrue(out, "msg='{0}', ref='{1}', tmp='{2}'".format(msg, referenceOutfile, tmpOutfile))
Ejemplo n.º 11
0
    def test_two(self):
        logging.info("TestSnpSet test_two")

        fn = "lrt_up_two_kernel_mixed_effect_linear_qqfit.N300.fullrank.txt"
        tmpOutfile = self.file_name(fn)
        referenceOutfile = self._referenceOutfile(fn)

        result_dataframe = snp_set(
            test_snps = self.currentFolder+'/../../../tests/datasets/all_chr.maf0.001.N300',
            set_list = self.currentFolder+'/../../../tests/datasets/set_input.23.txt',
            pheno = self.currentFolder+'/../../../tests/datasets/phenSynthFrom22.23.N300.txt',
            G0 = self.currentFolder+'/../../../tests/datasets/all_chr.maf0.001.chr22.23.N300.bed',
            output_file_name = tmpOutfile,
            test="lrt"
            )


        out,msg=ut.compare_files(tmpOutfile, referenceOutfile, tolerance)                
        self.assertTrue(out,msg)#msg='Files %s and %s are different.' % (tmpOutfile, referenceOutfile))
Ejemplo n.º 12
0
    def test_four(self):
        logging.info("TestSnpSet test_four")

        fn = "sc_davies_two_kernel_linear_qqfit.N300.noautoselect.txt"
        tmpOutfile = self.file_name(fn)
        referenceOutfile = self._referenceOutfile(fn)

        result_dataframe = snp_set(
            test_snps = self.currentFolder+'/../../../tests/datasets/all_chr.maf0.001.N300',
            set_list = self.currentFolder+'/../../../tests/datasets/set_input.small.txt',
            pheno = self.currentFolder+'/../../../tests/datasets/phenSynthFrom22.23.N300.randcidorder.txt',
            G0 = self.currentFolder+'/../../../tests/datasets/all_chr.maf0.001.chr22.23.N300.bed',
            test = 'sc_davies',
            output_file_name = tmpOutfile
            )


        out,msg=ut.compare_files(tmpOutfile, referenceOutfile, tolerance)                
        self.assertTrue(out, "msg='{0}', ref='{1}', tmp='{2}'".format(msg, referenceOutfile, tmpOutfile))
Ejemplo n.º 13
0
    def test_two(self):
        logging.info("TestSnpSet test_two")

        fn = "lrt_up_two_kernel_mixed_effect_linear_qqfit.N300.fullrank.txt"
        tmpOutfile = self.file_name(fn)
        referenceOutfile = self._referenceOutfile(fn)

        result_dataframe = snp_set(
            test_snps = self.currentFolder+'/../../../tests/datasets/all_chr.maf0.001.N300',
            set_list = self.currentFolder+'/../../../tests/datasets/set_input.23.txt',
            pheno = self.currentFolder+'/../../../tests/datasets/phenSynthFrom22.23.N300.txt',
            G0 = self.currentFolder+'/../../../tests/datasets/all_chr.maf0.001.chr22.23.N300.bed',
            output_file_name = tmpOutfile,
            test="lrt"
            )


        out,msg=ut.compare_files(tmpOutfile, referenceOutfile, tolerance)                
        self.assertTrue(out,msg)#msg='Files %s and %s are different.' % (tmpOutfile, referenceOutfile))
Ejemplo n.º 14
0
    def runTest(self):
        os.chdir(os.path.dirname(os.path.realpath(__file__)))
        tmpOutfile = self._tmpOutfile()
        referenceOutfile = self._referenceOutfile()
        with open('inputs/' + self._infile) as f:
            filecontent = f.read()

        runner = Local()
        try:
            distributable = eval(filecontent)
        except Exception as e:
            raise Exception("Can't eval '{0}' because of '{1}'".format(
                self._infile, e.message))
        runner.run(distributable)

        out, msg = ut.compare_files(tmpOutfile, referenceOutfile, tolerance)
        self.assertTrue(
            out,
            "msg='{0}', ref='{1}', tmp='{2}'".format(msg, referenceOutfile,
                                                     tmpOutfile))