예제 #1
0
def my_layout(node):
    from ete2 import AttrFace, faces
    if node.is_leaf():
        faces.add_face_to_node(AttrFace("name"), node, column=0, position="aligned")
    else:
        node.img_style["size"] = 0
        node.img_style["fgcolor"] = "#000000"
 def my_layout(node):
     if node.is_leaf():
         name_face = AttrFace("name",fsize=25)
         faces.add_face_to_node(name_face, node, column=0, position="branch-right")
     else:
         name_face = AttrFace("name", fsize=20, fgcolor="red")
         faces.add_face_to_node(name_face, node, column=0, position="branch-right")
예제 #3
0
파일: addons.py 프로젝트: alxndrsPittis/ete
def ultrametric_layout(node):
    # node balls consume space in the tree picture, so partitions with
    # many splits are not well aligned with partitions having less
    # splits. To solve it,  I set node sphere size to 0
    node.img_style["size"] = 0
    if node.is_leaf():
        faces.add_face_to_node(nameFace, node, 0)
예제 #4
0
def makeSupportSymbols(node, secondary_support):
    #function to make circle with size scaled to base support value and color of circle scaled to the level of the second support value
    opacity = 0.01
    # Let's make the sphere transparent 
    if secondary_support == None:
        circle_color = "Grey"
        opacity = 1.0
        factor = 6
    elif secondary_support >=95.0:
        circle_color = "Black"
        opacity = 1.0
        factor = 10
    elif secondary_support >=70.0:
        circle_color = "Black"
        opacity = 1.0
        factor = 8
    elif secondary_support <70.0:
        circle_color = "Black"
        opacity = 1.0
        factor = 6
    else:
        print "secondary value unexpected: {}".format(secondary_support())
        circle_color = "Red"
        opacity = 1.0
    #circle_color = "#33343E" #a black from the pomacanthus drawing
    #print "color is {}, bootstrap is {}, opacity is {}".format(color, secondary_support, opacity)
    support_face = CircleFace(radius=node.support * factor, color=circle_color, style="circle")    
    support_face.opacity = opacity
    faces.add_face_to_node(support_face, node, 0, position="float-behind")
예제 #5
0
파일: addons.py 프로젝트: alxndrsPittis/ete
def ultrametric_layout(node):
    # node balls consume space in the tree picture, so partitions with
    # many splits are not well aligned with partitions having less
    # splits. To solve it,  I set node sphere size to 0
    node.img_style["size"] = 0
    if node.is_leaf():
        faces.add_face_to_node(nameFace, node, 0)
예제 #6
0
 def layout(node):
     if node.is_leaf():
         N = AttrFace("name", fsize=7)
         faces.add_face_to_node(faces.AttrFace("name", "Arial", 10, None),
                                node,
                                0,
                                position='branch-right')
예제 #7
0
def layout_simple(node):
    if node.is_leaf():
        attr = AttrFace("name",
                        fsize=10,
                        fgcolor="black",
                        text_prefix="  ",
                        fstyle="italic")
        faces.add_face_to_node(attr, node, 0, position="aligned")
예제 #8
0
파일: item_faces.py 프로젝트: a1an77/ete
def master_ly(node):
    if node.is_leaf():
        # Create an ItemFAce. First argument must be the pointer to
        # the constructor function that returns a QGraphicsItem. It
        # will be used to draw the Face. Next arguments are arbitrary,
        # and they will be forwarded to the constructor Face function.
        F = faces.DynamicItemFace(ugly_name_face, 100, 50)
        faces.add_face_to_node(F, node, 0, position="aligned")
예제 #9
0
def layout(node):
    if node.is_leaf():
        N = AttrFace("name", fsize=14, fgcolor="black")
        faces.add_face_to_node(N, node, 0)
        small_tree = small_d[node.name]
        T = TreeFace(small_tree,small_ts)
        T.opacity = 0.8
        # And place as a float face over the tree
        faces.add_face_to_node(T, node, 1, position="aligned")
예제 #10
0
def my_layout(node):
    if node.is_leaf():
         # If terminal node, draws its name
         name_faces = AttrFace("name")
    else:
         # If internal node, draws label with smaller font size
         name_faces = AttrFace("name", fsize=10)
    # Adds the name face to the image at the preferred position
    faces.add_face_to_node(name_faces, node, column=0, position="branch-right")
예제 #11
0
def layout(node):
    if not node.is_leaf():
        size = random.randint(20,50)
        F= faces.PieChartFace([10,20,60,10],
                              colors=COLOR_SCHEMES[random.sample(schema_names, 1)[0]],
                              width=size, height=size)
        F.border.width = None
        F.opacity = 0.6
        faces.add_face_to_node(F,node, 0, position="float")
예제 #12
0
def layout(node):
    if node.is_leaf():
        N = AttrFace("name", fsize=14, fgcolor="black")
        faces.add_face_to_node(N, node, 0)
        small_tree = small_d[node.name]
        T = TreeFace(small_tree, small_ts)
        T.opacity = 0.8
        # And place as a float face over the tree
        faces.add_face_to_node(T, node, 1, position="aligned")
