コード例 #1
0
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=-12,
            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"
コード例 #2
0
def phyparts_pie_layout(mynode):
    if mynode.name in phyparts_pies:
        pie = faces.PieChartFace(
            phyparts_pies[mynode.name],
            #colors=COLOR_SCHEMES["set1"],
            colors=["blue", "green", "red", "dark gray"],
            width=50,
            height=50)
        pie.border.width = None
        pie.opacity = 0.5
        faces.add_face_to_node(pie, mynode, 0, position="branch-right")

        concord_text = faces.TextFace(str(int(concord_dict[mynode.name])) +
                                      '   ',
                                      fsize=20)
        conflict_text = faces.TextFace(str(int(conflict_dict[mynode.name])) +
                                       '   ',
                                       fsize=20)

        faces.add_face_to_node(concord_text, mynode, 0, position="branch-top")
        faces.add_face_to_node(conflict_text,
                               mynode,
                               0,
                               position="branch-bottom")

    else:
        F = faces.TextFace(mynode.name, fsize=20)
        faces.add_face_to_node(F, mynode, 0, position="aligned")
コード例 #3
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")
コード例 #4
0
ファイル: ProfilesLayout.py プロジェクト: dkoslicki/TAMPA
    def layout(self, node):

        scale=self.scaling
        eps = .000000001
        node_taxid = str(node.taxid)

        if node_taxid in self.profile_tax_id_to_percentage and self.profile_tax_id_to_percentage[node_taxid]['percentage'] > 0.:
            if  (scale=="log"):
                size_profile = (np.log(self.profile_tax_id_to_percentage[node_taxid]['percentage'])+9.)/11.*self.label_size
            elif(scale=="sqrt"):
                size_profile = (np.sqrt(self.profile_tax_id_to_percentage[node_taxid]['percentage'])-0.0000316227766)/10*self.label_size
            elif(scale=="exponent"):
                size_profile = (np.exp(self.profile_tax_id_to_percentage[node_taxid]['percentage'])-1.000000001)/np.exp(100)*self.label_size
            elif(scale=="linear"):
                size_profile = (self.profile_tax_id_to_percentage[node_taxid]['percentage'])/100*self.label_size
        else:
            size_profile = eps

        if node_taxid in self.ground_truth_tax_id_to_percentage and self.ground_truth_tax_id_to_percentage[node_taxid]['percentage'] > 0.:
            if  (scale=="log"):
                size_ground_truth = (np.log(self.ground_truth_tax_id_to_percentage[node_taxid]['percentage'])+9.)/11.*self.label_size
            elif(scale=="sqrt"):
                size_ground_truth = (np.sqrt(self.ground_truth_tax_id_to_percentage[node_taxid]['percentage'])-0.0000316227766)/10*self.label_size
            elif(scale=="exponent"):
                size_ground_truth = (np.exp(self.ground_truth_tax_id_to_percentage[node_taxid]['percentage'])-1.000000001)/np.exp(100)*self.label_size
            elif(scale=="linear"):
                size_ground_truth = (self.ground_truth_tax_id_to_percentage[node_taxid]['percentage'])/100*self.label_size
        else:
            size_ground_truth = eps




        chart_sizes = np.array([size_profile, size_ground_truth])

        if not np.sum(chart_sizes) == 0:
            chart_sizes = 100 * (chart_sizes / np.sum(chart_sizes))

            if(self.labels=="All"):
                F2 = TextFace(abbreaviate_name(node.sci_name), tight_text=True, fsize=self.font_size)  # use the scientific name
                faces.add_face_to_node(F2, node, column=0, position="branch-right")

            elif(self.labels=="Leaf"):
                if node.is_leaf():
                    F2 = TextFace(abbreaviate_name(node.sci_name), tight_text=True, fsize=self.font_size)  # use the scientific name
                    faces.add_face_to_node(F2, node, column=0, position="branch-right")

            if(self.layt=="Pie"):  # PIE CHART

                size = max([size_profile, size_ground_truth])
                F = faces.PieChartFace(chart_sizes,colors=['#1b9e77', '#d95f02'],width=size, height=size)

            elif(self.layt=="Circle"): #TWO CIRCLES SIDE BY SIDE
                F=faces.CircleFace(radius=size_profile, color="#1b9e77", style='circle', label=None)
                F1=faces.CircleFace(radius=size_ground_truth, color="#d95f02", style='circle', label=None)
                F1.border.width = None
                F1.opacity = 0.6
                faces.add_face_to_node(F1, node, 0, position="float-behind")

            elif(self.layt=="Rectangle"): #TWO CIRCLES SIDE BY SIDE

                F=faces.RectFace(width=size_profile, height=self.label_width, fgcolor="#1b9e77",bgcolor="#1b9e77", label=None)
                F1=faces.RectFace(width=size_ground_truth, height=self.label_width, fgcolor="#d95f02",bgcolor="#d95f02", label=None)
                F1.border.width = None
                F1.opacity = 0.6
                faces.add_face_to_node(F1, node, 0, position="float-behind")


            faces.add_face_to_node(F, node, 0, position="float-behind")
            F.border.width = None
            F.opacity = 0.6
