Esempio n. 1
0
def lendist_ttests(attr, outfile, g2n, name2obj, matched, pcutoff):
    testtype = statcommon.get_test_type(g2n, matched)
    f = open(outfile, 'w')
    # compare median length
    f.write(("#Category\tGroup1_Group2\tt_val\tp_val\tMean1 +/- Std1\t" +
             "Mean2 +/- Std2\n"))
    medattr = "median_" + attr 
    pair2tp, group2mean = statcommon.ttest_allpairs(g2n, name2obj, matched,
                                                    medattr, testtype=testtype)
    statcommon.ttest_write(f, medattr, pair2tp, group2mean)

    # compare freq of each length
    f.write("#Length\n")
    lens = get_lens(name2obj.values())
    lenattr = "len2" + attr
    for l in lens:
        pair2tp, group2mean = statcommon.ttest_allpairs(g2n, name2obj,
                                  matched, attr=None,
                                  func=statcommon.obj_dictattr_lookup,
                                  func_args=(lenattr, l), testtype=testtype)
        statcommon.ttest_write(f, str(l), pair2tp, group2mean, pcutoff)
    f.close()
Esempio n. 2
0
def geneusage_ttests(attr, type, outfile, g2n, name2obj, matched, pcutoff):
    # attr: "clones"/"reads"; type=genetype: v, d, j, vj, dj
    testtype = statcommon.get_test_type(g2n, matched)
    f = open(outfile, 'w')
    f.write(("Name\tGroup1_Group2\tt_val\tp_val\tMean1 +/- Std1\t" +
             "Mean2 +/- Std2\n"))
    genes = get_genes(name2obj.values(), type)
    for gene in genes:
        pair2tp, group2mean = statcommon.ttest_allpairs(g2n, name2obj, matched,
                                                 attr=None, func=get_geneusage,
                                                 func_args=(attr, type, gene),
                                                 testtype=testtype)
        statcommon.ttest_write(f, gene, pair2tp, group2mean, pcutoff)
    f.close()
Esempio n. 3
0
 def run(self):
     testtype = statcommon.get_test_type(self.g2n, self.matched)
     p2stat, g2mean = statcommon.ttest_allpairs(self.g2n, self.name2stat,
                                                self.matched, self.index,
                                                testtype=testtype)
     picklefile = os.path.join(self.outdir, "%s.pickle" % self.index)
     pickle.dump((p2stat, g2mean), gzip.open(picklefile, 'wb'))
     if self.plotfmt:
         plotfile = os.path.join(self.plotdir, self.index)
         if not self.matched:
             dvplot.draw_diversity_plot(self.g2n, self.name2stat,
                                        self.index, plotfile, self.plotfmt)
         else:
             dvplot.draw_diversity_plot_hacktimeseries(self.g2n,
                        self.name2stat, self.index, plotfile, self.plotfmt)