示例#1
0
def main():
    kmers = ["TGTAT", "CGTAT", "TTAGT", "TCTAT", "TCTAC"]
    motif_clust = MotifCluster(kmers)
    #result = motif_clust.cluster_by_seq()
    #print "Result: ", result
    data = np.transpose(np.array(kmers))
    print "DATA: "
    print data
    dist_func = lambda x, y: sw_align(x, y, return_score=True)
    linkage_method = "average"
    hclust = clustering.hierarchical_clust(np.array(kmers),
                                           dist_func,
                                           linkage_method)
示例#2
0
    def cluster_by_edit(self, kmers, linkage_method):
        """
        Cluster sequences by edit distances.

        Parameters:
        -----------
        kmers : flat list of kmers
        linkage_method : determines linkage function for hierarchical
        clustering ('average', 'single', ...).

        """
        # Nest kmers to create matrix for clustering purposes.
        kmers = [kmers]
        data = np.array(kmers)
        hclust = clustering.hierarchical_clust(data,
                                               self.edit_dist_func,
                                               linkage_method)
        return hclust