ete2.clustering.clustertree.ClusterNode

Package ete2 :: Package clustering :: Module clustertree :: Class ClusterNode |
[hide private]
[frames] | no frames]

# Class ClusterNode

source code

                object --+
                         |
    coretype.tree.TreeNode --+
                             |
                            ClusterNode

    Creates a new Cluster Tree object, which is a collection
    of ClusterNode instances connected in a hierarchical way, and
    representing a clustering result.

    a newick file or string can be passed as the first argument. An
    ArrayTable file or instance can be passed as a second argument.

    Examples:
      t1 = Tree() # creates an empty tree
      t2 = Tree( '(A:1,(B:1,(C:1,D:1):0.5):0.5);' )
      t3 = Tree( '/home/user/myNewickFile.txt' )

Instance Methods | [hide private]
_set_forbidden(self, value) | source code
_get_intra(self) | source code
_get_inter(self) | source code
_get_silh(self) | source code
_get_prof(self) | source code
_get_std(self) | source code
_set_profile(self, value) | source code
__init__(self, newick=None, text_array=None, fdist=<function spearman_dist at 0x2acd2a8>) x.__init__(...) initializes x; see x.__class__.__doc__ for signature | source code
set_distance_function(self, fn) Sets the distance function used to calculate cluster distances and silouette indexex. | source code
link_to_arraytable(self, arraytbl) Allows to link a given arraytable object to the tree structure under this node. | source code
iter_leaf_profiles(self) Returns an iterator over all the profiles associated to the leaves under this node. | source code
get_leaf_profiles(self) Returns the list of all the profiles associated to the leaves under this node. | source code
get_silhouette(self, fdist=None) Calculates the node's silhouette value by using a given distance function. | source code
get_dunn(self, clusters, fdist=None) Calculates the Dunn index for the given set of descendant nodes. | source code
_calculate_avg_profile(self) This internal function updates the mean profile associated to an internal node. | source code
Inherited from `object`: `__delattr__`, `__format__`, `__getattribute__`, `__hash__`, `__new__`, `__reduce__`, `__reduce_ex__`, `__repr__`, `__setattr__`, `__sizeof__`, `__subclasshook__`
Inherited from coretype.tree.TreeNode
__add__(self, value) This allows to sum two trees. | source code
__and__(self, value) This allows to execute tree&'A' to obtain the descendant node A | source code
__contains__(self, item) Check if item belongs to this node. | source code
__iter__(self) Iterator over leaf nodes | source code
__len__(self) Node len returns number of children. | source code
__str__(self) Print tree in newick format. | source code
_asciiArt(self, char1=`'``-``'`, show_internal=True, compact=False) Returns the ASCII representation of the tree. | source code
_get_children(self) | source code
_get_dist(self) | source code
_get_support(self) | source code
_get_up(self) | source code
_iter_descendants_postorder(self) Iterator over all desdecendant nodes. | source code
_iter_descendants_preorder(self) Iterator over all desdecendant nodes. | source code
_set_children(self, value) | source code
_set_dist(self, value) | source code
_set_support(self, value) | source code
_set_up(self, value) | source code
add_child(self, child=None, name=None, dist=None, support=None) Adds a new child to this node. | source code
add_feature(self, pr_name, pr_value) Adds or updates a node's feature. | source code
add_features(self, **features) Adds or updates a node's feature. | source code
add_sister(self, sister=None, name=None, dist=None) Adds a sister to this node. | source code
collapse(self) | source code
del_feature(self, pr_name) Deletes permanently a node's feature. | source code
delete(self, prevent_nondicotomic=True) Deletes node from the tree structure. | source code
describe(self) Prints general information about this node and its connections. | source code
detach(self) Detachs this node (and all its descendants) from its parent and returns the referent to itself. | source code
expand(self) | source code
get_ascii(self, show_internal=True, compact=False) Returns a string containing an ascii drawing of the tree. | source code
get_children(self) Returns an independent list of node's children. | source code
get_common_ancestor(self, *target_nodes) Returns the first common ancestor between this node and a given list of 'target_nodes'. | source code
get_descendants(self, strategy=`'``preorder``'`) Returns the list of all nodes (leaves and internal) under this node. | source code
get_distance(self, target, target2=None, topology_only=False) Returns the distance between two nodes. | source code
get_farthest_leaf(self, topology_only=False) Returns node's farthest descendant node (which is always a leaf), and the distance to it. | source code
get_farthest_node(self, topology_only=False) Returns the node's farthest descendant or ancestor node, and the distance to it. | source code
get_leaf_names(self) Returns the list of terminal node names under the current node. | source code
get_leaves(self) Returns the list of terminal nodes (leaves) under this node. | source code
get_leaves_by_name(self, name) Returns a list of nodes marching a given name. | source code
get_midpoint_outgroup(self) Returns the node that divides the current tree into two distance-balanced partitions. | source code
get_sisters(self) Returns an indepent list of sister nodes. | source code
get_tree_root(self) Returns the absolute root node of current tree structure. | source code
is_leaf(self) | source code
is_root(self) | source code
iter_descendants(self, strategy=`'``preorder``'`) Returns an iterator over descendant nodes. | source code
iter_leaf_names(self) Returns an iterator over the leaf names under this node. | source code
iter_leaves(self) Returns an iterator over the leaves under this node. | source code
iter_search_nodes(self, **conditions) | source code
populate(self, size, names_library=`[``]`, reuse_names=True) Populates the partition under this node with a given number of leaves. | source code
prune(self, nodes) Prunes the topology of this node in order to conserve only a selected list of leaf or internal nodes. | source code
remove_child(self, child) Removes a child from this node (parent and child nodes still exit but are no longer connected). | source code
remove_sister(self, sister=None) Removes a node's sister node. | source code
render(self, file_name, layout=None, w=None, h=None, img_properties=None, header=None) Renders the tree structure into an image file. | source code
search_nodes(self, **conditions) | source code
set_outgroup(self, outgroup) Sets a descendant node as the outgroup of a tree. | source code
show(self, layout=None, image_properties=None) Begins an interative session to visualize this node structure. | source code
swap_childs(self) Swaps current childs order. | source code
traverse(self, strategy=`'``preorder``'`) Returns an iterator that traverse the tree structure under this node. | source code
unroot(self) Unroots this node. | source code
write(self, features=None, outfile=None, format=0) Returns the newick representation of this node topology. | source code

