当前位置: 首页>>代码示例>>Python>>正文


Python TreeNode.from_linkage_matrix方法代码示例

本文整理汇总了Python中skbio.core.tree.TreeNode.from_linkage_matrix方法的典型用法代码示例。如果您正苦于以下问题:Python TreeNode.from_linkage_matrix方法的具体用法?Python TreeNode.from_linkage_matrix怎么用?Python TreeNode.from_linkage_matrix使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在skbio.core.tree.TreeNode的用法示例。


在下文中一共展示了TreeNode.from_linkage_matrix方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_linkage_matrix

# 需要导入模块: from skbio.core.tree import TreeNode [as 别名]
# 或者: from skbio.core.tree.TreeNode import from_linkage_matrix [as 别名]
    def test_linkage_matrix(self):
        # Ensure matches: http://www.southampton.ac.uk/~re1u06/teaching/upgma/
        id_list = ['A', 'B', 'C', 'D', 'E', 'F', 'G']
        linkage = np.asarray([[1.0,  5.0,  1.0,  2.0],
                              [0.0,  3.0,  8.0,  2.0],
                              [6.0,  7.0, 12.5,  3.0],
                              [8.0,  9.0, 16.5,  5.0],
                              [2.0, 10.0, 29.0,  6.0],
                              [4.0, 11.0, 34.0,  7.0]])

        tree = TreeNode.from_linkage_matrix(linkage, id_list)
        self.assertEqual("(E:17.0,(C:14.5,((A:4.0,D:4.0):4.25,(G:6.25,(B:0.5,"
                         "F:0.5):5.75):2.0):6.25):2.5);",
                         tree.to_newick(with_distances=True))
开发者ID:BANSHEE-,项目名称:scikit-bio,代码行数:16,代码来源:test_tree.py

示例2: get_clusters

# 需要导入模块: from skbio.core.tree import TreeNode [as 别名]
# 或者: from skbio.core.tree.TreeNode import from_linkage_matrix [as 别名]
def get_clusters(x_original, axis=['row', 'column'][0]):
    """Performs UPGMA clustering using euclidean distances"""
    x = x_original.copy()
    if axis == 'column':
        x = x.T
    nr = x.shape[0]
    metric_f = get_nonphylogenetic_metric('euclidean')
    row_dissims = DistanceMatrix(metric_f(x), map(str, range(nr)))
    # do upgma - rows
    # Average in SciPy's cluster.heirarchy.linkage is UPGMA
    linkage_matrix = linkage(row_dissims.condensed_form(), method='average')
    tree = TreeNode.from_linkage_matrix(linkage_matrix, row_dissims.ids)
    row_order = [int(tip.name) for tip in tree.tips()]
    return row_order
开发者ID:jrherr,项目名称:qiime,代码行数:16,代码来源:make_otu_heatmap.py

示例3: single_file_upgma

# 需要导入模块: from skbio.core.tree import TreeNode [as 别名]
# 或者: from skbio.core.tree.TreeNode import from_linkage_matrix [as 别名]
def single_file_upgma(input_file, output_file):
    # read in dist matrix
    dist_mat = DistanceMatrix.from_file(input_file)

    # SciPy uses average as UPGMA:
    # http://docs.scipy.org/doc/scipy/reference/generated/
    #    scipy.cluster.hierarchy.linkage.html#scipy.cluster.hierarchy.linkage
    linkage_matrix = linkage(dist_mat.condensed_form(), method='average')

    tree = TreeNode.from_linkage_matrix(linkage_matrix, dist_mat.ids)

    # write output
    f = open(output_file, 'w')
    try:
        f.write(tree.to_newick(with_distances=True))
    except AttributeError:
        if c is None:
            raise RuntimeError("""input file %s did not make a UPGMA tree.
 Ensure it has more than one sample present""" % (str(input_file),))
        raise
    f.close()
开发者ID:AhmedAbdelfattah,项目名称:qiime,代码行数:23,代码来源:hierarchical_cluster.py


注:本文中的skbio.core.tree.TreeNode.from_linkage_matrix方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。