Ejemplo n.º 1
0
def main():
    draw_me = False
    sum_only = False
    MHC = False
    regions = pc_toolbox.create_region_list(REGION_LOC)
    bfile = BFILE
    #ldfolder = LDFOLDER
    ldfolder = '/home/jkb4y/ubs/work/results/Intersection_06022014/eurmeta_LD/'
    #outfolder = OUTFOLDER
    outfolder = '/home/jkb4y/ubs/work/results/Intersection_06022014/CAnalysis_LD/'
    assoc_folder = ASSOC_FOLDER
    #assoc_folder = '/home/jkb4y/work/results/Intersection_06022014/CAnalysis_eurmeta'
    #for r2 in ['0','0.2','0.4','0.6','0.8']:
    for r2 in ['0']:
    #for r2 in ['0','0.2']:
    #for r2 in ['0.2','0.4']:
    #for r2 in ['0.8','0.6']:
    #r2 = '0.8'
        tot_loc = os.path.join(ldfolder,'all_regions_r2_{0}.ld'.format(r2))
        with open(tot_loc, mode="w") as total:
            ld_title_list = ['CHR_A','BP_A','SNP_A','CHR_B','BP_B','SNP_B','R2']
            total.write('\t'.join(ld_title_list)+'\n')
        for region in regions:
            chrband = region.ID
            chromosome = region.chro
            subfolder = pc_toolbox.chr_folder(outfolder, chromosome)
            assoc_chr_folder = pc_toolbox.chr_folder(assoc_folder, chromosome)
            if chrband == '6p21.32' and not MHC:
                continue
            ld, snp_loc = plink_ld(region, bfile, ldfolder, assoc_chr_folder, r2, sum_only)
            copy_to_tot(tot_loc, ld)
            
            lz_ld = ld_for_lz(ld)
            main_lz(region, subfolder, assoc_chr_folder, snp_loc,lz_ld, r2, draw_me)
Ejemplo n.º 2
0
def main(argv):
    global out_base, freq_loc, meta_loc, bfile, table_type
    global covar_loc, annot, weight_min, build, fix_args
    global family
    cl_arguments(argv)
    #fix_it.main(fix_args)
    gene_region_list = pc_toolbox.create_region_list(region_loc)
    annot_dict_loc = fix_it.locate_annot_dict(build)
##    print annot_dict_loc
    annot_dict = fix_it.build_annot_dict('LOG',annot_dict_loc)
##    print("Annotation Dictionary as Follows:")
##    print annot_dict
##    gene_list = sorted(key_list,key=lambda gene:gene_region_dict[gene][0])
    #head, tail = os.path.split(out_file)
    #keep_loc = os.path.join(out_file,'_plink_keep.txt')
    keep_loc = out_base+'_plink_keep.txt'
    plink_out = out_base+'_sigs_inCC'
    #fixed_meta_loc = fix_it.locate_fixed_meta(meta_loc, build)
##    print fixed_meta_loc
    fixed_meta_loc = meta_loc
    index_dict = create_index_dict(fixed_meta_loc,table_type)
    z_list, lw_list = find_leastP_SNPs(gene_region_list, fixed_meta_loc, index_dict,
                                       out_base, freq_loc, keep_loc,
                                       weight_min, table_type, annot_dict)
    if bfile is not None and covar_loc is not None:
        plink_it(keep_loc, bfile, covar_loc, plink_out)
    repair_for_zs(z_list, lw_list, fixed_meta_loc, index_dict, build)
Ejemplo n.º 3
0
def which_one(region_loc, table_loc,chromosome, index_dict, zero_list):
    if region_loc is not None:
##        determine_table_titles(table_loc)
##        region_list = create_region_list(region_loc, region_col_dict)
        mb_region_list = pc_toolbox.create_region_list(region_loc)
        region_list = list()
        for mb_region in mb_region_list:
            region = RegInfo(chro = mb_region.chro, start = int(float(mb_region.start) * 1e6),
                             end = int(float(mb_region.end) *1e6),
                             band=mb_region.band, sym=mb_region.sym,
                             ID=mb_region.ID,title=mb_region.title)
            region_list.append(region)
        print region_list
    else:
        range_list = macro_ranges(table_loc, chromosome, index_dict)