コード例 #5
0
ファイル: ProfilesLayout.py プロジェクト: dkoslicki/TAMPA
    def layout(self, node):
        #if not node.is_leaf():
        scale=self.scaling
        eps = .000000001
        node_taxid = str(node.taxid)

        if node_taxid in self.profile_tax_id_to_percentage and self.profile_tax_id_to_percentage[node_taxid] > 0.:
            if  (scale=="log"):
                size_profile = np.log(self.profile_tax_id_to_percentage[node_taxid])
            elif(scale=="sqrt"):
                size_profile = np.sqrt(self.profile_tax_id_to_percentage[node_taxid])
            elif(scale=="exponent"):
                size_profile = np.exp(self.profile_tax_id_to_percentage[node_taxid])
            elif(scale=="linear"):
                size_profile = (self.profile_tax_id_to_percentage[node_taxid])
        else:
            size_profile = eps

        if node_taxid in self.ground_truth_tax_id_to_percentage and self.ground_truth_tax_id_to_percentage[node_taxid] > 0.:
            if  (scale=="log"):
                size_ground_truth = np.log(self.ground_truth_tax_id_to_percentage[node_taxid])
            elif(scale=="sqrt"):
                size_ground_truth = np.sqrt(self.ground_truth_tax_id_to_percentage[node_taxid])
            elif(scale=="exponent"):
                size_ground_truth = np.exp(self.ground_truth_tax_id_to_percentage[node_taxid])
            elif(scale=="linear"):
                size_ground_truth = (self.ground_truth_tax_id_to_percentage[node_taxid])
        else:
            size_ground_truth = eps

        size = 25*max([size_ground_truth, size_profile])
        chart_sizes = np.array([size_profile, size_ground_truth])
        # print(np.sum(chart_sizes))
        if not np.sum(chart_sizes) == 0:
            chart_sizes = 100 * (chart_sizes / np.sum(chart_sizes))
            if(self.labels=="All"):
                F2 = TextFace(abbreaviate_name(node.sci_name), tight_text=True, fsize=20)  # use the scientific name
                faces.add_face_to_node(F2, node, column=0, position="branch-right")
            elif(self.labels=="Leaf"):
                if node.is_leaf():
                    F2 = TextFace(abbreaviate_name(node.sci_name), tight_text=True, fsize=20)  # use the scientific name
                    faces.add_face_to_node(F2, node, column=0, position="branch-right")
            # print(chart_sizes)

            if(self.layt=="Pie"):  # PIE CHART
                F = faces.PieChartFace(chart_sizes,colors=['#1b9e77', '#d95f02'],width=size, height=size)

            elif(self.layt=="Bar"):# BAR CHART
                F = faces.BarChartFace(chart_sizes, deviations=None, labels=None, colors=['#1b9e77', '#d95f02'],width=50, height=50, label_fsize=0, scale_fsize=0)

                #print(chart_sizes, node.sci_name)

            elif(self.layt=="Circle"): #TWO CIRCLES SIDE BY SIDE
                F=faces.CircleFace(radius=size_profile*10, color="#1b9e77", style='circle', label=None)
                F1=faces.CircleFace(radius=size_ground_truth*10, color="#d95f02", style='circle', label=None)
                F1.border.width = None
                F1.opacity = 0.6
                faces.add_face_to_node(F1, node, 0, position="float-behind")

            elif(self.layt=="Rectangle"): #TWO CIRCLES SIDE BY SIDE
                F=faces.RectFace(width=size_profile*40, height=40, fgcolor="#1b9e77",bgcolor="#1b9e77", label=None)
                F1=faces.RectFace(width=size_ground_truth*40, height=40, fgcolor="#d95f02",bgcolor="#d95f02", label=None)
                F1.border.width = None
                F1.opacity = 0.6
                faces.add_face_to_node(F1, node, 0, position="float-behind")


            faces.add_face_to_node(F, node, 0, position="float-behind")
            F.border.width = None
            F.opacity = 0.6