예제 #13
0
	def layout(node):
		if node.name in ckm_name_to_perc:
			ckm_perc = float(ckm_name_to_perc[node.name])
		else:
			ckm_perc = 0
		F = CircleFace(radius=3.14*math.sqrt(ckm_perc), color="RoyalBlue", style="sphere")
		F.border.width = None
		F.opacity = 0.6
		faces.add_face_to_node(F,node, 0, position="branch-right")
		if label_internal_nodes:
			faces.add_face_to_node(TextFace(node.name, fsize=7),node, 0, position="branch-top")
예제 #14
0
파일: bubble_map.py 프로젝트: a1an77/ete
def layout(node):
    if node.is_leaf():
        # Add node name to laef nodes
        N = AttrFace("name", fsize=14, fgcolor="black")
        faces.add_face_to_node(N, node, 0)
    if "weight" in node.features:
        # Creates a sphere face whose size is proportional to node's
        # feature "weight"
        C = CircleFace(radius=node.weight, color="RoyalBlue", style="sphere")
        # Let's make the sphere transparent 
        C.opacity = 0.3
        # And place as a float face over the tree
        faces.add_face_to_node(C, node, 0, position="float")
예제 #15
0
def layout(node):
    global CONT
    if CONT >= len(chars):
        CONT = 0
    if node.is_leaf():
        node.img_style["size"] = 0
        F2= AttrFace("name", tight_text=True)
        F= TextFace(chars[CONT], tight_text=True)
        F.inner_border.width = 0
        F2.inner_border.width = 0
        #faces.add_face_to_node(F ,node, 0, position="branch-right")
        faces.add_face_to_node(F2 ,node, 1, position="branch-right")
        CONT += 1
예제 #16
0
파일: new_seq_face.py 프로젝트: a1an77/ete
def test_layout_phylo_nt(node):
    '''
    layout for CodemlTree
    '''
    if hasattr(node, "collapsed"):
        if node.collapsed == 1:
            node.img_style["draw_descendants"]= False
    if node.is_leaf():
        if hasattr (node, "sequence"):
            seqface =  MySequenceFace(node.sequence, "nt",
                                      fsize=10,
                                      col_w=11, interactive=True)
            faces.add_face_to_node(seqface, node, 1, aligned=True)
예제 #17
0
def layout(node):

	if not node.is_root():
		# give node name to all but the root
		faces.add_face_to_node(TextFace(node.name), node, 0)
		# and increase them with the wight
		if "weight" in node.features:
			# Creates a sphere face whose size is proportional to node's
			# feature "weight"
			C = CircleFace(radius=node.weight, color="RoyalBlue", style="sphere")
			# Let's make the sphere transparent 
			C.opacity = 0.34
			# And place as a float face over the tree
			faces.add_face_to_node(C, node, 0, position="float")
예제 #18
0
파일: tree_faces.py 프로젝트: a1an77/ete
def layout(node):
    if node.is_leaf():
        # Add node name to laef nodes
        N = AttrFace("name", fsize=14, fgcolor="black")
        faces.add_face_to_node(N, node, 0)

        t = Tree()
        t.populate(10)

        T = TreeFace(t, small_ts)
        # Let's make the sphere transparent 
        T.opacity = 0.8
        # And place as a float face over the tree
        faces.add_face_to_node(T, node, 1, position="aligned")
예제 #19
0
def layout(node):

	if not node.is_root():
		# give node name to all but the root
		faces.add_face_to_node(TextFace(node.name), node, 0)
		# and increase them with the wight
		if "weight" in node.features:
			# Creates a sphere face whose size is proportional to node's
			# feature "weight"
			C = CircleFace(radius=node.weight, color="RoyalBlue", style="sphere")
			# Let's make the sphere transparent 
			C.opacity = 0.34
			# And place as a float face over the tree
			faces.add_face_to_node(C, node, 0, position="float")
예제 #20
0
	def layout(node):
		#print(node)
		if node.is_leaf():
			if node.name in x_file_names:
				#make reconstructed bubble
				size = x[x_file_names.index(node.name)]
				F = CircleFace(radius=500*math.sqrt(size), color="RoyalBlue", style="sphere")
				F.border.width = None
				F.opacity = 0.6
				faces.add_face_to_node(F,node, 0, position="branch-right")
				if taxonomic_names_on_leaves:
					nameFace = AttrFace("name", fsize=25, fgcolor='black',text_suffix="_"+taxonomy[x_file_names.index(node.name)])
					faces.add_face_to_node(nameFace, node, 0, position="branch-right")
				else:
					nameFace = AttrFace("name", fsize=25, fgcolor='black')
					faces.add_face_to_node(nameFace, node, 0, position="branch-right")
		elif node.name in hyp_node_names: #Otherwise it's a hypothetical node, just use recon x
			node_base_name = hyp_node_names[node.name][0]
			percent = hyp_node_names[node.name][1]
			if node_base_name in x_file_names:
				idx = hyp_node_names[node.name][2]
				size = x[x_file_names.index(node_base_name)+(idx+1)*len(x_file_names)]
				F = CircleFace(radius=500*math.sqrt(size), color="RoyalBlue", style="sphere")
				F.border.width = None
				F.opacity = 0.6
				faces.add_face_to_node(F,node, 0, position="branch-right")
				#print node
				#print size
			else:
				size=0
		else:
			size=0
