(2017/2/22, OS X El Capitan)
I was doing phylogenetic analysis and wanted to write a phylogenetic tree that integrated alignment information, so I introduced the ETE Toolkit. With the ETE Toolkit, you can use Python to create a phylogenetic tree that integrates alignment, domains, heatmaps, and more. This time, I would like to introduce a simple phylogenetic tree, a phylogenetic tree with alignment, and other useful functions. Currently, there is no comprehensive information other than the official website, so please let me know if you have any suggestions on how to use it.
http://etetoolkit.org
You need to install the above two. The OS is available on Mac or Linux. The official website recommends installing the ETE Toolkit using anaconda, which is often used to build Python environments. Please install anaconda by referring to the following pages. http://qiita.com/y__sama/items/5b62d31cb7e6ed50f02c
After installing anaconda, create a virtual environment and put it in with conda. As a caveat, it seems that an installation error occurs in Python 3.5 or later, so it is better to build a virtual environment as Python 3.4 (as of February 23, 2017).
$conda install -c etetoolkit ete3 ete3_external_apps
Finally, check if it was installed correctly.
$ete3 version
$ete3 build check
According to the official website, you can also build from source. http://etetoolkit.org/download/
Prepare a neick format tree file (extension can be .txt).
phylotree.py
#!/usr/bin/env python
import sys
from ete3 import PhyloTree
t = PhyloTree(sys.argv[1]) #Specify the newic file as an argument.
t.render("motifs.png ", w=2000, dpi=500) #Export file specification. w is width, h is height, unit is unit(“px”: pixels, “mm”: millimeters, “in”: inches), Dpi can be specified
You can make it a circular style by specifying "c" in TreeStyle (). Besides that, TreeStyle allows you to specify various things such as node color and shape (dots, thick lines, etc.). Please refer to the official website below. http://etetoolkit.org/docs/latest/reference/reference_treeview.html?highlight=treestyle#treestyle
phylotree_circular.py
#!/usr/bin/env python
import sys
from ete3 import Tree, PhyloTree, TreeStyle
t = PhyloTree(sys.argv[1])
circular_style = TreeStyle() #TreeStyle()You can specify the shape of the phylogenetic tree with
circular_style.mode = "c" #"c"Specify circular_Make it a style tree
circular_style.scale = 60 #You can specify the scale of the node
t.render("circular_tree_3.png ", w=800, dpi=200, tree_style=circular_style) #Export. w is width, h is height, unit is unit(“px”: pixels, “mm”: millimeters, “in”: inches), Dpi can be specified
In addition to the newick file, prepare a fasta file aligned with mafft etc. I referred to the following site for how to use mafft.
http://qiita.com/MaedaTaro_Umiushi/items/2d05225677ded15b19a7
In addition to the regular phylogenetic tree script, you can easily combine and visualize the phylogenetic tree and alignment by using the link_to_alignment
option.
phylotree_align
#!/usr/bin/env python
import sys
from ete3 import Tree, PhyloTree, SeqMotifFace, TreeStyle
t = PhyloTree(sys.argv[1]) #Specify newic file as an argument
t.link_to_alignment(sys.argv[2]) #Link the alignment file to the tree.
t.render("motifs_align.png ", w=2000, dpi=500) #Export. w is width, h is height, unit is unit(“px”: pixels, “mm”: millimeters, “in”: inches), Dpi can be specified
You can get the list of genes used for the tree as follows.
gene_list.py
import sys
from ete3 import Tree
t = Tree(sys.argv[1]) #Load the tree
gene_list = t.get_leaf_names() #Acquisition of gene name(Leaf name)
print(gene_list)
On the "The Programmable Tree Drawing Engine" page of the ETE Toolkit official website (http://etetoolkit.org/docs/latest/tutorial/tutorial_drawing.html?highlight=heatmap), everything from heatmaps to adding image files Has been shown to be possible. I will add it when I understand how to use it in the future.
Recommended Posts