Beispiel #1
0
def showTreeStructure(inputfile):
    t = ClusterTree(
        "./OUTPUT/%s/NWK/HIER_CLUST_%s.nwk" %
        ((inputfile.split("_")[0]).upper(), inputfile.split(".")[0]))

    def mylayout(node):
        global flag
        #print node.left
        # print "node",len(node )
        #if len(node)!=1:# and flag == 1:
        #    if flag == 1:
        #        pidlist= getpid(node)
        #print pidlist
        #       dcs=DoCS(pidlist,PRO_pfam)
        #print dcs
        #       if dcs>=0.5:
        #          flag=0

        # print pidlist,len(node),dcs
        # print "_____________________"

        if node.is_leaf():
            node.img_style["shape"] = "sphere"
            node.img_style["size"] = 10
            node.img_style["fgcolor"] = 'purple'

    t.dist = 0
    t.convert_to_ultrametric(1, strategy="fixed")

    ts = TreeStyle()
    ts.scale = 230
    ts.root_opening_factor = 5.0
    ts.mode = "c"
    ts.layout_fn = mylayout
    #print mylayout
    t.show(tree_style=ts)
    print("--------------------------------")
    print("completed")
Beispiel #2
0
A\t-1.23\t-0.81\t1.79\t0.78\t-0.42\t-0.69\t0.58
B\t-1.76\t-0.94\t1.16\t0.36\t0.41\t-0.35\t1.12
C\t-2.19\t0.13\t0.65\t-0.51\t0.52\t1.04\t0.36
D\t-1.22\t-0.98\t0.79\t-0.76\t-0.29\t1.54\t0.93
E\t-1.47\t-0.83\t0.85\t0.07\t-0.81\t1.53\t0.65
F\t-1.04\t-1.11\t0.87\t-0.14\t-0.80\t1.74\t0.48
G\t-1.57\t-1.17\t1.29\t0.23\t-0.20\t1.17\t0.26
H\t-1.53\t-1.25\t0.59\t-0.30\t0.32\t1.41\t0.77
"""
print("Example numerical matrix")
print(matrix)
# #Names  col1    col2    col3    col4    col5    col6    col7
# A       -1.23   -0.81   1.79    0.78    -0.42   -0.69   0.58
# B       -1.76   -0.94   1.16    0.36    0.41    -0.35   1.12
# C       -2.19   0.13    0.65    -0.51   0.52    1.04    0.36
# D       -1.22   -0.98   0.79    -0.76   -0.29   1.54    0.93
# E       -1.47   -0.83   0.85    0.07    -0.81   1.53    0.65
# F       -1.04   -1.11   0.87    -0.14   -0.80   1.74    0.48
# G       -1.57   -1.17   1.29    0.23    -0.20   1.17    0.26
# H       -1.53   -1.25   0.59    -0.30   0.32    1.41    0.77
#
#
# We load a tree structure whose leaf nodes correspond to rows in the
# numerical matrix. We use the text_array argument to link the tree
# with numerical matrix.
t = ClusterTree("(((A,B),(C,(D,E))),(F,(G,H)));", text_array=matrix)
t.show("heatmap")
t.show("cluster_cbars")
t.show("cluster_bars")
t.show("cluster_lines")
A\t-1.23\t-0.81\t1.79\t0.78\t-0.42\t-0.69\t0.58
B\t-1.76\t-0.94\t1.16\t0.36\t0.41\t-0.35\t1.12
C\t-2.19\t0.13\t0.65\t-0.51\t0.52\t1.04\t0.36
D\t-1.22\t-0.98\t0.79\t-0.76\t-0.29\t1.54\t0.93
E\t-1.47\t-0.83\t0.85\t0.07\t-0.81\t1.53\t0.65
F\t-1.04\t-1.11\t0.87\t-0.14\t-0.80\t1.74\t0.48
G\t-1.57\t-1.17\t1.29\t0.23\t-0.20\t1.17\t0.26
H\t-1.53\t-1.25\t0.59\t-0.30\t0.32\t1.41\t0.77
"""
print "Example numerical matrix"
print matrix
# #Names  col1    col2    col3    col4    col5    col6    col7
# A       -1.23   -0.81   1.79    0.78    -0.42   -0.69   0.58
# B       -1.76   -0.94   1.16    0.36    0.41    -0.35   1.12
# C       -2.19   0.13    0.65    -0.51   0.52    1.04    0.36
# D       -1.22   -0.98   0.79    -0.76   -0.29   1.54    0.93
# E       -1.47   -0.83   0.85    0.07    -0.81   1.53    0.65
# F       -1.04   -1.11   0.87    -0.14   -0.80   1.74    0.48
# G       -1.57   -1.17   1.29    0.23    -0.20   1.17    0.26
# H       -1.53   -1.25   0.59    -0.30   0.32    1.41    0.77
#
#
# We load a tree structure whose leaf nodes correspond to rows in the
# numerical matrix. We use the text_array argument to link the tree
# with numerical matrix.
t = ClusterTree("(((A,B),(C,(D,E))),(F,(G,H)));", text_array=matrix)
t.show("heatmap")
t.show("cluster_cbars")
t.show("cluster_bars")
t.show("cluster_lines")
Beispiel #4
0
    # If node is internal
    else:
        # If silhouette is good, creates a green bubble
        if node.silhouette > 0:
            validationFace = TextFace("Silh=%0.2f" % node.silhouette,
                                      "Verdana", 10, "#056600")
            node.img_style["fgcolor"] = "#056600"
        # Otherwise, use red bubbles
        else:
            validationFace = 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
        add_face_to_node(validationFace, node, 0)
        if len(node) > 100:
            add_face_to_node(cbarsFace, node, 1)


# Use my layout to visualize the tree
ts = TreeStyle()
ts.layout_fn = mylayout
t.show(tree_style=ts)
Beispiel #5
0
        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)


# Use my layout to visualize the tree
t.show(mylayout)
        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 = TextFace("Silh=%0.2f" %node.silhouette,
                                      "Verdana", 10, "#056600")
            node.img_style["fgcolor"]="#056600"
        # Otherwise, use red bubbles
        else:
            validationFace = 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
        add_face_to_node(validationFace, node, 0)
        if len(node)>100:
            add_face_to_node(cbarsFace, node, 1)

# Use my layout to visualize the tree
ts = TreeStyle()
ts.layout_fn = mylayout
t.show(tree_style=ts)