Exemple #1
0
 def testTaxTTests(self):
     tax = testfile('multiple_tax.tab')
     int = testfile('int_ttest.tab')
     expanded = testfile('expand_taxttest.tab')
     tax_df = expand.expand('t',
                            sinfo=TTEST_SINFO,
                            int_file=int,
                            pep_colname_int='peptide',
                            pep_colname_func='peptide',
                            pep_colname_tax='peptide',
                            data_dir=TEST_DIR,
                            outfile=expanded,
                            tax_file=tax,
                            tax_colname='lca')
     tax_tst = stat.stat(expanded,
                         sinfo=TTEST_SINFO,
                         paired=False,
                         parametric=False,
                         ontology=None,
                         mode=None,
                         outfile=None)
     # make sure false is > 0.05 and trues are less than 0.05
     self.assertTrue(tax_tst['p'][210] > 0.05)
     self.assertTrue(tax_tst['p'][[1496, 1870884]].le(0.05).all())
     # also, make sure firmicutes phylum is sum of c difficile and clostridiaceae
     self.assertEqual(tax_tst['int1'][1239], np.log2(1020))
Exemple #2
0
 def testDA(self):
     func = testfile('multiple_func.tab')
     int = testfile('int_ttest.tab')
     expanded = testfile('go_expanded_ttest.tab')
     test_write = testfile('go_tested.tab')
     df_expd = expand.expand('f',
                             sinfo=TTEST_SINFO,
                             int_file=int,
                             pep_colname_int='peptide',
                             pep_colname_func='peptide',
                             pep_colname_tax='peptide',
                             data_dir=TEST_DIR,
                             outfile=expanded,
                             func_file=func,
                             func_colname='go',
                             ontology='go')
     df_tst = stat.stat(expanded,
                        sinfo=TTEST_SINFO,
                        paired=False,
                        parametric=True,
                        ontology='go',
                        mode='f',
                        outfile=test_write)
     # make sure false is > 0.05 and trues are less than 0.05
     self.assertTrue(df_tst['p']['GO:0008152'] > 0.05)
     self.assertTrue(df_tst['p'][['GO:0022610', 'GO:0000003',
                                  'GO:0032505']].le(0.05).all())
Exemple #3
0
 def testDiffAbundEc(self):
     func = testfile('multiple_func.tab')
     int = testfile('int_ttest.tab')
     expandfile = testfile('ec_ttest.tab')
     tested_file = testfile('ec_ttest_tested.tab')
     expand.expand('f',
                   sinfo=TTEST_SINFO,
                   int_file=int,
                   pep_colname_int='peptide',
                   pep_colname_func='peptide',
                   pep_colname_tax='peptide',
                   data_dir=TEST_DIR,
                   outfile=expandfile,
                   func_file=func,
                   func_colname='ec',
                   ontology='ec')
     ec_tst = stat.stat(expandfile,
                        sinfo=TTEST_SINFO,
                        paired=False,
                        parametric=True,
                        ontology='ec',
                        mode='f',
                        outfile=tested_file)
     # make sure false is > 0.05 and trues are less than 0.05
     self.assertTrue(ec_tst['p']['3.4.11.-'] > 0.05)
     self.assertTrue(ec_tst['p'][['3.4.21.70', '1.2.-.-']].le(0.05).all())
Exemple #4
0
 def testCogTTest(self):
     func = testfile('multiple_func.tab')
     int = testfile('int_ttest.tab')
     expandfile = testfile('cog_ttest.tab')
     cog_df = expand.expand('f', sinfo=TTEST_SINFO, int_file=int, pep_colname_int='peptide', pep_colname_func='peptide',
                            pep_colname_tax='peptide', outfile=expandfile, func_file=func, func_colname='cog',
                            ontology='cog')
     cog_tst = stat.stat(expandfile, sinfo=TTEST_SINFO, paired=False, parametric=True, ontology='cog', mode='f', control_group='s2',
                         outfile=None)
     # make sure false is > 0.05 and trues are less than 0.05
     cog_tst.set_index('id', inplace=True)
     self.assertTrue(cog_tst['p_s1_over_s2']['C'] > 0.05)
     self.assertTrue(cog_tst['p_s1_over_s2'][['N', 'D']].le(0.05).all())
Exemple #5
0
def cli():
    """
    Command line interface; main entry point to metaQuantome

    :return: exit code
    """
    # initialize logger
    logging.basicConfig(level=logging.INFO,
                        format='%(message)s',
                        stream=sys.stderr)
    args = parse_args_cli()
    if args.command == "db":
        db_download_handler(args.dbs, args.dir, args.update)
    elif args.command == "expand":
        expand(mode=args.mode,
               sinfo=args.samps,
               int_file=args.int_file,
               pep_colname_int=args.pep_colname_int,
               pep_colname_func=args.pep_colname_func,
               pep_colname_tax=args.pep_colname_tax,
               data_dir=args.data_dir,
               outfile=args.outfile,
               func_file=args.func_file,
               func_colname=args.func_colname,
               ontology=args.ontology,
               slim_down=args.slim_down,
               tax_file=args.tax_file,
               tax_colname=args.tax_colname,
               nopep=args.nopep,
               nopep_file=args.nopep_file,
               ft_tar_rank=args.ft_tar_rank)
    elif args.command == "filter":
        run_filter(expanded_file=args.expand_file,
                   sinfo=args.samps,
                   ontology=args.ontology,
                   mode=args.mode,
                   qthreshold=args.qthreshold,
                   min_child_non_leaf=args.min_children_non_leaf,
                   min_child_nsamp=args.min_child_nsamp,
                   min_peptides=args.min_peptides,
                   min_pep_nsamp=args.min_pep_nsamp,
                   outfile=args.outfile)
    elif args.command == "stat":
        stat(infile=args.file,
             sinfo=args.samps,
             paired=args.paired,
             parametric=args.parametric,
             ontology=args.ontology,
             mode=args.mode,
             outfile=args.outfile)
    elif args.command == "viz":
        run_viz(plottype=args.plottype,
                img=args.img,
                infile=args.infile,
                mode=args.mode,
                meancol=args.meancol,
                nterms=args.nterms,
                strip=args.strip,
                target_rank=args.target_rank,
                barcol=args.barcol,
                textannot=args.textannot,
                calculate_sep=args.calculate_sep,
                fc_name=args.fc_name,
                flip_fc=args.flip_fc,
                gosplit=args.gosplit,
                sinfo=args.samps,
                filter_to_sig=args.filter_to_sig,
                alpha=args.alpha,
                whichway=args.whichway,
                name=args.name,
                id=args.id,
                target_onto=args.target_onto,
                width=args.width,
                height=args.height,
                tabfile=args.tabfile)
    else:
        ValueError(
            'incorrect mode. please provide one of "db", "expand", "filter", "stat", or "viz".'
        )
    sys.exit(0)