예제 #21
0
def mylayout(node):
    # If node is a leaf
    if node.is_leaf():
        # And a line profile
        faces.add_face_to_node(profileFace, node, 0, aligned=True)
        node.img_style["size"]=0
        faces.add_face_to_node(nameFace, node, 1, aligned=True)

    # If node is internal
    else:
        # If silhouette is good, creates a green bubble
        if node.silhouette>0:
            validationFace = faces.TextFace("Silh=%0.2f" %node.silhouette, "Verdana", 10, "#056600")
            node.img_style["fgcolor"]="#056600"
        # Otherwise, use red bubbles
        else:
            validationFace = faces.TextFace("Silh=%0.2f" %node.silhouette, "Verdana", 10, "#940000")
            node.img_style["fgcolor"]="#940000"

        # Sets node size proportional to the silhouette value.
        node.img_style["shape"]="sphere"
        if node.silhouette<=1 and node.silhouette>=-1:
            node.img_style["size"]= 15+int((abs(node.silhouette)*10)**2)

        # If node is very internal, draw also a bar diagram
        # with the average expression of the partition
        faces.add_face_to_node(validationFace, node, 0)
        if len(node)>100:
            faces.add_face_to_node(cbarsFace, node, 1)
예제 #22
0
파일: new_seq_face.py 프로젝트: a1an77/ete
def test_layout_phylo_aa_motif(node):
    '''
    layout for CodemlTree
    '''
    if hasattr(node, "collapsed"):
        if node.collapsed == 1:
            node.img_style["draw_descendants"]= False
    special_col = [[10,100],[150,1000],[1000,2000],[3000,4990]]
    if node.is_leaf():
        if hasattr (node, "sequence"):
            seqface =  MySequenceFace(node.sequence, "aa",
                                      fsize=10,special_col=special_col,
                                      alt_col_w=3,
                                      col_w=11, interactive=True)
            faces.add_face_to_node(seqface, node, 1, aligned=True)
예제 #23
0
def layout(node):
	if not node.is_root():
		# Add node name to laef nodes
		#N = AttrFace("name", fsize=14, fgcolor="black")
		#faces.add_face_to_node(N, node, 0)
		#pass
		faces.add_face_to_node(TextFace(node.name), node, 0)
		if "weight" in node.features:
			# Creates a sphere face whose size is proportional to node's
			# feature "weight"
			C = CircleFace(radius=node.weight, color="RoyalBlue", style="sphere")
			# Let's make the sphere transparent 
			C.opacity = 0.3
			# And place as a float face over the tree
			faces.add_face_to_node(C, node, 0, position="float")
예제 #24
0
파일: test_scale.py 프로젝트: a1an77/ete
def layout2(node):
    #node.img_style["size"] = random.randint(40, 200)
    if hasattr(node, "size"):
        f = faces.PieChartFace([100], node.size[0], node.size[1], ["blue"])
        faces.add_face_to_node(f, node, 0, position="branch-top")
        faces.add_face_to_node(f, node, 0, position="branch-bottom")
        #f = faces.PieChartFace([100], node.size[0]*3, node.size[0]*3, ["blue"])
        #faces.add_face_to_node(f, node, 0, position="branch-right")
        f.border.width = 0
        
        node.img_style["size"] = 10
        node.img_style["shape"] = "square"
    node.img_style["bgcolor"] = random_color()
    node.img_style["hz_line_width"] = 0
    node.img_style["vt_line_width"] = 0
예제 #25
0
def layout2(node):
    #node.img_style["size"] = random.randint(40, 200)
    if hasattr(node, "size"):
        f = faces.PieChartFace([100], node.size[0], node.size[1], ["blue"])
        faces.add_face_to_node(f, node, 0, position="branch-top")
        faces.add_face_to_node(f, node, 0, position="branch-bottom")
        #f = faces.PieChartFace([100], node.size[0]*3, node.size[0]*3, ["blue"])
        #faces.add_face_to_node(f, node, 0, position="branch-right")
        f.border.width = 0

        node.img_style["size"] = 10
        node.img_style["shape"] = "square"
    node.img_style["bgcolor"] = random_color()
    node.img_style["hz_line_width"] = 0
    node.img_style["vt_line_width"] = 0
def layout(node):
    node.img_style["size"] = random.randint(5,100)
    node.img_style["hz_line_width"] = 5
    node.img_style["vt_line_width"] = 10
    if node.is_leaf():
        #node.img_style["size"] = random.randint(50, 50)
        f = faces.TextFace("alignedFace", fsize=8, fgcolor="blue")
        #f = faces.AttrFace("name", fsize=random.randint(20,20))
        faces.add_face_to_node(f, node, 0, position="aligned")
        f.border.width = 0
        #f = faces.CircleFace(20, "red")
        #f = faces.AttrFace("name", fsize=20)
        f = faces.TextFace("NAME", fsize=10)
        #faces.add_face_to_node(f, node, 0, position="branch-right")
        f.border.width = 0
 def layout(node):
     def color(node):
         if type(node.item) is Value:
             return "Red"
         elif type(node.item) is Parameter:
             return "Yellow"
         elif node.item.leaf:
             return "Green"
         else:
             return "RoyalBlue"
     N = AttrFace("name", fsize=14, fgcolor="black")
     faces.add_face_to_node(N, node, 0)
     C = CircleFace(radius=node.weight, color=color(node), style="sphere")
     C.opacity = 0.3
     faces.add_face_to_node(C, node, 0, position="float")
