_visualizer.py 文件源码

python
阅读 30 收藏 0 点赞 0 评论 0

项目:q2-diversity 作者: qiime2 项目源码 文件源码
def _compute_rarefaction_data(feature_table, min_depth, max_depth, steps,
                              iterations, phylogeny, metrics):
    depth_range = np.linspace(min_depth, max_depth, num=steps, dtype=int)
    iter_range = range(1, iterations + 1)

    rows = feature_table.ids(axis='sample')
    cols = pd.MultiIndex.from_product([list(depth_range), list(iter_range)],
                                      names=['depth', 'iter'])
    data = {k: pd.DataFrame(np.NaN, index=rows, columns=cols)
            for k in metrics}

    for d, i in itertools.product(depth_range, iter_range):
        rt = rarefy(feature_table, d)
        for m in metrics:
            if m in phylogenetic_metrics():
                vector = alpha_phylogenetic(table=rt, metric=m,
                                            phylogeny=phylogeny)
            else:
                vector = alpha(table=rt, metric=m)
            data[m][(d, i)] = vector
    return data
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号