Ejemplo n.º 1
0
import matplotlib
matplotlib.use('Agg')

from ecolopy_dev import Community
from ecolopy_dev.utils import draw_shannon_distrib

abd = Community('dataset_trial/bci_short.txt')
abd.fit_model('etienne')
abd.set_current_model('etienne')
pval, neut_h = abd.test_neutrality (model='etienne',
                                    gens=1000, full=True)
draw_shannon_distrib(neut_h, abd.shannon, outfile='lala.png')



abd2 = Community('test2.txt')
abd2.fit_model('lognormal')
abd2.set_current_model('lognormal')
pval, neut_h = abd2.test_neutrality (model='lognormal',
                                     gens=1000, full=True)
draw_shannon_distrib(neut_h,abd2.shannon)


bci = Community('../dataset_trial/bci_full.txt')
bci.fit_model('lognormal')
bci.set_current_model('lognormal')

pval, bci_neut_h = bci.test_neutrality (model='lognormal',
                                        gens=1000, full=True)

Ejemplo n.º 2
0
if not (1 <= tmp['fmin']['theta'] < com.S and \
        1e-50 <= tmp['fmin']['m'] < 1-1e-50):
    del (tmp['fmin'])

# find the model with the higher likelihood:
met = min(tmp, key=lambda x: tmp[x]['lnL'])

# load it as 'etienne' model
com.set_model(tmp[met]['model'])

lrt = com.lrt('ewens', 'etienne')
best = 'ewens' if lrt > 0.05 else 'etienne'
print 'Best model by LRT was: ' + best

com.generate_random_neutral_distribution(model=best)

pval, neut_h = com.test_neutrality(model=best, gens=10000, full=True)
#draw_shannon_distrib(neut_h, abd.shannon)
draw_shannon_distrib(neut_h,
                     com.shannon,
                     outfile='Fulcaldea_stuessyi_log_shannon_dist.pdf',
                     filetype='pdf')
print 'P-value for neutrality test was: ', pval

out = open('Fulcaldea_stuessyi_log_shannon_neutral_data.tsv', 'w')
out.write('# shannon:' + str(com.shannon) + '\n')
out.write('\n'.join([str(s for s in neut_h)]) + '\n')
out.close()

com.dump_community('Fulcaldea_stuessyi_log_ecolopy.pik')
Ejemplo n.º 3
0
        print '    optimization failed: ' + e.args[0]

# in case optimization by fmin failed to found correct values for theta and m:
if not (1 <= tmp['fmin']['theta'] < com.S and \
        1e-50 <= tmp['fmin']['m'] < 1-1e-50):
    del (tmp['fmin'])

# find the model with the higher likelihood:
met = min(tmp, key=lambda x: tmp[x]['lnL'])

# load it as 'etienne' model
com.set_model(tmp[met]['model'])

lrt = abd.lrt('ewens', 'etienne')
best = 'ewens' if lrt > 0.05 else 'etienne'
print 'Best model by LRT was: ' + best

com.generate_random_neutral_distribution(model=best)

pval, neut_h = com.test_neutrality (model=best, gens=10000, full=True)
#draw_shannon_distrib(neut_h, abd.shannon)
draw_shannon_distrib(neut_h, abd.shannon, outfile='Fulcaldea_stuessyi_1kfrac_shannon_dist.pdf', filetype='pdf')
print 'P-value for neutrality test was: ' + pval

out = open('Fulcaldea_stuessyi_1kfrac_shannon_neutral_data.tsv', 'w')
out.write('# shannon:' + str(shannon) + '\n')
out.write('\n'.join([str(s for s in neut_h)]) + '\n')
out.close()

com.dump_abundance('Fulcaldea_stuessyi_1kfrac_ecolopy.pik')
Ejemplo n.º 4
0
# find the model with the higher likelihood:
met = min(tmp, key=lambda x: tmp[x]['lnL'])

# load it as 'etienne' model
com.set_model(tmp[met]['model'])

lrt = com.lrt('ewens', 'etienne')
best = 'ewens' if lrt > 0.05 else 'etienne'
print 'Best model by LRT was: ' + best

com.generate_random_neutral_distribution(model=best)

pval, neut_h = com.test_neutrality(model=best,
                                   gens=10000,
                                   full=True,
                                   method='shannon',
                                   n_cpus=4)
draw_shannon_distrib(neut_h,
                     com.shannon,
                     outfile='test_log_shannon_dist.pdf',
                     filetype='pdf')
