Commit 62fee36f authored by Hanna  JULIENNE's avatar Hanna JULIENNE

add entry point to perform chromosome imputation

parent cd04d3fd
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()
......@@ -7,23 +7,13 @@ import pandas as pd
from .windows import ld_region_centered_window_imputation, impg_like_imputation, realigned_zfiles_on_panel
def chromosome_imputation_entry_point(chrom, zscore, ref_panel, ld_folder, window_size=10000, imputation_style="online", buf=2500, lamb= 0.01, pinv_rcond = 0.01):
"""
Function whose only purpose is to allow the calling of the ImputationLauncher.chromosome_imputation method
from an entry point
"""
imputer = ImputationLauncher( window_size=10000, imputation_style="online", buf=2500, lamb= 0.01, pinv_rcond = 0.01)
imputer.chromosome_imputation(chrom, zscore, ref_panel, ld_folder)
class ImputationLauncher(object):
"""
Class perform imputation of snp from summary statistic
"""
def __init__(self, window_size=10000, imputation_style="online", buf=2500, lamb= 0.01, pinv_rcond = 0.01 ):
def __init__(self, window_size=10000, imputation_style="batch", buf=2500, lamb= 0.01, pinv_rcond = 0.01 ):
"""
Args:
......
......@@ -10,13 +10,12 @@ setup(name='impute_jass',
#package_dir = {'': 'jass_preprocessing'},
packages= ['impute_jass'],
package_data = {'impute_jass':'./data/*.csv'},
zip_safe=False
zip_safe=False,
# entry_points={
# 'console_scripts' : [
# 'impute_chromosome = imputation_launcher:chromosome_imputation_entry_point'
#
# ]
# }
entry_points={
'console_scripts' : [
'impute_jass = impute_jass.__main__:main'
]
}
)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment