Package ete2 :: Package treeview :: Module layouts
[hide private]
[frames] | no frames]

Source Code for Module ete2.treeview.layouts

  1  __VERSION__="ete2-2.0rev90"  
  2  # #START_LICENSE########################################################### 
  3  # 
  4  # Copyright (C) 2009 by Jaime Huerta Cepas. All rights reserved.   
  5  # email: jhcepas@gmail.com 
  6  # 
  7  # This file is part of the Environment for Tree Exploration program (ETE).  
  8  # http://ete.cgenomics.org 
  9  #   
 10  # ETE is free software: you can redistribute it and/or modify it 
 11  # under the terms of the GNU General Public License as published by 
 12  # the Free Software Foundation, either version 3 of the License, or 
 13  # (at your option) any later version. 
 14  #   
 15  # ETE is distributed in the hope that it will be useful, 
 16  # but WITHOUT ANY WARRANTY; without even the implied warranty of 
 17  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
 18  # GNU General Public License for more details. 
 19  #   
 20  # You should have received a copy of the GNU General Public License 
 21  # along with ETE.  If not, see <http://www.gnu.org/licenses/>. 
 22  # 
 23  # #END_LICENSE############################################################# 
 24   
 25  import numpy 
 26  import faces 
 27   
28 -def basic(node):
29 if node.is_leaf(): 30 node.img_style["size"]=1 31 node.img_style["shape"] = "circle" 32 faces.add_face_to_node(faces.AttrFace("name","Arial",10,"#4f8f0f",None), node, 0 )
33
34 -def phylogeny(node):
35 leaf_color = "#000000" 36 node.img_style["shape"] = "circle" 37 if hasattr(node,"evoltype"): 38 if node.evoltype == 'D': 39 node.img_style["fgcolor"] = "#1d176e" 40 node.img_style["hz_line_color"] = "#1d176e" 41 node.img_style["vt_line_color"] = "#1d176e" 42 elif node.evoltype == 'S': 43 node.img_style["fgcolor"] = "#FF0000" 44 node.img_style["line_color"] = "#FF0000" 45 elif node.evoltype == 'L': 46 node.img_style["fgcolor"] = "#777777" 47 node.img_style["vt_line_color"] = "#777777" 48 node.img_style["hz_line_color"] = "#777777" 49 node.img_style["line_type"] = 1 50 leaf_color = "#777777" 51 52 if node.is_leaf(): 53 node.img_style["shape"] = "square" 54 node.img_style["size"] = 4 55 node.img_style["fgcolor"] = leaf_color 56 faces.add_face_to_node( faces.AttrFace("name","Arial",11,leaf_color,None), node, 0 ) 57 if hasattr(node,"sequence"): 58 SequenceFace = faces.SequenceFace(node.sequence,"aa",13) 59 faces.add_face_to_node(SequenceFace, node, 1, aligned=True) 60 else: 61 node.img_style["size"] = 6
62
63 -def heatmap(node):
64 square_size = 10 65 # Extras node info 66 node.collapsed = False 67 68 # Color and style 69 node.img_style["fgcolor"] = "#3333FF" 70 node.img_style["size"] = 0 71 72 ncols = node.arraytable.matrix.shape[1] 73 matrix_max = numpy.max(node.arraytable.matrix) 74 matrix_min = numpy.min(node.arraytable.matrix) 75 matrix_avg = matrix_min+((matrix_max-matrix_min)/2) 76 ProfileFace = faces.ProfileFace(\ 77 matrix_max,\ 78 matrix_min,\ 79 matrix_avg,\ 80 square_size*ncols,\ 81 square_size,\ 82 "heatmap") 83 ProfileFace.ymargin=0 84 if node.is_leaf(): 85 # Set colors 86 faces.add_face_to_node(ProfileFace, node, 0, aligned=True )
87
88 -def cluster_cbars(node):
89 # Extras node info 90 node.collapsed = False 91 # Color and style 92 node.img_style["fgcolor"] = "#3333FF" 93 node.img_style["size"] = 4 94 matrix_max = numpy.max(node.arraytable.matrix) 95 matrix_min = numpy.min(node.arraytable.matrix) 96 matrix_avg = matrix_min+((matrix_max-matrix_min)/2) 97 ProfileFace = faces.ProfileFace(\ 98 matrix_max,\ 99 matrix_min,\ 100 matrix_avg,\ 101 200,\ 102 60,\ 103 "cbars") 104 105 if node.is_leaf(): 106 nameFace = faces.AttrFace("name",fsize=6 ) 107 faces.add_face_to_node(nameFace, node, 1, aligned=True ) 108 faces.add_face_to_node(ProfileFace, node, 0, aligned=True ) 109 else: 110 # Set custom faces 111 faces.add_face_to_node(ProfileFace, node, 0, aligned=True )
112
113 -def cluster_lines(node):
114 # Extras node info 115 node.collapsed = False 116 # Color and style 117 node.img_style["fgcolor"] = "#3333FF" 118 node.img_style["size"] = 4 119 matrix_max = numpy.max(node.arraytable.matrix) 120 matrix_min = numpy.min(node.arraytable.matrix) 121 matrix_avg = matrix_min+((matrix_max-matrix_min)/2) 122 ProfileFace = faces.ProfileFace(\ 123 matrix_max,\ 124 matrix_min,\ 125 matrix_avg,\ 126 200,\ 127 50,\ 128 "lines") 129 130 if node.is_leaf(): 131 nameFace = faces.AttrFace("name",fsize=6 ) 132 faces.add_face_to_node(nameFace, node, 1, aligned=True ) 133 faces.add_face_to_node(ProfileFace, node, 0, aligned=True ) 134 else: 135 # Set custom faces 136 faces.add_face_to_node(ProfileFace, node, 0, aligned=True )
137
138 -def cluster_bars(node):
139 # Extras node info 140 node.collapsed = False 141 # Color and style 142 node.img_style["fgcolor"] = "#3333FF" 143 node.img_style["size"] = 4 144 145 if node.is_leaf(): 146 matrix_max = numpy.max(node.arraytable.matrix) 147 matrix_min = numpy.min(node.arraytable.matrix) 148 matrix_avg = matrix_min+((matrix_max-matrix_min)/2) 149 ProfileFace = faces.ProfileFace(\ 150 matrix_max,\ 151 matrix_min,\ 152 matrix_avg,\ 153 200,\ 154 40,\ 155 "bars") 156 nameFace = faces.AttrFace("name",fsize=6 ) 157 faces.add_face_to_node(nameFace, node, 1, aligned=True ) 158 faces.add_face_to_node(ProfileFace, node, 0, aligned=True )
159
160 -def large(node):
161 # Color and style 162 node.img_style["fgcolor"] = "#3333FF" 163 node.img_style["size"] = 0
164 165 166 # Labels to show in qt application menu 167 layout_functions = { 168 "Basic": basic, 169 "Phylogenetic tree": phylogeny, 170 "Clustering heatmap": heatmap, 171 "Clustering validation (bars)": cluster_bars, 172 "Clustering validation (profiles)": cluster_cbars, 173 "Very large topology": large 174 } 175