예제 #1
0
    def test_two(self):  #!!! rather a big test case
        from pysnptools.util.mapreduce1.runner import Local, LocalMultiProc
        logging.info("TestSingleSnpAllPlusSelect test_two")
        do_plot = False

        bed_fn = self.pythonpath + "/tests/datasets/synth/all.bed"
        pheno_fn = self.pythonpath + "/tests/datasets/synth/pheno_10_causals.txt"
        cov_fn = self.pythonpath + "/tests/datasets/synth/cov.txt"

        # partition snps on chr5 vs rest
        test_chr = 5
        snp_reader = Bed(bed_fn, count_A1=False)
        test_snps = snp_reader[:, snp_reader.pos[:, 0] == test_chr]

        mf_name = "lmpl"  #"lmpl" "local", "coreP", "nodeP", "socketP", "nodeE", "lmp"
        runner = mf_to_runner_function(mf_name)(20)

        output_file_name = self.file_name("two")
        for GB_goal in [None, 2]:
            results = single_snp_all_plus_select(
                test_snps=test_snps,
                G=bed_fn,
                pheno=pheno_fn,
                covar=cov_fn,
                k_list=[int(k) for k in np.logspace(0, 7, base=2, num=7)],
                n_folds=7,
                seed=42,
                do_plot=do_plot,
                GB_goal=GB_goal,
                output_file_name=output_file_name,
                runner=runner,
                count_A1=False)
            logging.info(results.head())
            self.compare_files(results, "two")
예제 #2
0
    def test_notebook(self):
        do_plot = False
        mf_name = "lmp"  #"local", "coreP", "nodeP", "socketP", "nodeE", "lmp"
        runner = mf_to_runner_function(mf_name)(4)
        output_file_name = self.file_name("notebook")

        logging.info("TestSingleSnpAllPlusSelect test_one")
        # define file names
        snp_reader = Bed(self.pythonpath + "/tests/datasets/synth/all",
                         count_A1=False)
        pheno_fn = self.pythonpath + "/tests/datasets/synth/pheno_10_causals.txt"
        cov_fn = self.pythonpath + "/tests/datasets/synth/cov.txt"

        # find the chr5 SNPs
        test_snps = snp_reader[:, snp_reader.pos[:, 0] == 5]

        #select the 2nd kernel and run GWAS
        results = single_snp_all_plus_select(test_snps=test_snps,
                                             G=snp_reader,
                                             pheno=pheno_fn,
                                             GB_goal=2,
                                             do_plot=do_plot,
                                             output_file_name=output_file_name,
                                             runner=runner,
                                             count_A1=False)

        self.compare_files(results, "notebook")
