Ejemplo n.º 1
0

from ete_dev import EvolTree


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

print tree

raw_input(
    "\n   tree and alignment loaded\nHit some key, to start computation of branch site models A and A1 on each branch.\n"
)

print "running model M0, for comparison with branch-site models..."
tree.run_model("M0")

# each node/leaf has two kind of identifiers node_id and paml_id, to mark nodes we have to specify
# the node_id of the nodes we want to mark, and the kind of mark in this way:

for leaf in tree:
    leaf.node_id
    print "\n---------\nNow working with leaf " + leaf.name
    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/ete2.../bsA.. directory)
    print "running model bsA and bsA1"
    tree.run_model("bsA." + leaf.name)
    tree.run_model("bsA1." + leaf.name)
Ejemplo n.º 2
0
    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')
print 'running M1 (all branches have the save value of omega)...'
tree.run_model ('M1')
#print 'running M3 (all branches have the save value of omega)...'
#tree.run_model ('M3')

print '''p-value that, in marked clade, we have one class of site
specifically evolving at a different rate:'''
print tree.get_most_likely ('bsC.137', 'M1')
#print 'p-value representing significance that omega is different of 1:'
#print tree.get_most_likely ('bsD.137', 'M3')


print 'The End.'
Ejemplo n.º 3
0
06 Feb 2011

use slr to compute evolutionary rates
"""

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

from ete_dev 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'])





Ejemplo n.º 4
0
__licence__ = "GPLv3"
__version__ = "0.0"


from ete_dev import EvolTree


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

print tree

raw_input ('\n   tree and alignment loaded\nHit some key, to start computation of branch site models A and A1 on each branch.\n')

print 'running model M0, for comparison with branch-site models...'
tree.run_model('M0')

# each node/leaf has two kind of identifiers node_id and paml_id, to mark nodes we have to specify
# the node_id of the nodes we want to mark, and the kind of mark in this way:

for leaf in tree:
    leaf.node_id
    print '\n---------\nNow working with leaf ' + leaf.name
    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/ete2.../bsA.. directory)
    print 'running model bsA and bsA1'
    tree.run_model ('bsA.'+ leaf.name)
    tree.run_model ('bsA1.' + leaf.name)
Ejemplo n.º 5
0
__email__ = "*****@*****.**"
__licence__ = "GPLv3"
__version__ = "0.0"

from ete_dev import TreeStyle
from ete_dev import EvolTree
from ete_dev 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/ete2-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.'
Ejemplo n.º 6
0
__licence__ = "GPLv3"
__version__ = "0.0"

from ete_dev import EvolTree

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

print tree

raw_input(
    '\n   tree and alignment loaded\nHit some key, to start computation of branch site models A and A1 on each branch.\n'
)

print 'running model M0, for comparison with branch-site models...'
tree.run_model('M0')

# each node/leaf has two kind of identifiers node_id and paml_id, to mark nodes we have to specify
# the node_id of the nodes we want to mark, and the kind of mark in this way:

for leaf in tree:
    leaf.node_id
    print '\n---------\nNow working with leaf ' + leaf.name
    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/ete2.../bsA.. directory)
    print 'running model bsA and bsA1'
    tree.run_model('bsA.' + leaf.name)
    tree.run_model('bsA1.' + leaf.name)
Ejemplo n.º 7
0
__licence__ = "GPLv3"
__version__ = "0.0"

from ete_dev import TreeStyle
from ete_dev import EvolTree
from ete_dev 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/ete2-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)
Ejemplo n.º 8
0
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: '
print fb.get_ctrl_string()
raw_input('hit some key...')

print 'Have a look to run message of codeml: '
print fb.run
raw_input('hit some key...')

print 'Have a look to log likelihood value of this model, and number of parameters:'
print 'lnL: %s and np: %s' % (fb.lnL, fb.np)
Ejemplo n.º 9
0
__licence__ = "GPLv3"
__version__ = "0.0"



from ete_dev import EvolTree

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

print tree

raw_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')
Ejemplo n.º 10
0
Archivo: 7_slr.py Proyecto: tarah28/ete
#!/usr/bin/python
"""
06 Feb 2011

use slr to compute evolutionary rates
"""

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

from ete_dev 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'])
Ejemplo n.º 11
0
# 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')

raw_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)
p-value ofthis comparison is:''')
print tree.get_most_likely('b_free.137', 'M0')

raw_input('''
Now test if foreground rate is significantly different of 1.
(b_free with significantly better likelihood than b_neut)
if significantly different, and higher than one, we will be under
Ejemplo n.º 12
0
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: '
print fb.get_ctrl_string()
raw_input ('hit some key...')


print 'Have a look to run message of codeml: '
print fb.run
raw_input ('hit some key...')

print 'Have a look to log likelihood value of this model, and number of parameters:'
Ejemplo n.º 13
0
# 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')

raw_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)
p-value ofthis comparison is:''')
print tree.get_most_likely ('b_free.137', 'M0')

raw_input ('''
Now test if foreground rate is significantly different of 1.
(b_free with significantly better likelihood than b_neut)
if significantly different, and higher than one, we will be under