コード例 #1
0
ファイル: test_protamine.py プロジェクト: razib764/Treelib
def main():
    """
    main function
    """
    tree = EvolTree(WRKDIR + 'tree.nw')
    tree.workdir = 'data/protamine/PRM1/paml/'

    random_swap(tree)
    tree.link_to_evol_model(WRKDIR + 'paml/fb/fb.out', 'fb')
    check_annotation(tree)
    tree.link_to_evol_model(WRKDIR + 'paml/M1/M1.out', 'M1')
    tree.link_to_evol_model(WRKDIR + 'paml/M2/M2.out', 'M2')
    tree.link_to_evol_model(WRKDIR + 'paml/M7/M7.out', 'M7')
    tree.link_to_evol_model(WRKDIR + 'paml/M8/M8.out', 'M8')
    tree.link_to_alignment(WRKDIR + 'alignments.fasta_ali')
    print 'pv of LRT M2 vs M1: ',
    print tree.get_most_likely('M2', 'M1')
    print 'pv of LRT M8 vs M7: ',
    print tree.get_most_likely('M8', 'M7')

    tree.show(histfaces=['M2'])

    print 'The End.'
コード例 #2
0
ファイル: test_protamine.py プロジェクト: AlishaMechtley/ete
def main():
    """
    main function
    """
    tree = EvolTree (WRKDIR + 'tree.nw')
    tree.workdir = 'data/protamine/PRM1/paml/'

    random_swap(tree)
    tree.link_to_evol_model (WRKDIR + 'paml/fb/fb.out', 'fb')
    check_annotation (tree)
    tree.link_to_evol_model (WRKDIR + 'paml/M1/M1.out', 'M1')
    tree.link_to_evol_model (WRKDIR + 'paml/M2/M2.out', 'M2')
    tree.link_to_evol_model (WRKDIR + 'paml/M7/M7.out', 'M7')
    tree.link_to_evol_model (WRKDIR + 'paml/M8/M8.out', 'M8')
    tree.link_to_alignment  (WRKDIR + 'alignments.fasta_ali')
    print 'pv of LRT M2 vs M1: ',
    print tree.get_most_likely ('M2','M1')
    print 'pv of LRT M8 vs M7: ',
    print tree.get_most_likely ('M8','M7')


    tree.show (histfaces=['M2'])

    print 'The End.'
コード例 #3
0
ファイル: 2_sites_model.py プロジェクト: AlishaMechtley/ete
    pass

input ('\n   tree and alignment loaded\n Hit some key, to start computation of site models M1 and M2.\n')

print ('running model M1')
tree.run_model ('M1')
print ('running model M2')
tree.run_model ('M2')

print ('\n\n comparison of models M1 and M2, p-value: ' + str(tree.get_most_likely ('M2','M1')))

#tree.show()

print ('by default the hist represented is this one:')

tree.show (histfaces=['M2'])

print ('but we can choose between many others...')

model2 = tree.get_evol_model ('M2')

col2 = {'NS' : 'black', 'RX' : 'black',
        'RX+': 'black', 'CN' : 'black',
        'CN+': 'black', 'PS' : 'black', 'PS+': 'black'}


model2.set_histface (up=False, kind='curve', colors=col2, ylim=[0,4], hlines = [2.5, 1.0, 4.0, 0.5], header = 'Many lines, error boxes, background black',
                     hlines_col=['orange', 'yellow', 'red', 'cyan'], errors=True)

tree.show(histfaces=['M2'])
コード例 #4
0
ファイル: 4_branch_models.py プロジェクト: AlishaMechtley/ete
marks = ['1', '3', '7']

tree.mark_tree (marks, ['#1'] * 3)
print (tree.write ())

print ('we can easily colorize marked branches')
# display marked branches in orange
for node in tree.traverse ():
    if not hasattr (node, 'mark'):
        continue
    if node.mark == '':
        continue
    node.img_style = NodeStyle ()
    node.img_style ['bgcolor'] = '#ffaa00'
tree.show()

print ('''now running branch models
free branch models, 2 groups of branches, one with Gorilla and
chimp, the other with the rest of the phylogeny
''')
print ('running branch free...')
tree.run_model ('b_free.137')
print ('running branch neut...')
tree.run_model ('b_neut.137')
print ('running M0 (all branches have the save value of omega)...')
tree.run_model ('M0')

