alpha_diversity.py 文件源码

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

项目:microbiomeHD 作者: cduvallet 项目源码 文件源码
def get_layered_pvals(df, groupcol, valuecol, subset_by,
                      pval_method='kruskalwallis'):
    """
    Get pvalues for all pairwise combinations in groupcol.
    Performs calculating separately for each group in subset_by columns.
    In other words, this is a wrapper for groupby(subset_by) + get_all_pvals().

    Parameters
    ----------
    df : pandas dataframe
        tidy dataframe with labels in `groupcol` and values in `valuecol`
    groupcol, valuecol : str
        columns in df
    subset_by : str
        column to group by
    pval_method : str {'kruskalwallis', 'ranksums', 'wilcoxon', 'ttest_ind'}
        statistical method for comparison. Default is 'kruskalwallis'

    Returns
    -------
    pvals : dict
        multi-level dictionary, with outside keys as the unique values in
        df[subset_by] and the inner values as in get_all_pvals()
    """

    pvals = {}
    for s, subdf in df.groupby(subset_by):
        pvals[s] = get_all_pvals(subdf, groupcol, valuecol,
                                      method=pval_method)
    return pvals
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号