##        print(range_list)
        region_list = macro_regions(chromosome, range_list)
##    base, ext = os.path.splitext(table_loc)
##    noZ_loc = base + '_noZs'+ext
    fix_list, zr_list = identify_zerops(region_list, zero_list)
    print('''
************************************************************************************
Here are the regions which will be drawn:
''')
    for fix in fix_list:
        print fix
    print('''
The following regions contain zero p-values, and will be adapted:''')
    for z in zr_list:
        print z
        
    print('''
************************************************************************************''')
    sys.stdout.flush()
    return fix_list, zr_list
Ejemplo n.º 4
0
def main():
    global out_file, region_loc,assoc_loc, freq_loc
    cl_arguments(sys.argv[1:])
    gene_region_list = pc_toolbox.create_region_list(region_loc)
    #gene_region_dict = create_region_dict(region_loc,position_form)
    #key_list = gene_region_dict.keys()
    #gene_list = sorted(key_list,key=lambda gene:gene_region_dict[gene][0])
    #find_leastP_SNPs(gene_list, gene_region_dict, assoc_loc)
    find_leastP_SNPs(gene_region_list, assoc_loc, out_file, freq_loc)
Ejemplo n.º 5
0
def main(argv):
    region_loc = REGION_LOC
    build = BUILD
    meta_loc = META_LOC
    outfolder = OUTFOLDER
    region_list = pc_toolbox.create_region_list(region_loc)
    annot_dict_loc = fix_it.locate_annot_dict(build)
    annot_dict = fix_it.build_annot_dict('LOG',annot_dict_loc)
    fixed_meta_loc = fix_it.locate_fixed_meta(meta_loc, build)
    for region in region_list:
        read_meta(fixed_meta_loc, region, outfolder, build, annot_dict)
Ejemplo n.º 6
0
def main():
    regions = pc_toolbox.create_region_list(REGION_LOC)
    ldfolder = '/home/jkb4y/work/results/2012Feb1/hg18/LD/'
    outfolder = '/home/jkb4y/work/results/2012Feb1/hg18/CAnalysis_Test/'
    for region in regions:
        chrband = region.band
        chromosome = region.chro
        subfolder = pc_toolbox.chr_folder(outfolder, chromosome)
        ldfile = chrband + '_r2_0.8_lz.ld'
        ld_sub = pc_toolbox.chr_folder(ldfolder, chromosome)
        ld = os.path.join(ld_sub,ldfile)
        snp_list = '{0}_~leastP_SNPs.txt'.format(chrband)
        snp_loc = os.path.join(ld_sub,snp_list)
        main_lz(region, subfolder, snp_loc,ld)
Ejemplo n.º 7
0
def main(argv):
    global region_loc, pc_cmdlist
    print sys.argv
    cl_arguments(argv)
    print(pc_cmdlist)
##    gene_region_dict = pc_toolbox.create_region_dict(region_loc, POSITION_FORM)
##    key_list = gene_region_dict.keys()
##    print gene_region_dict
##    index_tup = (chrcol,startcol,endcol,genecol)
##    region_list = create_region_list(region_loc, index_tup)
    region_list = pc_toolbox.create_region_list(region_loc)
    for region in region_list:
         cmd = write_command(region, pc_cmdlist)
         os.system(cmd)
def main():
    global out_file, table_loc, assoc, region_loc, build
    cl_arguments(sys.argv[1:])
    region_list = pc_toolbox.create_region_list(region_loc)
    annot_dict_loc = fix_it.locate_annot_dict(build)
    purpose = 'LOG'
    annot_dict = fix_it.build_annot_dict(purpose,annot_dict_loc)
