1
1
__author__ = 'Lindo Nkambule'
2
2
3
- from gwaspy .preimp_qc .annotations import *
4
- from typing import Tuple , Any , Dict , Union
5
- from gwaspy .utils .read_file import read_infile
3
+
6
4
import argparse
7
- from gwaspy .preimp_qc .report import MyDocument
5
+ import hail as hl
6
+ import os
8
7
import shutil
9
8
import warnings
10
- import os
11
- import hail as hl
9
+
10
+ from gwaspy .preimp_qc .annotations import *
11
+ from gwaspy .preimp_qc .report import MyDocument
12
+ from gwaspy .utils .read_file import read_infile
13
+ from gwaspy .utils .reference_liftover import liftover_to_grch38
14
+ from typing import Tuple , Any , Dict , Union
15
+
12
16
13
17
warnings .simplefilter (action = 'ignore' , category = RuntimeWarning )
14
18
@@ -67,7 +71,7 @@ def preimp_qc(input_type: str = None, dirname: str = None, basename: str = None,
67
71
cr_diff_thresh : Union [int , float ] = 0.02 , maf_thresh : Union [int , float ] = 0.01 , withpna : int = 0 ,
68
72
hwe_th_con_thresh : Union [int , float ] = 1e-6 , hwe_th_cas_thresh : Union [int , float ] = 1e-10 ,
69
73
hwe_th_all_thresh : Union [int , float ] = 1e-06 , annotations_file : str = None , report : bool = True ,
70
- export_type : str = 'hail' , out_dir : str = None , reference : str = 'GRCh38' ):
74
+ liftover : bool = False , export_type : str = 'hail' , out_dir : str = None , reference : str = 'GRCh38' ):
71
75
print ('\n Running QC' )
72
76
73
77
global mt , row_filters , filters , data_type , lambda_gc_pos , lambda_gc_pre , n_sig_var_pre , n_sig_var_pos , man_table_results , remove_fields
@@ -84,7 +88,10 @@ def preimp_qc(input_type: str = None, dirname: str = None, basename: str = None,
84
88
hl .default_reference (new_default_reference = reference )
85
89
86
90
# read input
87
- mt = read_infile (input_type = input_type , dirname = dirname , basename = basename , annotations = annotations_file )
91
+ if liftover :
92
+ mt = liftover_to_grch38 (input_type = input_type , dirname = dirname , basename = basename , annotations = annotations_file )
93
+ else :
94
+ mt = read_infile (input_type = input_type , dirname = dirname , basename = basename , annotations = annotations_file )
88
95
89
96
if 'is_case' in mt .col :
90
97
gwas_pre , n_sig_var_pre = manhattan (qqtitle = 'Pre-QC QQ Plot' , mantitle = 'Pre-QC Manhattan Plot' ).filter (mt )
@@ -373,6 +380,7 @@ def main():
373
380
parser .add_argument ('--annotations' , type = str )
374
381
parser .add_argument ('--reference' , type = str , default = 'GRCh38' )
375
382
parser .add_argument ('--report' , action = 'store_false' )
383
+ parser .add_argument ('--liftover' , action = 'store_true' )
376
384
# parser.add_argument('--qc_round', type=str, required=True)
377
385
378
386
# required for QC
@@ -399,8 +407,8 @@ def main():
399
407
mind_thresh = arg .mind , fhet_aut = arg .fhet_aut , fstat_x = arg .fstat_x , fstat_y = arg .fstat_y ,
400
408
geno_thresh = arg .geno , cr_diff_thresh = arg .midi , maf_thresh = arg .maf , hwe_th_con_thresh = arg .hwe_th_con ,
401
409
hwe_th_cas_thresh = arg .hwe_th_cas , hwe_th_all_thresh = arg .hwe_th_all , annotations_file = arg .annotations ,
402
- report = arg .report , export_type = arg .export_type , out_dir = arg .out_dir , reference = arg .reference ,
403
- withpna = arg .withpna )
410
+ report = arg .report , liftover = arg .liftover , export_type = arg .export_type , out_dir = arg .out_dir ,
411
+ reference = arg . reference , withpna = arg .withpna )
404
412
405
413
406
414
if __name__ == '__main__' :
0 commit comments