peakcaller.bak2.py 文件源码

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

项目:CLAM 作者: Xinglab 项目源码 文件源码
def test_bin_fisher(intv_bin_ip, intv_bin_con, with_control=True, correction_method='fdr_bh'):
    """DOCSTRING
    Args
    Returns
    """
    if intv_bin_ip.shape[0] != 1:
        raise Exception('Fisher exact test does not deal with replicates.')
    intv_counter = intv_bin_ip.shape[1]
    assert intv_counter == intv_bin_con.shape[1]
    binscore = np.empty(intv_counter)
    binsignal = np.empty(intv_counter)
    ip_sum = np.sum(intv_bin_ip[0,])
    con_sum = np.sum(intv_bin_con[0,])
    for i in range(intv_counter):
        this_ip = intv_bin_ip[0, i]
        others_ip = ip_sum - this_ip
        this_con = intv_bin_con[0, i]
        others_con = con_sum - this_con
        if this_ip == 0:
            binsignal[i], binscore[i] = np.nan, 1.0
            continue
        _, binscore[i] = fisher_exact([[this_ip, others_ip], [this_con, others_con]], alternative='greater')
        if with_control:
            binsignal[i] = this_ip/others_ip / this_con*others_con
        else:
            binsignal[i] = this_ip

    adj = multipletests(binscore, alpha=0.05, method=correction_method)
    binscore_adj = adj[1]
    return binsignal, binscore_adj
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号