__main__.py 2.14 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import argparse
import pandas as pd
from impute_jass.imputation_launcher import ImputationLauncher


def launch_chromosome_imputation(args):
    """
    Function whose only purpose is to allow the calling of the ImputationLauncher.chromosome_imputation method
    from an entry point
    """
    print(args)
    imputer = ImputationLauncher( window_size=int(args.window_size), buf=int(args.buffer_size),
                        lamb= float(args.l2_regularization), pinv_rcond = float(args.eigen_treshold))

    z_file = "{0}/z_{1}_{2}.txt".format(args.zscore_folder, args.gwas, args.chrom)
    zscore = pd.read_csv(z_file)
    imputer.chromosome_imputation(args.chrom, zscore, ref_panel, ld_folder)

def add_chromosome_imputation_argument(parser):
    parser.add_argument('--chrom', required=True, help= "chromosome to impute to the chr\d+ format")
    parser.add_argument('--gwas', required=True, help= "GWAS to impute to the consortia_trait format")

    parser.add_argument('--ref-folder', required=True, help= "reference panel location (used to determine which snp to impute)")
    parser.add_argument('--LD-folder', required=True, help= "Location  LD correlation matrices")
    parser.add_argument('--zscore-folder', required=True, help= "Location of the zscore files of the gwases to impute")
    parser.add_argument('--output-folder', required=True, help= "Location of the impute zscore files")

    parser.add_argument('--window-size', help= "Size of the non overlapping window", default = 500000)
    parser.add_argument('--buffer-size', help= "Size of the buffer around the imputation window", default = 125000)
    parser.add_argument('--l2-regularization', help= "Size of the buffer around the imputation window", default = 0.1)
    parser.add_argument('--eigen-treshold', help= "treshold under which eigen vectors are removed for the computation of the pseudo inverse", default = 0.1)
    parser.set_defaults(func=launch_chromosome_imputation)
    return(parser)


def main():

    parser = argparse.ArgumentParser()#prog='impute_jass')
    parser = add_chromosome_imputation_argument(parser)
    args = parser.parse_args()
    args.func(args)


if __name__=="__main__":
    main()