예제 #28
0
파일: gen_tree2.py 프로젝트: agrimaldi/crg
def layout(node):
    if node.is_leaf():
        try:
            sane_node_name = sanitize(node.name)
            node.img_style['size'] = 10
            longNameFace = faces.TextFace(node.name.ljust(MAX_LN_LEN),
                                          ftype='courier',
                                          fsize=12)
            if node.name == 'Family Name':
                for family in globalInfo.families:
                    tmp_png = globalInfo.gen_png('fam_name', family, angle=90, save=False)
                    faces.add_face_to_node(faces.ImgFace(tmp_png),
                                           node, globalInfo.families.index(family)+2,
                                           aligned = True)
            else:
                organism = globalInfo.results_data[sane_node_name]
                print organism
                for family in globalInfo.families:
                    if family in organism.keys():
                        num_other = 0
                        for label in organism[family]:
                            print 'candidate :', organism[family][label], globalInfo.families.index(family), len(organism[family][label])
                            if label in globalInfo.img.keys():
                                tmp_png = globalInfo.gen_png(label,
                                                             len(organism[family][label]))
                                faces.add_face_to_node(faces.ImgFace(tmp_png),
                                                       node, globalInfo.families.index(family)+2,
                                                       aligned = True)

                            else:
                                num_other += 1
                        if num_other:
                            tmp_png = globalInfo.gen_png('unknown', num_other)
                            faces.add_face_to_node(faces.ImgFace(tmp_png),
                                           node, globalInfo.families.index(family)+2,
                                           aligned = True)
                    else:
                        tmp_png = globalInfo.gen_png('nan', '')
                        faces.add_face_to_node(faces.ImgFace(tmp_png),
                                               node, globalInfo.families.index(family)+2,
                                               aligned = True)

            faces.add_face_to_node(longNameFace, node, column=1, aligned=True)
                
        except Exception, e:
            print e
            print traceback.print_exc()
예제 #29
0
def layout(node):
    #if node.up is not None:

    #attr = AttrFace("decrease", fsize=7, fgcolor="red", text_prefix="-")
    #faces.add_face_to_node(attr, node, 0, position="branch-bottom")
    if node.is_leaf():
        attr = AttrFace("name",
                        fsize=10,
                        fgcolor="black",
                        text_prefix="  ",
                        fstyle="italic")
        faces.add_face_to_node(attr, node, 0, position="aligned")
        attr = AttrFace(args.feature_name,
                        fsize=7,
                        fgcolor="green",
                        text_prefix="")
        faces.add_face_to_node(attr, node, 0, position="branch-top")
예제 #30
0
파일: random_draw.py 프로젝트: a1an77/ete
def aligned_faces(node):
    if node.is_leaf():
        for i in xrange(3):
            F = faces.TextFace("ABCDEFGHIJK"[0:random.randint(1,11)])
            F.border.width = 1
            F.border.line_style = 1
            F.inner_background.color = "lightgreen"
            F.border.width = 1
            F.inner_border.width = 1
            F.background.color = "darkgreen"
            F.border.width = 2
            F.vt_align = random.randint(0,4)
            F.hz_align = random.randint(0,4)
            F.margin_bottom = random.randint(1, 20)
            F.margin_right  = random.randint(1, 20)
            F.margin_left = random.randint(1, 20)
            F.margin_top = random.randint(1, 20)

            faces.add_face_to_node(F, node, i, position="aligned")
            if random.randint(0, 1):
                faces.add_face_to_node(F, node, i, position="aligned")
예제 #31
0
	def layout(node):
		node_style = NodeStyle()
		node_style["hz_line_width"] = 10
		node_style["vt_line_width"] = 10
		node.set_style(node_style)
		#print(node)
		if node.is_leaf():
			if node.name in org_names:
				#make reconstructed bubble
				size = x[org_names.index(node.name)]
				F = CircleFace(radius=size_factor*math.sqrt(size), color="RoyalBlue", style="sphere")
				F.border.width = None
				F.opacity = 0.6
				faces.add_face_to_node(F,node, 0, position="branch-right")
				#Denote that this was a training organism
				nameFace = AttrFace("name", fsize=font_size, fgcolor='black')
				faces.add_face_to_node(nameFace, node, 0, position="branch-right")
		elif node.name in hyp_node_names: #Otherwise it's a hypothetical node, just use recon x
			node_base_name = hyp_node_names[node.name][0]
			percent = hyp_node_names[node.name][1]
			if node_base_name in org_names:
				idx = hyp_node_names[node.name][2]
				size = x[org_names.index(node_base_name)+(idx+1)*len(org_names)]
				F = CircleFace(radius=size_factor*math.sqrt(size), color="RoyalBlue", style="sphere")
				F.border.width = None
				F.opacity = 0.6
				faces.add_face_to_node(F,node, 0, position="branch-right")
				#This is if I want the names of the hypothetical nodes to be printed as well
				#nameFace = AttrFace("name", fsize=font_size, fgcolor='black')
				#faces.add_face_to_node(nameFace, node, 0, position="branch-right")
			else:
				size=0
		else:
			size=0