예제 #3
0
    def test_three(self):  #!!! rather a big test case
        from pysnptools.util.mapreduce1.runner import Local, LocalMultiProc
        logging.info("TestSingleSnpAllPlusSelect test_three")

        bed_fn = self.pythonpath + "/tests/datasets/synth/all.bed"
        bed_fn = Bed(bed_fn, count_A1=False)
        pheno_fn = self.pythonpath + "/tests/datasets/synth/pheno_10_causals.txt"
        cov_fn = self.pythonpath + "/tests/datasets/synth/cov.txt"

        mf_name = "lmp"  #"local", "coreP", "nodeP", "socketP", "nodeE", "lmp"
        runner = mf_to_runner_function(mf_name)(4)

        output_file_name = self.file_name("three")
        results = single_snp_all_plus_select(
            test_snps=bed_fn,
            pheno=pheno_fn,
            covar=cov_fn,
            k_list=[int(k) for k in np.logspace(0, 7, base=2, num=7)],
            n_folds=7,
            seed=42,
            do_plot=False,
            GB_goal=2,
            output_file_name=output_file_name,
            runner=runner,
            count_A1=False)
        logging.info(results)
        self.compare_files(results, "three")
    def test_three(self): #!!! rather a big test case
        from fastlmm.util.runner import Local, HPC, LocalMultiProc
        logging.info("TestSingleSnpAllPlusSelect test_three")

        bed_fn = self.pythonpath + "/tests/datasets/synth/all.bed"
        bed_fn = Bed(bed_fn)
        pheno_fn = self.pythonpath + "/tests/datasets/synth/pheno_10_causals.txt"
        cov_fn = self.pythonpath + "/tests/datasets/synth/cov.txt"

        mf_name = "lmp" #"local", "coreP", "nodeP", "socketP", "nodeE", "lmp"
        runner = mf_to_runner_function(mf_name)(4)


        output_file_name = self.file_name("three")
        results = single_snp_all_plus_select(test_snps=bed_fn, pheno=pheno_fn,
                                  covar=cov_fn,
                                  k_list = [int(k) for k in np.logspace(0, 7, base=2, num=7)],
                                  n_folds=7,
                                  seed = 42,
                                  do_plot=False,
                                  GB_goal=2,
                                  output_file_name=output_file_name,
                                  runner = runner
                                  )
        logging.info(results)
        self.compare_files(results,"three")
    def test_two(self): #!!! rather a big test case
        from fastlmm.util.runner import Local, HPC, LocalMultiProc
        logging.info("TestSingleSnpAllPlusSelect test_two")
        do_plot = False

        bed_fn = self.pythonpath + "/tests/datasets/synth/all.bed"
        pheno_fn = self.pythonpath + "/tests/datasets/synth/pheno_10_causals.txt"
        cov_fn = self.pythonpath + "/tests/datasets/synth/cov.txt"

        # partition snps on chr5 vs rest
        test_chr = 5
        snp_reader = Bed(bed_fn)
        test_snps = snp_reader[:,snp_reader.pos[:,0] == test_chr]

        mf_name = "lmpl" #"lmpl" "local", "coreP", "nodeP", "socketP", "nodeE", "lmp"
        runner = mf_to_runner_function(mf_name)(20)

        output_file_name = self.file_name("two")
        for GB_goal in [None,2]:
            results = single_snp_all_plus_select(test_snps=test_snps, G=bed_fn, pheno=pheno_fn,
                                      covar=cov_fn,
                                      k_list = [int(k) for k in np.logspace(0, 7, base=2, num=7)],
                                      n_folds=7,
                                      seed = 42,
                                      do_plot=do_plot,
                                      GB_goal=GB_goal,
                                      output_file_name=output_file_name,
                                      runner = runner
                                      )
            logging.info(results.head())
            self.compare_files(results,"two")
    def too_slow_test_notebook(self):
        do_plot = False
        runner = LocalMultiProc(multiprocessing.cpu_count(), mkl_num_threads=2)
        output_file_name = self.file_name("notebook")

        logging.info("TestSingleSnpAllPlusSelect test_notebook")
        # define file names
        snp_reader = Bed(self.pythonpath + "/tests/datasets/synth/all.bed",
                         count_A1=False)
        pheno_fn = self.pythonpath + "/tests/datasets/synth/pheno_10_causals.txt"
        cov_fn = self.pythonpath + "/tests/datasets/synth/cov.txt"

        # find the chr5 SNPs
        test_snps = snp_reader[:, snp_reader.pos[:, 0] == 5]

        #select the 2nd kernel and run GWAS
        results = single_snp_all_plus_select(test_snps=test_snps,
                                             G=snp_reader,
                                             pheno=pheno_fn,
                                             GB_goal=2,
                                             do_plot=do_plot,
                                             output_file_name=output_file_name,
                                             runner=runner,
                                             count_A1=False)

        self.compare_files(results, "notebook")
    def test_one(self):
        from fastlmm.util.runner import Local, HPC, LocalMultiProc

        logging.info("TestSingleSnpAllPlusSelect test_one")
        snps = self.bedbase
        pheno = self.phen_fn
        covar = self.cov_fn
        
        output_file_name = self.file_name("one")
        results = single_snp_all_plus_select(test_snps=snps, pheno=pheno,
                                  covar=covar,
                                  k_list = np.logspace(start=0, stop=1, num=2, base=2),
                                  n_folds=2,
                                  do_plot=False,
                                  output_file_name = output_file_name,
                                  GB_goal=2,
                                  #runner = LocalMultiProc(taskcount=20,mkl_num_threads=5,just_one_process=True)
                                  )

        self.compare_files(results,"one")
    def test_one(self):
        logging.info("TestSingleSnpAllPlusSelect test_one")
        snps = self.bedbase
        pheno = self.phen_fn
        covar = self.cov_fn

        output_file_name = self.file_name("one")
        results = single_snp_all_plus_select(
            test_snps=snps,
            pheno=pheno,
            covar=covar,
            k_list=np.logspace(start=0, stop=1, num=2, base=2),
            n_folds=2,
            do_plot=False,
            output_file_name=output_file_name,
            GB_goal=2,
            #runner = LocalMultiProc(taskcount=20,mkl_num_threads=5,just_one_process=True)
            count_A1=False)

        self.compare_files(results, "one")
    def test_notebook(self):
        do_plot = False
        mf_name = "lmp" #"local", "coreP", "nodeP", "socketP", "nodeE", "lmp"
        runner = mf_to_runner_function(mf_name)(4)
        output_file_name = self.file_name("notebook")


        logging.info("TestSingleSnpAllPlusSelect test_one")
        # define file names
        snp_reader = Bed(self.pythonpath + "/tests/datasets/synth/all")
        pheno_fn = self.pythonpath + "/tests/datasets/synth/pheno_10_causals.txt"
        cov_fn = self.pythonpath + "/tests/datasets/synth/cov.txt"

        # find the chr5 SNPs
        test_snps = snp_reader[:,snp_reader.pos[:,0] == 5]

        #select the 2nd kernel and run GWAS
        results = single_snp_all_plus_select(test_snps=test_snps,G=snp_reader,pheno=pheno_fn,GB_goal=2,do_plot=do_plot,output_file_name=output_file_name,runner=runner)


        self.compare_files(results,"notebook")
    def too_slow_test_three(self):
        logging.info("TestSingleSnpAllPlusSelect test_three")

        bed_fn = self.pythonpath + "/tests/datasets/synth/all.bed"
        bed_fn = Bed(bed_fn, count_A1=False)
        pheno_fn = self.pythonpath + "/tests/datasets/synth/pheno_10_causals.txt"
        cov_fn = self.pythonpath + "/tests/datasets/synth/cov.txt"
        runner = LocalMultiProc(multiprocessing.cpu_count(), mkl_num_threads=2)

        output_file_name = self.file_name("three")
        results = single_snp_all_plus_select(
            test_snps=bed_fn,
            pheno=pheno_fn,
            covar=cov_fn,
            k_list=[int(k) for k in np.logspace(0, 7, base=2, num=7)],
            n_folds=7,
            seed=42,
            do_plot=False,
            GB_goal=2,
            output_file_name=output_file_name,
            runner=runner,
            count_A1=False)
        logging.info(results)
        self.compare_files(results, "three")