##    annot_dict = None
##    print("Annotation Dictionary as Follows:")
##    print annot_dict
##    if annot is not None:
##        annot_dict = meta_toolbox.read_annot(annot)
##    elif fix:
##        annot_dict = meta_toolbox.read_annot_dict()
    snp_list = read_table(table_loc, region_list, assoc, annot_dict)
    print("inter_region_yank finds {0} SNPs of significance!".format(len(snp_list)))
    write_results(snp_list, out_file, assoc, annot_dict)
Ejemplo n.º 9
0
def which_one(region_loc, table_loc,chromosome, index_dict, zero_list):
    if region_loc is not None:
##        determine_table_titles(table_loc)
##        region_list = create_region_list(region_loc, region_col_dict)
        mb_region_list = pc_toolbox.create_region_list(region_loc)
        region_list = []
        for mb_region in mb_region_list:
            region = RegInfo(chro = mb_region.chro, start = int(float(mb_region.start) * 1e6),
                             end = int(float(mb_region.end) *1e6), band=mb_region.band, sym=mb_region.sym)
            region_list.append(region)
        print region_list
    else:
        range_list = macro_ranges(table_loc, chromosome, index_dict)
##        print(range_list)
        region_list = macro_regions(chromosome, range_list)
    fix_list = remove_zerops(region_list, zero_list)
    print('Here are the regions which will be drawn:')
    print fix_list
    return fix_list
Ejemplo n.º 10
0
def main(argv):
     global region_loc, pc_cmdlist, cluster, cflag
     print sys.argv
     cl_arguments(argv)
     print(pc_cmdlist)
##    gene_region_dict = pc_toolbox.create_region_dict(region_loc, POSITION_FORM)
##    key_list = gene_region_dict.keys()
##    print gene_region_dict
##    index_tup = (chrcol,startcol,endcol,genecol)
##    region_list = create_region_list(region_loc, index_tup)
     region_list = pc_toolbox.create_region_list(region_loc)
     for region in region_list:
          cmd = write_command(region, pc_cmdlist)
          if cluster:
               bash_loc = './PBS_scripts/'+region+'_'+cflag+'.sh'
               print bash_loc
               #write_bash(bash_loc, cmd)
               #os.system('qsub {0}.'.format(bash_loc))
          else:
               os.system(cmd)
def main(argv):
    global out_base, freq_loc, table_loc, bfile, table_type
    global covar_loc, annot, weight_min, build, region_loc, pop, aa_freq_loc
    cl_arguments(argv)
    zlist = list()
    index_dict, input_title_line = pc_toolbox.create_index_dict(table_loc, table_type)
    region_list = pc_toolbox.create_region_list(region_loc)
    annot_dict = create_annot_dict(build, 'LOG')
    out_file = out_base + '_yank.tbl'
    output_title_line = create_output_title_line(table_type, input_title_line)
    with open(out_file, mode="w") as out_text:
##        title_line = '\t'.join(META_TITLE_LIST)
        out_text.write(output_title_line +'\n')
        for region in region_list:
            print zlist
            sig_line, zlist, multicounter = read_table(table_loc, index_dict, region, weight_min, table_type, annot_dict, zlist)
            info = document_result(sig_line, region, index_dict, table_type,annot_dict, multicounter)
            if table_type == 'assoc':
                if pop == 'AA':
                    for item in AA_ASSOC_ORDER_LIST:
                        out_text.write(str(info[item]) + '\t')
                if pop == 'UK':
                    for item in ASSOC_ORDER_LIST:
                        out_text.write(str(info[item]) + '\t')
                
##            if table_type in ['perm']:
##                out_list = sig_line.strip().split()
##                out_list.append(info['note'])
##                out_list.append(info['band'])
##                out_list.append(info['ID'])
##                out_text.write('\t'.join(out_list))
            if table_type in ['meta','family']:
                for item in META_ORDER_LIST:
                    out_text.write(str(info[item]) + '\t')
            if table_type =='perm':
                for item in PERM_ORDER_LIST:
                    out_text.write(str(info[item]) + '\t')
            out_text.write('\n')
    if table_type in ['meta','family']:
        repair_meta_for_lz(zlist, table_loc, index_dict, weight_min)