예제 #32
0
def my_layout(node):
    if node.name != "43":
        print node.name
        if node.is_leaf():
            # If terminal node, draws its name
            name_face = AttrFace("species", fsize=16)
            pie = PieChartFace([changes[node.name][0], changes[node.name][1]],
                               changes[node.name][2], changes[node.name][2],
                               ["Green", "Red"])
            pie.opacity = 0.5
            #name_face = AttrFace("name", fsize=16)
            faces.add_face_to_node(name_face,
                                   node,
                                   column=0,
                                   position="branch-right")
            faces.add_face_to_node(pie, node, column=0, position="float")
        else:
            # If internal node, draws label with smaller font size
            #name_face = AttrFace("name", fsize=10)
            pie = PieChartFace([changes[node.name][0], changes[node.name][1]],
                               changes[node.name][2], changes[node.name][2],
                               ["Green", "Red"])
            pie.opacity = 0.5
            #faces.add_face_to_node(name_face, node, column=0, position="branch-right")
            faces.add_face_to_node(pie, node, column=0, position="float")
예제 #33
0
 def layout(node):
     #print(node)
     if node.is_leaf():
         if node.name in x_file_names:
             #make reconstructed bubble
             size = x[x_file_names.index(node.name)]
             F = CircleFace(radius=500 * math.sqrt(size),
                            color="RoyalBlue",
                            style="sphere")
             F.border.width = None
             F.opacity = 0.6
             faces.add_face_to_node(F, node, 0, position="branch-right")
             if taxonomic_names_on_leaves:
                 nameFace = AttrFace(
                     "name",
                     fsize=25,
                     fgcolor='black',
                     text_suffix="_" +
                     taxonomy[x_file_names.index(node.name)])
                 faces.add_face_to_node(nameFace,
                                        node,
                                        0,
                                        position="branch-right")
             else:
                 nameFace = AttrFace("name", fsize=25, fgcolor='black')
                 faces.add_face_to_node(nameFace,
                                        node,
                                        0,
                                        position="branch-right")
     elif node.name in hyp_node_names:  #Otherwise it's a hypothetical node, just use recon x
         node_base_name = hyp_node_names[node.name][0]
         percent = hyp_node_names[node.name][1]
         if node_base_name in x_file_names:
             idx = hyp_node_names[node.name][2]
             size = x[x_file_names.index(node_base_name) +
                      (idx + 1) * len(x_file_names)]
             F = CircleFace(radius=500 * math.sqrt(size),
                            color="RoyalBlue",
                            style="sphere")
             F.border.width = None
             F.opacity = 0.6
             faces.add_face_to_node(F, node, 0, position="branch-right")
             #print node
             #print size
         else:
             size = 0
     else:
         size = 0
예제 #34
0
def tree_layout(node):
    if not node.is_leaf():
        #faces.add_face_to_node(AttrFace("mylabel"), node, column=1, position="branch-top")
        faces.add_face_to_node(AttrFace("mylabel"), node, column=1)
    else:
        if hasattr(node,'color'):
            faces.add_face_to_node(AttrFace("name",fgcolor=node.color), node, column=1)
        else:
            faces.add_face_to_node(AttrFace("name"), node, column=1)
예제 #35
0
def layout(node):
    if node.is_leaf():

        #######################################################
        #~ Taxon Label Size and Margin Adjustment
        N = AttrFace("name", fsize=1200, fgcolor="#000000")
        N.margin_top = 250
        N.margin_right = 100  #outside
        N.margin_left = 1000  #inside
        N.margin_bottom = 250
        #######################################################

        #######################################################
        #~ Taxon Label Background Color Setting
        tmp = "<myTaxaonLabel>"
        #~ if not(node.name.find(tmp)) : N.background.color="#FF9999"
        #######################################################

        faces.add_face_to_node(N, node, 0, position="aligned")

    if (not node.is_leaf()):
        S = faces.AttrFace("support", fsize=200, fgcolor="#000000")
        S.margin_top = 20
        S.margin_right = 10
        S.margin_left = 20
        S.margin_bottom = 20
        faces.add_face_to_node(S, node, column=0, position="float")
        if "support" in node.features:
            # Creates a sphere face whose size is proportional to node's
            # feature "weight"
            C = CircleFace(radius=node.support * 20,
                           color="RoyalBlue",
                           style="sphere")
            # Let's make the sphere transparent
            C.opacity = 0.3
            # And place as a float face over the tree
            faces.add_face_to_node(C, node, position="float", column=1)
    style = NodeStyle()
    style["size"] = 0
    style["vt_line_width"] = 150
    style["hz_line_width"] = 150
    style["vt_line_type"] = 0  # 0 solid, 1 dashed, 2 dotted
    style["hz_line_type"] = 0
    node.set_style(style)

    bgcol1 = "#FFCCCC"
    bgcol2 = "#FFE5CC"
    bgcol3 = "#FFFFCC"
    bgcol4 = "#E5FFCC"
    bgcol5 = "#CCFFCC"
    bgcol6 = "#CCFFE5"
    bgcol7 = "#FFCCE5"
    bgcol8 = "#CCFFFF"
    bgcol9 = "#CCE5FF"
    bgcol10 = "#CCCCFF"
    bgcol11 = "#E5CCFF"