print 'P-value for neutrality test was: ', pval

out = open('test_log_shannon_neutral_data.tsv', 'w')
out.write('# shannon:' + str(com.shannon) + '\n')
out.write('\n'.join([str(s) for s in neut_h]) + '\n')
out.close()

com.dump_community('test_log_ecolopy.pik')
Ejemplo n.º 5
0
        print '    optimization failed: ' + e.args[0]

# in case optimization by fmin failed to found correct values for theta and m:
if not (1 <= tmp['fmin']['theta'] < com.S and \
        1e-50 <= tmp['fmin']['m'] < 1-1e-50):
    del (tmp['fmin'])

# find the model with the higher likelihood:
met = min(tmp, key=lambda x: tmp[x]['lnL'])

# load it as 'etienne' model
com.set_model(tmp[met]['model'])

lrt = com.lrt('ewens', 'etienne')
best = 'ewens' if lrt > 0.05 else 'etienne'
print 'Best model by LRT was: ' + best

com.generate_random_neutral_distribution(model=best)

pval, neut_h = com.test_neutrality (model=best, gens=10000, full=True)
#draw_shannon_distrib(neut_h, abd.shannon)
draw_shannon_distrib(neut_h, com.shannon, outfile='Fulcaldea_stuessyi_log_shannon_dist.pdf', filetype='pdf')
print 'P-value for neutrality test was: ', pval

out = open('Fulcaldea_stuessyi_log_shannon_neutral_data.tsv', 'w')
out.write('# shannon:' + str(com.shannon) + '\n')
out.write('\n'.join([str(s for s in neut_h)]) + '\n')
out.close()

com.dump_community('Fulcaldea_stuessyi_log_ecolopy.pik')
Ejemplo n.º 6
0
    except Exception as e:
        print '    optimization failed: ' + e.args[0]

# in case optimization by fmin failed to found correct values for theta and m:
if not (1 <= tmp['fmin']['theta'] < com.S and \
        1e-50 <= tmp['fmin']['m'] < 1-1e-50):
    del (tmp['fmin'])

# find the model with the higher likelihood:
met = min(tmp, key=lambda x: tmp[x]['lnL'])

# load it as 'etienne' model
com.set_model(tmp[met]['model'])

lrt = com.lrt('ewens', 'etienne')
best = 'ewens' if lrt > 0.05 else 'etienne'
print 'Best model by LRT was: ' + best

com.generate_random_neutral_distribution(model=best)

pval, neut_h = com.test_neutrality (model=best, gens=10000, full=True, method='shannon', n_cpus=4)
draw_shannon_distrib(neut_h, com.shannon, outfile='test_log_shannon_dist.pdf', filetype='pdf')
print 'P-value for neutrality test was: ', pval

out = open('test_log_shannon_neutral_data.tsv', 'w')
out.write('# shannon:' + str(com.shannon) + '\n')
out.write('\n'.join([str(s) for s in neut_h]) + '\n')
out.close()

com.dump_community('test_log_ecolopy.pik')
Ejemplo n.º 7
0
if not (1 <= tmp['fmin']['theta'] < com.S and \
        1e-50 <= tmp['fmin']['m'] < 1-1e-50):
    del (tmp['fmin'])

# find the model with the higher likelihood:
met = min(tmp, key=lambda x: tmp[x]['lnL'])

# load it as 'etienne' model
com.set_model(tmp[met]['model'])

lrt = abd.lrt('ewens', 'etienne')
best = 'ewens' if lrt > 0.05 else 'etienne'
print 'Best model by LRT was: ' + best

com.generate_random_neutral_distribution(model=best)

pval, neut_h = com.test_neutrality(model=best, gens=10000, full=True)
#draw_shannon_distrib(neut_h, abd.shannon)
draw_shannon_distrib(neut_h,
                     abd.shannon,
                     outfile='Fulcaldea_stuessyi_1kfrac_shannon_dist.pdf',
                     filetype='pdf')
print 'P-value for neutrality test was: ' + pval

out = open('Fulcaldea_stuessyi_1kfrac_shannon_neutral_data.tsv', 'w')
out.write('# shannon:' + str(shannon) + '\n')
out.write('\n'.join([str(s for s in neut_h)]) + '\n')
out.close()

com.dump_abundance('Fulcaldea_stuessyi_1kfrac_ecolopy.pik')