本文整理汇总了Python中CGAT.Stats.doLogLikelihoodTest方法的典型用法代码示例。如果您正苦于以下问题:Python Stats.doLogLikelihoodTest方法的具体用法?Python Stats.doLogLikelihoodTest怎么用?Python Stats.doLogLikelihoodTest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CGAT.Stats
的用法示例。
在下文中一共展示了Stats.doLogLikelihoodTest方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testLRT
# 需要导入模块: from CGAT import Stats [as 别名]
# 或者: from CGAT.Stats import doLogLikelihoodTest [as 别名]
def testLRT(self):
"""test that the false positive rate is in the same order as mSignificance.
Sample from a normal distribution and compare two models:
1. mean estimated = complex model (1 df)
2. mean given = simple model (0 df)
Likelihood = P(model | data)
"""
simple_np = 0
complex_np = 1
npassed = 0
for replicate in range(0, self.mNumReplicates):
sample = scipy.stats.norm.rvs(
size=self.mNumSamples, loc=0.0, scale=1.0)
mean = scipy.mean(sample)
complex_ll = numpy.sum(
numpy.log(scipy.stats.norm.pdf(sample, loc=mean, scale=1.0)))
simple_ll = numpy.sum(
numpy.log(scipy.stats.norm.pdf(sample, loc=0.0, scale=1.0)))
a = Stats.doLogLikelihoodTest(complex_ll, complex_np,
simple_ll, simple_np,
significance_threshold=self.mSignificance)
if a.mPassed:
npassed += 1
r = float(npassed) / self.mNumReplicates
self.assertAlmostEqual(self.mSignificance, r, places=self.nplaces)
示例2: increased
# 需要导入模块: from CGAT import Stats [as 别名]
# 或者: from CGAT.Stats import doLogLikelihoodTest [as 别名]
if options.mode == "pairs":
reference_result = last_result
reference_id = x - 1
elif options.mode == "1xn":
reference_result = first_result
reference_id = 0
if reference_result.mNumParameters >= result.mNumParameters:
if options.loglevel >= 1:
options.stdlog.write("number of parameters of full model not increased (null=%i, full=%i).\n" % (
reference_result.mNumParameters, result.mNumParameters))
continue
lrt = Stats.doLogLikelihoodTest(
result.mLogLikelihood, result.mNumParameters,
reference_result.mLogLikelihood, reference_result.mNumParameters,
options.significance_threshold)
if lrt.mPassed:
c = "passed"
else:
c = "failed"
options.stdout.write("%s%i\t%i\t%s\t%f\t%i\t%f\t%i\t%5.2e\n" % (prefix_row, reference_id, x, c,
lrt.mFullLogLikelihood, lrt.mFullNumParameters,
lrt.mNullLogLikelihood, lrt.mNullNumParameters,
lrt.mProbability,
))
last_result = result
x += 1
示例3: main
# 需要导入模块: from CGAT import Stats [as 别名]
# 或者: from CGAT.Stats import doLogLikelihoodTest [as 别名]
#.........这里部分代码省略.........
h.append("df%s" % (model))
h.append("chi%s" % (model))
h.append("lrt%s" % (model))
options.stdout.write("\t".join(h))
options.stdout.write("\tcons\tpassed\tfilename\n")
nmethod = 0
consistent_cols = [None for x in range(len(options.analysis))]
passed_tests = {}
for m in options.models:
passed_tests[m] = 0
for result in results:
row_consistent = None
if options.prefix:
options.stdout.write("%s" % (options.prefix))
options.stdout.write("%i" % nmethod)
options.stdout.write("\t%i" % (result.mNumSequences))
npassed = 0
for model in options.models:
sites = result.mSites[model]
# do significance test
full_model, null_model = model, map_nested_models[model]
lrt = Stats.doLogLikelihoodTest(
result.mSites[full_model].mLogLikelihood,
result.mSites[full_model].mNumParameters,
result.mSites[null_model].mLogLikelihood,
result.mSites[null_model].mNumParameters,
options.significance_threshold)
x = 0
for analysis in options.analysis:
if analysis == "neb":
s = set(
map(extract_f, filter(filter_f, sites.mNEB.mPositiveSites)))
elif analysis == "beb":
s = set(
map(extract_f, filter(filter_f, sites.mBEB.mPositiveSites)))
options.stdout.write("\t%i" % (len(s)))
if not lrt.mPassed:
s = set()
if row_consistent is None:
row_consistent = s
else:
row_consistent = row_consistent.intersection(s)
if consistent_cols[x] is None:
consistent_cols[x] = s
else:
consistent_cols[x] = consistent_cols[
x].intersection(s)
示例4: set
# 需要导入模块: from CGAT import Stats [as 别名]
# 或者: from CGAT.Stats import doLogLikelihoodTest [as 别名]
options.stdout.write("%i" % nmethod)
options.stdout.write("\t%i" % (result.mNumSequences ))
npassed = 0
for model in options.models:
sites = result.mSites[model]
## do significance test
full_model, null_model = model, map_nested_models[model]
lrt = Stats.doLogLikelihoodTest(
result.mSites[full_model].mLogLikelihood,
result.mSites[full_model].mNumParameters,
result.mSites[null_model].mLogLikelihood,
result.mSites[null_model].mNumParameters,
options.significance_threshold )
x = 0
for analysis in options.analysis:
if analysis == "neb":
s = set(map( extract_f, filter( filter_f, sites.mNEB.mPositiveSites)))
elif analysis == "beb":
s = set(map( extract_f, filter( filter_f, sites.mBEB.mPositiveSites)))
options.stdout.write("\t%i" % ( len(s) ) )
if not lrt.mPassed:
示例5: float
# 需要导入模块: from CGAT import Stats [as 别名]
# 或者: from CGAT.Stats import doLogLikelihoodTest [as 别名]
lnl_simple = float(row['%s:lnL' % b])
df_complex = map_model2params[a]
df_simple = map_model2params[b]
if options.loglevel >= 3:
options.stdlog.write("# testing %s: ll=%f,df=%i versus %s:lnl=%f,df=%i\n" %\
(a,
lnl_complex,df_complex,
b, lnl_simple,
df_simple))
if lnl_complex < lnl_simple:
nerrors += 1
options.stdout.write( "\tna\tna" )
continue
lrt = Stats.doLogLikelihoodTest( lnl_complex, df_complex, lnl_simple, df_simple )
if lrt.mPassed: stats[(a,b)] += 1
options.stdout.write( "\t%s\t%5.2e" % (
Stats.getSignificance( lrt.mProbability),
lrt.mProbability ) )
options.stdout.write( "\n" )
noutput += 1
options.stdout.write( "npassed" )
for a, b in tests:
options.stdout.write( "\t%i\t%5.2f" % (stats[(a, b)], 100.0 * stats[(a,b)] / noutput ) )
options.stdout.write( "\n" )