예제 #36
0
def layout(node):
    if node.is_leaf():
        
        #######################################################
        #~ Taxon Label Size and Margin Adjustment
        N = AttrFace("name", fsize=1200,fgcolor="#000000")
        N.margin_top = 250
        N.margin_right = 100 #outside
        N.margin_left = 1000 #inside
        N.margin_bottom = 250
        #######################################################
        
        #######################################################
        #~ Taxon Label Background Color Setting
        tmp = "<myTaxaonLabel>" 
        #~ if not(node.name.find(tmp)) : N.background.color="#FF9999"
        #######################################################
        
        faces.add_face_to_node(N, node, 0, position="aligned")

    if (not node.is_leaf()) :
        S=faces.AttrFace("support", fsize=200, fgcolor="#000000")
        S.margin_top = 20
        S.margin_right = 10
        S.margin_left = 20
        S.margin_bottom = 20
        faces.add_face_to_node( S, node, column=0 , position = "float")
        if "support" in node.features:
        # Creates a sphere face whose size is proportional to node's
        # feature "weight"
            C = CircleFace(radius=node.support*20, color="RoyalBlue", style="sphere")
        # Let's make the sphere transparent 
            C.opacity = 0.3
        # And place as a float face over the tree
            faces.add_face_to_node(C, node, position="float",column=1)
    style = NodeStyle()
    style["size"] = 0
    style["vt_line_width"] = 150
    style["hz_line_width"] = 150
    style["vt_line_type"] = 0 # 0 solid, 1 dashed, 2 dotted
    style["hz_line_type"] = 0
    node.set_style(style)

    bgcol1="#FFCCCC"
    bgcol2="#FFE5CC"
    bgcol3="#FFFFCC"
    bgcol4="#E5FFCC"
    bgcol5="#CCFFCC"
    bgcol6="#CCFFE5"
    bgcol7="#FFCCE5"
    bgcol8="#CCFFFF"
    bgcol9="#CCE5FF"
    bgcol10="#CCCCFF"
    bgcol11="#E5CCFF"
예제 #37
0
def calibrations_layout(node):
    #width is set to 2 to increase visibility in large trees when exporting
    node.img_style["hz_line_width"]=4
    node.img_style["vt_line_width"]=4
    
    if node.is_leaf():
        node.img_style["size"] = 0
        color = "#000000" # these two lines hide the default node symbol for tips. They are replaced by the textface below
        faces.add_face_to_node( faces.TextFace(node.name, ftype="Arial", fsize=20, fstyle = "italic", fgcolor=color), node, 0 )
        #try adding the family to the tip as well
        #if node.name in ranks: # note that ranks is a dictionary that has not been passed in to the function. Could be trouble!
            #family = ranks[node.name]
            #faces.add_face_to_node( faces.TextFace(family, ftype="Arial", fsize=12, fgcolor="red"), node, 0 )
        if node.up is None:
            node.img_style["size"]=0
            node.dist = 0.35 # you may need to change this value to fit the aspect of your tree
            node.img_style["hz_line_color"] = "#ffffff"
            if UNROOTED:
                node.img_style["vt_line_type"] = 0.001
        #add faces to nodes that have images. face_dict is defined outside this function too....
        #if node.name in face_dict:
            #faces.add_face_to_node(face_dict[node.name], node, column  = 1, position = "branch-right")

    #If node is an internal node
    else:
        #color the node if is is a major clade
        #if node.nodeid in BG_COLORS:
            #node.img_style["bgcolor"] = BG_COLORS[str(node.nodeid)]
        # Sets the style of internal nodes
        node.img_style["size"] = 0
        #node.img_style["shape"] = "circle"
        #node.img_style["fgcolor"] = "#000000"
        
        #label internal nodes with nodenumber
        num = node.nodenumber
        faces.add_face_to_node(faces.TextFace(num, ftype="Arial", fsize=16, fgcolor="purple"), node, 0, position = "branch-right")
        # add paml calibrations
        if "paml_cal" in node.features:
            faces.add_face_to_node(faces.TextFace(node.paml_cal, ftype="Arial", fsize=16, fgcolor="black"), node, 0, position = "branch-right")
        if "raw_cal" in node.features:
            faces.add_face_to_node(faces.TextFace(node.raw_cal, ftype="Arial", fsize=16, fgcolor="orange"), node, 0, position = "branch-right")
예제 #38
0
파일: CAFE.py 프로젝트: melakbet/MAVR
 def layout(node):
     if node.up is not None:
         attr = AttrFace("significant_expansion",
                         fsize=7,
                         fgcolor="green",
                         text_prefix="+")
         faces.add_face_to_node(attr, node, 0, position="branch-top")
         attr = AttrFace("significant_contraction",
                         fsize=7,
                         fgcolor="red",
                         text_prefix="-")
         faces.add_face_to_node(attr, node, 0, position="branch-bottom")
     if node.is_leaf():
         attr = AttrFace("name",
                         fsize=10,
                         fgcolor="black",
                         text_prefix="  ",
                         fstyle="italic")
         faces.add_face_to_node(attr, node, 0, position="aligned")
