def test_my_wil_rank_sum_gtr(): """nosetest for utils.my_wil_rank_sum_gtr""" # test gtr dist vals = [] for x in xrange(1000): vals.append(random.randint(0, 10000)) vals.sort() low_vals = vals[0:300] high_vals = vals[800:] pval = utils.my_wil_rank_sum_gtr(high_vals, low_vals, vals) nose.tools.assert_true(pval < float(.01)) # test eq dist low_vals = [] for x in xrange(300): low_vals.append( vals[random.randint(0,999)] ) high_vals = [] for x in xrange(300): high_vals.append( vals[random.randint(0,999)] ) pval = utils.my_wil_rank_sum_gtr(high_vals, low_vals, vals) nose.tools.assert_true(pval > float(.05), 'pval was significant, but should not be ' + str(pval))
human_all_vals) = plot_fore_control(outfile, protein, human_fore, human_control, human_all, human_host_freqs, chicken_host_freqs) outfile = os.path.join(dir, 'chicken_' + protein + '.png') (chicken_fore_vals, chicken_control_vals, chicken_all_vals) = plot_fore_control(outfile, protein, chicken_fore, chicken_control, chicken_all, chicken_host_freqs, human_host_freqs) human_control_pval = utils.my_wil_rank_sum_gtr(human_fore_vals, human_control_vals, human_all_vals) chicken_control_pval = utils.my_wil_rank_sum_gtr(chicken_fore_vals, chicken_control_vals, chicken_all_vals) if protein in ('polymerase PB1', 'neuraminidase', 'polymerase PB2', 'nonstructural protein 2', 'polymerase PA', 'matrix protein 2'): human_pval = 'fore gtr ' + str(len(human_fore_vals)) + ' ' + str(len(human_control_vals) )+ ' ' + str(utils_stats.wilcox_gtr(human_fore_vals, human_control_vals)) p = utils_stats.wilcox_gtr(chicken_fore_vals, chicken_control_vals) print 'pval', p, 'yo' chicken_pval = 'fore gtr ' + str(len(chicken_fore_vals)) + ' ' + str(len(chicken_control_vals)) + ' ' + str(p) else: human_pval = 'ctrl gtr ' + str(len(human_control_vals)) + ' ' + str(len(human_fore_vals)) + ' ' + str(utils_stats.wilcox_gtr(human_control_vals, human_fore_vals)) chicken_pval = 'ctrl gtr ' + str(len(chicken_control_vals)) + ' ' + str(len(chicken_fore_vals)) + ' ' + str(utils_stats.wilcox_gtr(chicken_control_vals, chicken_fore_vals)) print 'human pval', protein, human_pval