make-input-file.py 文件源码

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

项目:pheweb 作者: statgen 项目源码 文件源码
def make_pheno(pheno_name, use_maf, use_af, use_ac, use_ns):

    ns = random.randrange(100, 10_000)
    num_chromosomes = ns*2

    with TSVWriter(f'input_files/assoc-files/{pheno_name}.txt') as writer:

        for v in variants:
            if v['chrom'] == '1' and v['pos'] == 869334 or random.random() < 100 / len(variants):

                d = dict(
                    chrom=v['chrom'],
                    pos=v['pos'],
                    ref=v['ref'],
                    alt=v['alt'],
                    pval=format_float(random.random()),
                )
                ac = random.randrange(0,num_chromosomes+1) # allow MAF=0 b/c I'm sure somebody will.
                af = ac / num_chromosomes
                if use_maf: d['maf'] = format_float(min(af, 1-af))
                if use_af: d['af'] = format_float(af)
                if use_ac: d['ac'] = ac
                if use_ns: d['ns'] = ns

                writer.writerow(d)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号