예제 #39
0
 def layout(node):
     node_style = NodeStyle()
     node_style["hz_line_width"] = 10
     node_style["vt_line_width"] = 10
     node.set_style(node_style)
     #print(node)
     if node.is_leaf():
         if node.name in org_names:
             #make reconstructed bubble
             size = x[org_names.index(node.name)]
             F = CircleFace(radius=size_factor * math.sqrt(size),
                            color="RoyalBlue",
                            style="sphere")
             F.border.width = None
             F.opacity = 0.6
             faces.add_face_to_node(F, node, 0, position="branch-right")
             #Denote that this was a training organism
             nameFace = AttrFace("name", fsize=font_size, fgcolor='black')
             faces.add_face_to_node(nameFace,
                                    node,
                                    0,
                                    position="branch-right")
     elif node.name in hyp_node_names:  #Otherwise it's a hypothetical node, just use recon x
         node_base_name = hyp_node_names[node.name][0]
         percent = hyp_node_names[node.name][1]
         if node_base_name in org_names:
             idx = hyp_node_names[node.name][2]
             size = x[org_names.index(node_base_name) +
                      (idx + 1) * len(org_names)]
             F = CircleFace(radius=size_factor * math.sqrt(size),
                            color="RoyalBlue",
                            style="sphere")
             F.border.width = None
             F.opacity = 0.6
             faces.add_face_to_node(F, node, 0, position="branch-right")
             #This is if I want the names of the hypothetical nodes to be printed as well
             #nameFace = AttrFace("name", fsize=font_size, fgcolor='black')
             #faces.add_face_to_node(nameFace, node, 0, position="branch-right")
         else:
             size = 0
     else:
         size = 0
예제 #40
0
def layout(node):

    if node.is_leaf():
        # Add node name to laef nodes
        N = AttrFace("name", fsize=20, fgcolor="black")
        faces.add_face_to_node(N, node, 0)
    elif "pie_data" in node.features:
        # Creates a pie chart face whose size is proportional to node's
        percents=node.pie_data
        rcolor=[]
        for i in xrange(0, len(percents)):
            r= lambda: random.randint(0,255)
            rcolor.append( ('#%02X%02X%02X' % (r(),r(),r())))
        C = BarChartFace(percents, width=WIDTH, height=HEIGHT, colors=rcolor, min_value=0, max_value=100)
        # Let's make the Bar Chart transparent 
        #C.opacity = 0.3
        # And place as a float face over the tree
        faces.add_face_to_node(C, node, column=0, position="branch-top")
        nameFace= AttrFace("name", fsize=20)
        faces.add_face_to_node(nameFace, node, column=0, position="branch-bottom")
예제 #41
0
    def __layout__(self, node):
        if node.is_leaf():
            # Add node name to laef nodes
            N = AttrFace("name", fsize=14, fgcolor="black")
            faces.add_face_to_node(N, node, 0)
            nstyle = NodeStyle()

            nstyle["size"] = 0
            node.set_style(nstyle)
        if "internalCount" in node.features:
            print node.name
            # Creates a sphere face whose size is proportional to node's     
            # feature "weight"
            C = CircleFace(radius=int(node.internalCount)/10, color="RoyalBlue", style="sphere")
            T = TextFace("10")
            # Let's make the sphere transparent
            C.opacity = 0.3
            # And place as a float face over the tree
            faces.add_face_to_node(C, node, 0, position="float")
            faces.add_face_to_node(T, node, 1)
def layout(node):
    if node.is_leaf():
        F= faces.PieChartFace([10,10,10,10,10,10,10,10,10,4,6],
                              colors=COLOR_SCHEMES["set3"],
                              width=50, height=50)
        F.border.width = None
        F.opacity = 0.8
        faces.add_face_to_node(F,node, 0, position="branch-right")

        F= faces.PieChartFace([10,20,5,5,60],
                              colors=COLOR_SCHEMES[random.sample(schema_names, 1)[0]],
                              width=100, height=40)
        F.border.width = None
        F.opacity = 0.8
        faces.add_face_to_node(F,node, 0, position="branch-right")
    else:
        F= faces.BarChartFace([40,20,70,100,30,40,50,40,70,12], min_value=0,
                              colors=COLOR_SCHEMES["spectral"],
                              labels = "aaa,bbb,cccccc,dd,eeee,ffff,gg,HHH,II,JJJ,KK".split(","))
        faces.add_face_to_node(F,node, 0, position="branch-top")
        F.background.color = "#eee"
예제 #43
0
    def __layout__(self, node):
        if node.is_leaf():
            # Add node name to laef nodes
            N = AttrFace("name", fsize=14, fgcolor="black")
            faces.add_face_to_node(N, node, 0)
            nstyle = NodeStyle()

            nstyle["size"] = 0
            node.set_style(nstyle)
        if "internalCount" in node.features:
            print node.name
            # Creates a sphere face whose size is proportional to node's
            # feature "weight"
            C = CircleFace(radius=int(node.internalCount) / 10,
                           color="RoyalBlue",
                           style="sphere")
            T = TextFace("10")
            # Let's make the sphere transparent
            C.opacity = 0.3
            # And place as a float face over the tree
            faces.add_face_to_node(C, node, 0, position="float")
            faces.add_face_to_node(T, node, 1)
예제 #44
0
def layout(node):
    if node.is_leaf():
        # Add node name to leaf nodes
        N = AttrFace("name", fsize=14, fgcolor=node.tip_color)
        faces.add_face_to_node(N, node, 0)