Properties | [hide private]
| intracluster_dist
| intercluster_dist
| silhouette
| profile
| deviation
Inherited from `object`: `__class__`
Inherited from coretype.tree.TreeNode
| children
| dist
| support
| up

Method Details | [hide private]

### __init__(self, newick=None, text_array=None, fdist=<function spearman_dist at 0x2acd2a8>) (Constructor) | source code
x.__init__(...) initializes x; see x.__class__.__doc__ for signature Overrides: object.__init__ (inherited documentation)

### set_distance_function(self, fn) | source code
    Sets the distance function used to calculate cluster
    distances and silouette indexex.

    ARGUMENTS:

      fn: a pointer to python function acepting two arrays (numpy) as
      arguments.

    EXAMPLE:

      # A simple euclidean distance
      my_dist_fn = lambda x,y: abs(x-y)
      tree.set_distance_function(my_dist_fn)

### link_to_arraytable(self, arraytbl) | source code
Allows to link a given arraytable object to the tree structure under this node. Row names in the arraytable object are expected to match leaf names. Returns a list of nodes for with profiles could not been found in arraytable.

### get_silhouette(self, fdist=None) | source code
Calculates the node's silhouette value by using a given distance function. By default, euclidean distance is used. It also calculates the deviation profile, mean profile, and inter/intra-cluster distances. It sets the following features into the analyzed node: node.intracluster node.intercluster node.silhouete intracluster distances a(i) are calculated as the Centroid Diameter intercluster distances b(i) are calculated as the Centroid linkage distance ** Rousseeuw, P.J. (1987) Silhouettes: A graphical aid to the interpretation and validation of cluster analysis. J. Comput. Appl. Math., 20, 53-65.

Property Details | [hide private]

### intracluster_dist Get Method: _get_intra(self) Set Method: _set_forbidden(self, value)

### intercluster_dist Get Method: _get_inter(self) Set Method: _set_forbidden(self, value)

### silhouette Get Method: _get_silh(self) Set Method: _set_forbidden(self, value)

### profile Get Method: _get_prof(self) Set Method: _set_profile(self, value)

### deviation Get Method: _get_std(self) Set Method: _set_forbidden(self, value)