input ('''Now we can do comparisons...
Compare first if we have one or 2 rates of evolution among phylogeny.
LRT between b_free and M0 (that is one or two rates of omega value)
コード例 #5
0
ファイル: 1_freeratio.py プロジェクト: nilesh-iiita/ete
from ete3 import EvolTree

tree = EvolTree ("data/S_example/measuring_S_tree.nw")

print tree

raw_input ('\n   tree loaded, hit some key.\n')

print 'Now, it is necessary to link this tree to an alignment:'

tree.link_to_alignment ('data/S_example/alignment_S_measuring_evol.fasta')

raw_input ('\n   alignment loaded, hit some key to see.\n')

tree.show()

print '''
we will run free-ratio model that is one of models available through
function run_model:
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
'''
print tree.run_model.__doc__ +'\n+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++'

tree.run_model ('fb.example')

raw_input ('free-ratio model runned, all results are store in a Model object.')

fb = tree.get_evol_model('fb.example')

print 'Have a look to the parameters used to run this model on codeml: '
コード例 #6
0
from ete3 import TreeStyle
from ete3 import EvolTree
from ete3 import faces

tree = EvolTree("data/S_example/measuring_S_tree.nw")
tree.link_to_alignment('data/S_example/alignment_S_measuring_evol.fasta')

print(tree)

print('\n Running free-ratio model with calculation of ancestral sequences...')

tree.run_model('fb_anc')
#tree.link_to_evol_model('/tmp/ete3-codeml/fb_anc/out', 'fb_anc')

I = TreeStyle()
I.force_topology = False
I.draw_aligned_faces_as_table = True
I.draw_guiding_lines = True
I.guiding_lines_type = 2
I.guiding_lines_color = "#CCCCCC"
for n in sorted(tree.get_descendants() + [tree], key=lambda x: x.node_id):
    if n.is_leaf(): continue
    anc_face = faces.SequenceFace(n.sequence, 'aa', fsize=10, bg_colors={})
    I.aligned_foot.add_face(anc_face, 1)
    I.aligned_foot.add_face(
        faces.TextFace('node_id: #%d ' % (n.node_id), fsize=8), 0)
print('display result of bs_anc model, with ancestral amino acid sequences.')
tree.show(tree_style=I)

print('\nThe End.')
コード例 #7
0
)

marks = ['1', 3, '7']

tree.mark_tree(marks, ['#1'] * 3)
print(tree.write())

# display marked branches in orange
for node in tree.traverse():
    if not hasattr(node, 'mark'):
        continue
    if node.mark == '':
        continue
    node.img_style = NodeStyle()
    node.img_style['bgcolor'] = '#ffaa00'
tree.show()

print('''now running branch-site models C and D that represents
the addition of one class of sites in on specific branch.
These models must be compared to null models M1 and M3.
if branch-site models are detected to be significantly better,
than, one class of site is evolving at different rate in the marked
clade.
''')

# TODO: re-enable model M3

print('running branch-site C...')
tree.run_model('bsC.137')
#print ('running branch-site D...')
#tree.run_model ('bsD.137')
コード例 #8
0
    tree.mark_tree([leaf.node_id], marks=['#1'])
    print (tree.write())
    # to organize a bit, we name model with the name of the marked node
    # any character after the dot, in model name, is not taken into account
    # for computation. (have a look in /tmp/ete3.../bsA.. directory)
    print ('running model bsA and bsA1')
    tree.run_model('bsA.'+ leaf.name)
    tree.run_model('bsA1.' + leaf.name)
    print ('p-value of positive selection for sites on this branch is: ')
    ps = tree.get_most_likely('bsA.' + leaf.name, 'bsA1.'+ leaf.name)
    rx = tree.get_most_likely('bsA1.'+ leaf.name, 'M0')
    print (str(ps))
    print ('p-value of relaxation for sites on this branch is: ')
    print (str(rx))
    model = tree.get_evol_model("bsA." + leaf.name)
    if ps < 0.05 and float(model.classes['foreground w'][2]) > 1:
        print ('we have positive selection on sites on this branch')
        tree.show(histfaces=['bsA.' + leaf.name])
    elif rx<0.05 and ps>=0.05:
        print ('we have relaxation on sites on this branch')
    else:
        print ('no signal detected on this branch, best fit for M0')
    print ('\nclean tree, remove marks')
    tree.mark_tree(map(lambda x: x.node_id, tree.get_descendants()),
                    marks=[''] * len(tree.get_descendants()), verbose=True)

# nothing working yet to get which sites are under positive selection/relaxation,
# have to look at the main outfile or rst outfile

print ('The End.')
コード例 #9
0
ファイル: 6_ancestral_sequence.py プロジェクト: fmaguire/ete
from ete3 import faces


tree = EvolTree ("data/S_example/measuring_S_tree.nw")
tree.link_to_alignment ('data/S_example/alignment_S_measuring_evol.fasta')

print tree

print '\n Running free-ratio model with calculation of ancestral sequences...'

tree.run_model ('fb_anc')
#tree.link_to_evol_model('/tmp/ete3-codeml/fb_anc/out', 'fb_anc')

I = TreeStyle()
I.force_topology             = False
I.draw_aligned_faces_as_table = True
I.draw_guiding_lines = True
I.guiding_lines_type = 2
I.guiding_lines_color = "#CCCCCC"
for n in sorted (tree.get_descendants()+[tree],
                 key=lambda x: x.node_id):
    if n.is_leaf(): continue
    anc_face = faces.SequenceFace (n.sequence, 'aa', fsize=10, bg_colors={})
    I.aligned_foot.add_face(anc_face, 1)
    I.aligned_foot.add_face(faces.TextFace('node_id: #%d '%(n.node_id),
                                           fsize=8), 0)
print 'display result of bs_anc model, with ancestral amino acid sequences.'
tree.show(tree_style=I)

print '\nThe End.'
コード例 #10
0
06 Feb 2011

use slr to compute evolutionary rates
"""

__author__  = "Francois-Jose Serra"
__email__   = "*****@*****.**"
__licence__ = "GPLv3"
__version__ = "0.0"

from ete3 import EvolTree


tree = EvolTree ("data/S_example/measuring_S_tree.nw")
tree.link_to_alignment ("data/S_example/alignment_S_measuring_evol.fasta")


tree.run_model ('SLR')

slr = tree.get_evol_model ('SLR')

slr.set_histface (up=False, kind='curve',errors=True,
                  hlines = [1.0,0.3], hlines_col=['black','grey'])

tree.show (histfaces=['SLR'])





コード例 #11
0
'can be run from within a paml directory'
from ete3 import EvolTree
import os

tree_file = "testTree.tre"
alignment_file = "testAlignment.fasta"
model = "./model/out"
model_name = "bsD.bl_0.2w"
# model_name = os.path.basename(os.getcwd())

testTree = EvolTree(tree_file)
testTree.link_to_alignment(alignment_file)
testTree.link_to_evol_model(model, model_name)

testTree.show()
コード例 #12
0
ファイル: 3_branchsite_test.py プロジェクト: razib764/Treelib
    print(tree.write())
    # to organize a bit, we name model with the name of the marked node
    # any character after the dot, in model name, is not taken into account
    # for computation. (have a look in /tmp/ete3.../bsA.. directory)
    print('running model bsA and bsA1')
    tree.run_model('bsA.' + leaf.name)
    tree.run_model('bsA1.' + leaf.name)
    print('p-value of positive selection for sites on this branch is: ')
    ps = tree.get_most_likely('bsA.' + leaf.name, 'bsA1.' + leaf.name)
    rx = tree.get_most_likely('bsA1.' + leaf.name, 'M0')
    print(str(ps))
    print('p-value of relaxation for sites on this branch is: ')
    print(str(rx))
    model = tree.get_evol_model("bsA." + leaf.name)
    if ps < 0.05 and float(model.classes['foreground w'][2]) > 1:
        print('we have positive selection on sites on this branch')
        tree.show(histfaces=['bsA.' + leaf.name])
    elif rx < 0.05 and ps >= 0.05:
        print('we have relaxation on sites on this branch')
    else:
        print('no signal detected on this branch, best fit for M0')
    print('\nclean tree, remove marks')
    tree.mark_tree(map(lambda x: x.node_id, tree.get_descendants()),
                   marks=[''] * len(tree.get_descendants()),
                   verbose=True)

# nothing working yet to get which sites are under positive selection/relaxation,
# have to look at the main outfile or rst outfile

print('The End.')
コード例 #13
0
#tree.run_model("bsA." + chimaeriformes)
#tree.mark_tree([leaf.node_id], marks = ["#1"])
print("Running")
print(tree.write())
tree.run_model('bsA.Chimaeriformes')
tree.run_model("bsA1.Chimaeriformes")

print('p-value of positive selection for sites on this branch is: ')
ps = tree.get_most_likely('bsA.Chimaeriformes', 'bsA1.Chimaeriformes')
print(str(ps))
rx = tree.get_most_likely('bsA1.Chimaeriformes', 'M0')
print(str(rx))
model = tree.get_evol_model("bsA.Chimaeriformes")
if ps < 0.05 and float(model.classes['foreground w'][2]) > 1:
    print('we have positive selection on sites on this branch')
    tree.show(histfaces=['bsA1.Chimaeriformes'])
elif rx < 0.05 and ps >= 0.05:
    print('we have relaxation on sites on this branch')
else:
    print('no signal detected on this branch, best fit for M0')
#tree.show(histfaces=['bsA1.'])

for models in tree._models:
    print(tree.get_evol_model(models))

from _pickle import dump

#out = open('my_tree.pik', 'w')
#dump(tree, out)
#out.close()