예제 #45
0
파일: CAFE.py 프로젝트: melakbet/MAVR
 def layout(node, feature):
     if node.up is not None or feature == "id":
         attr = AttrFace(feature, fsize=5, fgcolor="green")
         faces.add_face_to_node(attr, node, 0, position="branch-top")
예제 #46
0
def mylayout(node, number_nodes=True, label_support_with_numbers=False):
    #width is set to 2 to increase visibility in large trees when exporting
    node.img_style["hz_line_width"]=4
    node.img_style["vt_line_width"]=4
    #counter2 = 0
    # If node is a leaf, add the nodes name and a its scientific
    # name
    if node.is_leaf():
        node.img_style["size"] = 0
        color = "#000000"
        faces.add_face_to_node( faces.TextFace(node.name, ftype="Arial", fsize=20, fstyle = "italic", fgcolor=color), node, 0 )
        #try adding the family to the tip as well
        #if node.name in ranks:
            #family = ranks[node.name]
            #faces.add_face_to_node( faces.TextFace(family, ftype="Arial", fsize=12, fgcolor="red"), node, 0 )
        if node.up is None:
            node.img_style["size"]=0
            node.dist = 0.35 # you may need to change this value to fit the aspect of your tree
            node.img_style["hz_line_color"] = "#ffffff"
            if UNROOTED:
                node.img_style["vt_line_type"] = 0.001
        
        #if node.name in face_dict:
        #    print "{} in face_dict ".format(node.name)
        #    faces.add_face_to_node(face_dict[node.name], node, column  = 1, position = "branch-right") #WOuld relly like the image to appear on outside of tre
            #print "found {} matches".format(counter2)
            
            #node.img_style["size"] = 16
            #node.img_style["shape"] = "sphere"
            #node.img_style["fgcolor"] = "#AA0000"

        # Sets the style of leaf nodes
        #node.img_style["size"] = 12
        #node.img_style["shape"] = "circle"
    #If node is an internal node
    else:
        #support_face = CircleFace(radius=100, color="Thistle", style="circle")    
        #support_face.opacity = 0.3
        #faces.add_face_to_node(support_face, node, 0, position="float")
        
        ###make bubble proportional to boostrap support
        # Creates a sphere face whose size is proportional to node's
        # feature "weight"
        #C = CircleFace(radius=node.support, color="Black", style="sphere")
        # Let's make the sphere transparent 
        #C.opacity = 1.0
        # And place as a float face over the tree
        #faces.add_face_to_node(C, node, 0, position="float")
      
        #print "current node id :" + str(node.nodeid)
        #print "is node in BG_COLORS? " + str(node.nodeid) in BG_COLORS
        #if node.nodeid in BG_COLORS:
            #print "this node is in colors" + node.nodeid
            #node.img_style["bgcolor"] = BG_COLORS[str(node.nodeid)]
            #print BG_COLORS[node.nodeid]
        # Sets the style of internal nodes
        node.img_style["size"] = 0
        #node.img_style["shape"] = "circle"
        #node.img_style["fgcolor"] = "#000000"
        
        num = node.nodenumber
        if number_nodes == True:
            faces.add_face_to_node(faces.TextFace(num, ftype="Arial", fsize=12, fgcolor="purple"), node, 0, position = "branch-right")
        # is the internal node an order?
        if node.order:
            faces.add_face_to_node(faces.TextFace(node.order, ftype="Arial", fsize=25, fgcolor="#black"), node, 0)
        
        if label_support_with_numbers:
            faces.add_face_to_node(faces.TextFace(node.support, ftype="Arial", fsize=10, fgcolor="black"), node, 0, position = "branch-top")
            if node.bootstrap:
                faces.add_face_to_node(faces.TextFace(node.bootstrap, ftype="Arial", fsize=10, fgcolor="grey"), node, 0, position = "branch-bottom")
        makeSupportSymbols(node, node.bootstrap)   
예제 #47
0
def my_layout(node):
    # Add name label to all nodes
    faces.add_face_to_node(AttrFace("name"),
                           node,
                           column=0,
                           position="branch-right")
예제 #48
0
def layout(node):
    node.img_style["size"] = 5
    node.img_style["hz_line_width"] = 0
    node.img_style["vt_line_width"] = 0
    if node.is_leaf():
        f = faces.AttrFace("name", fgcolor="steelblue", fsize=20)
        faces.add_face_to_node(f, node, 0, position="aligned")

        f = faces.AttrFace("name", fsize=15)
        faces.add_face_to_node(f, node, 0, position="branch-right")
    else:
        f = faces.TextFace("uno", fsize=8)
        for x in xrange(random.randint(1, 5)):
            faces.add_face_to_node(f, node, 0, position="branch-top")

        f = faces.TextFace("otromassssssssssss", fsize=8)
        for x in xrange(random.randint(1, 5)):
            faces.add_face_to_node(f, node, 0, position="branch-bottom")

    f = faces.CircleFace(20, "red")
    f.opacity = 0.3
    faces.add_face_to_node(f, node, 0, position="float")
    f = faces.CircleFace(23, "blue")
    f.opacity = 0.3
    faces.add_face_to_node(f, node, 0, position="float-behind")