-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathheig.py
1410 lines (1354 loc) · 43.2 KB
/
heig.py
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import os
import time
import argparse
import traceback
import numexpr
import numpy as np
import heig.input.dataset as ds
from heig.utils import GetLogger, sec_to_str
# os.environ['NUMEXPR_MAX_THREADS'] = '8'
# numexpr.set_num_threads(int(os.environ['NUMEXPR_MAX_THREADS']))
VERSION = "1.3.0"
MASTHEAD = (
"******************************************************************************\n"
)
MASTHEAD += "* Highly Efficient Imaging Genetics (HEIG)\n"
MASTHEAD += f"* Version {VERSION}\n"
MASTHEAD += f"* Zhiwen Jiang and Hongtu Zhu\n"
MASTHEAD += (
f"* Department of Biostatistics, University of North Carolina at Chapel Hill\n"
)
MASTHEAD += f"* GNU General Public License v3\n"
MASTHEAD += f"* Correspondence: [email protected], [email protected]\n"
MASTHEAD += (
"******************************************************************************\n"
)
parser = argparse.ArgumentParser(
description=f"\n Highly Efficient Imaging Genetics (HEIG) v{VERSION}"
)
common_parser = parser.add_argument_group(title="Common arguments")
herigc_parser = parser.add_argument_group(
title="Arguments specific to heritability and (cross-trait) genetic correlation analysis"
)
image_parser = parser.add_argument_group(title="Arguments specific to reading images")
fpca_parser = parser.add_argument_group(title="Arguments specific to functional PCA")
ldr_parser = parser.add_argument_group(title="Arguments specific to constructing LDRs")
make_ld_parser = parser.add_argument_group(
title="Arguments specific to making an LD matrix and its inverse"
)
sumstats_parser = parser.add_argument_group(
title="Arguments specific to organizing and preprocessing GWAS summary statistics"
)
voxelgwas_parser = parser.add_argument_group(
title="Arguments specific to recovering voxel-level GWAS results"
)
gwas_parser = parser.add_argument_group(
title="Arguments specific to doing genome-wide association analysis"
)
relatedness_parser = parser.add_argument_group(
title="Arguments specific to removing genetic relatedness in LDRs"
)
make_mt_parser = parser.add_argument_group(
title="Arguments specific to making a hail.MatrixTable of genotype data"
)
rv_null_parser = parser.add_argument_group(
title="Arguments specific to the null model of rare variant analysis"
)
rv_sumstats_parser= parser.add_argument_group(
title="Arguments specific to generating summary statistics for rare variant analysis"
)
rv_annotation_parser = parser.add_argument_group(
title="Arguments specific to processing rare variant annotations"
)
rv_coding_parser = parser.add_argument_group(
title="Arguments specific to analyzing coding rare variants using FAVOR annotations"
)
rv_noncoding_parser = parser.add_argument_group(
title="Arguments specific to analyzing non-coding rare variants using FAVOR annotations"
)
rv_parser = parser.add_argument_group(
title="Arguments specific to analyzing rare variants w/ or w/o annotations"
)
cluster_parser = parser.add_argument_group(
title="Arguments specific to cluster inference"
)
rv_cluster_parser = parser.add_argument_group(
title="Arguments specific to cluster inference for rare variant associations"
)
# module arguments
herigc_parser.add_argument(
"--heri-gc",
action="store_true",
help="Heritability and (cross-trait) genetic correlation analysis.",
)
image_parser.add_argument("--read-image", action="store_true", help="Reading images.")
fpca_parser.add_argument("--fpca", action="store_true", help="Functional PCA.")
ldr_parser.add_argument("--make-ldr", action="store_true", help="Constructing LDRs.")
make_ld_parser.add_argument(
"--ld-matrix", action="store_true", help="Making an LD matrix and its inverse."
)
sumstats_parser.add_argument(
"--sumstats",
action="store_true",
help="Organizing and preprocessing GWAS summary statistics.",
)
voxelgwas_parser.add_argument(
"--voxel-gwas", action="store_true", help="Recovering voxel-level GWAS results."
)
gwas_parser.add_argument(
"--gwas", action="store_true", help="Genome-wide association analysis."
)
relatedness_parser.add_argument(
"--relatedness", action="store_true", help="Removing genetic relatedness in LDRs."
)
make_mt_parser.add_argument(
"--make-mt", action="store_true", help="Making a hail.MatrixTable of genotype data."
)
rv_null_parser.add_argument(
"--rv-null",
action="store_true",
help="Fitting the null model for rare variant analysis.",
)
rv_sumstats_parser.add_argument(
"--make-rv-sumstats",
action="store_true",
help="Generating summary statistics for rare variant analysis.",
)
rv_annotation_parser.add_argument(
"--rv-annot",
action="store_true",
help="Preprocessing rare variant annotations.",
)
rv_coding_parser.add_argument(
"--rv-coding",
action="store_true",
help="Analyzing rare coding variants using FAVOR annotations.",
)
rv_noncoding_parser.add_argument(
"--rv-noncoding",
action="store_true",
help="Analyzing rare non-coding variants using FAVOR annotations.",
)
rv_parser.add_argument(
"--rv",
action="store_true",
help="Analyzing rare variants w/ or w/o customized annotations.",
)
cluster_parser.add_argument(
"--cluster",
action="store_true",
help="Generating null distribution of cluster size (number of associated voxels).",
)
rv_cluster_parser.add_argument(
"--rv-cluster",
action="store_true",
help="Generating null distribution of cluster size for rare variant associations.",
)
# common arguments
common_parser.add_argument("--out", help="Prefix of output.")
common_parser.add_argument(
"--image",
help=(
"Directory to processed raw images in HDF5 format. "
"Supported modules: --fpca, --make-ldr."
),
)
common_parser.add_argument(
"--n-ldrs",
type=int,
help=(
"Number of LDRs. Supported modules: "
"--make-ldr, --fpca, --heri-gc, --voxel-gwas, --gwas, --cluster, "
"--relatedness, --rv-null, --make-rv-sumstats, --rv-coding, "
"--rv-noncoding, --rv, --rv-cluster."
),
)
common_parser.add_argument(
"--ldr-sumstats",
help=(
"Prefix of preprocessed LDR GWAS summary statistics. "
"Supported modules: --heri-gc, --voxel-gwas."
),
)
common_parser.add_argument(
"--bases",
help=(
"Directory to functional bases. Supported modules: "
"--make-ldr, --heri-gc, --voxel-gwas, --cluster, --rv-null."
),
)
common_parser.add_argument(
"--ldr-cov",
help=(
"Directory to variance-covariance marix of LDRs. "
"Supported modules: --heri-gc, --voxel-gwas, --cluster."
),
)
common_parser.add_argument(
"--keep",
help=(
"Subject ID file(s). Multiple files are separated by comma. "
"Only common subjects appearing in all files will be kept (logical and). "
"Each file should be tab or space delimited, "
"with the first column being FID and the second column being IID. "
"Other columns will be ignored. "
"Each row contains only one subject. "
"Supported modules: --read-image, --fpca, --make-ldr, --ld-matrix, "
"--gwas, --cluster, --make-mt, --relatedness, --rv-null, --make-rv-sumstats, "
"--rv-cluster."
),
)
common_parser.add_argument(
"--remove",
help=(
"Subject ID file(s). Multiple files are separated by comma. "
"Subjects appearing in any files will be removed (logical or). "
"Each file should be tab or space delimited, "
"with the first column being FID and the second column being IID. "
"Other columns will be ignored. "
"Each row contains only one subject. "
"If a subject appears in both --keep and --remove, --remove takes precedence. "
"Supported modules: --read-image, --fpca, --make-ldr, --gwas, --cluster, "
"--make-mt, --relatedness, --rv-null, --make-rv-sumstats, --rv-cluster."
),
)
common_parser.add_argument(
"--extract",
help=(
"SNP file(s). Multiple files are separated by comma. "
"Only common SNPs appearing in all files will be extracted (logical and). "
"Each file should be tab or space delimited, "
"with the first column being rsID. "
"Other columns will be ignored. "
"Each row contains only one SNP. "
"Supported modules: --heri-gc, --ld-matrix, --voxel-gwas, --gwas, "
"--cluster, --make-mt, --relatedness."
),
)
common_parser.add_argument(
"--extract-locus",
help=(
"Variant file(s). Multiple files are separated by comma. "
"Only common Variants appearing in all files will be extracted (logical and). "
"Each file should be tab or space delimited, "
"with the first column being CHR:POS. "
"Other columns will be ignored. "
"Each row contains only one variant. "
"Supported modules: --make-mt, --make-rv-sumstats, --rv-coding, --rv-noncoding, "
"--rv-annot, --rv, --rv-cluster."
),
)
common_parser.add_argument(
"--exclude",
help=(
"SNP file(s). Multiple files are separated by comma. "
"SNPs appearing in any files will be excluded (logical or). "
"Each file should be tab or space delimited, "
"with the first column being rsID. "
"Other columns will be ignored. "
"Each row contains only one SNP. "
"Supported modules: --heri-gc, --ld-matrix, --voxel-gwas, --gwas, "
"--cluster, --make-mt, --relatedness."
),
)
common_parser.add_argument(
"--exclude-locus",
help=(
"Variant file(s). Multiple files are separated by comma. "
"Variants appearing in any files will be excluded (logical or). "
"Each file should be tab or space delimited, "
"with the first column being CHR:POS. "
"Other columns will be ignored. "
"Each row contains only one variant. "
"Supported modules: --make-mt, --make-rv-sumstats, --rv-coding, --rv-noncoding, "
"--rv-annot, --rv, --rv-cluster."
),
)
common_parser.add_argument(
"--maf-min",
type=float,
help=(
"Minimum minor allele frequency for screening SNPs. "
"Supported modules: --ld-matrix, --sumstats, --gwas, --cluster, --make-mt, "
"--relatedness, --make-rv-sumstats, --rv-coding, --rv-noncoding, "
"--rv, --rv-cluster."
),
)
common_parser.add_argument(
"--maf-max",
type=float,
help=(
"Maximum minor allele frequency for screening SNPs. "
"Supported modules: --sumstats, --gwas, --cluster, --make-mt, "
"--relatedness, --make-rv-sumstats, --rv-coding, --rv-noncoding, "
"--rv, --rv-cluster."
),
)
common_parser.add_argument(
"--hwe",
type=float,
help=(
"A HWE p-value threshold. "
"Variants with a HWE p-value less than the threshold "
"will be removed."
"Supported modules: --make-mt, --gwas, --cluster, --relatedness, "
"--make-rv-sumstats."
),
)
common_parser.add_argument(
"--call-rate",
type=float,
help=(
"A genotype call rate threshold, equivalent to 1 - missing rate. "
"Variants with a call rate less than the threshold "
"will be removed."
"Supported modules: --gwas, --relatedness, --make-mt, --cluster, "
"--make-rv-sumstats."
),
)
common_parser.add_argument(
"--covar",
help=(
"Directory to covariate file. "
"The file should be tab or space delimited, with each row only one subject. "
"Supported modules: --make-ldr, --gwas, --cluster, --relatedness, --rv-null."
),
)
common_parser.add_argument(
"--cat-covar-list",
help=(
"List of categorical covariates to include in the analysis. "
"Multiple covariates are separated by comma. "
"Supported modules: --make-ldr, --gwas, --cluster, --relatedness, --rv-null."
),
)
common_parser.add_argument(
"--bfile",
help=(
"Prefix of PLINK bfile triplets. "
"When estimating LD matrix and its inverse, two prefices should be provided "
"and seperated by a comma, e.g., `prefix1,prefix2`. "
"When doing GWAS, only one prefix is allowed. "
"Supported modules: --ld-matrix, --make-mt."
),
)
common_parser.add_argument(
"--chr-interval", "--range",
help=(
"A segment of chromosome, e.g. `3:1000000,3:2000000`, "
"from chromosome 3 bp 1000000 to chromosome 3 bp 2000000. "
"Cross-chromosome is not allowed. And the end position must "
"be greater than the start position. "
"Supported modules: --voxel-gwas, --gwas, --cluster, --make-mt, --make-rv-sumstats, "
"--rv-coding, --rv-noncoding, --rv, --rv-cluster."
),
)
common_parser.add_argument(
"--voxels", "--voxel",
help=(
"One-based index of voxel or a file containing voxels. "
"Supported modules: --voxel-gwas, --cluster, --rv-coding, --rv-noncoding, --rv, "
"--rv-cluster."
),
)
common_parser.add_argument(
"--ldrs",
help=(
"Directory to LDR file. "
"Supported modules: --gwas, --cluster, --relatedness, --rv-null."
),
)
common_parser.add_argument(
"--geno-mt",
help=(
"Directory to genotype MatrixTable. "
"Supported modules: --gwas, --make-mt, --cluster, --relatedness."
),
)
common_parser.add_argument(
"--grch37",
action="store_true",
help=(
"Using reference genome GRCh37. Otherwise using GRCh38. "
"Supported modules: --gwas, --make-mt, --cluster, --relatedness, --rv-annot, "
"--make-rv-sumstats, --rv-coding, --rv-noncoding, --rv, --rv-cluster."
),
)
common_parser.add_argument(
"--variant-type",
help=(
"Variant type (case insensitive), "
"must be one of ('variant', 'snv', 'indel'). "
"Supported modules: --gwas, --make-mt, --cluster, --relatedness, "
"--make-rv-sumstats."
),
)
common_parser.add_argument(
"--not-save-genotype-data",
action="store_true",
help=(
"Not saving preprocessed genotype data (Deprecated)."
),
)
common_parser.add_argument(
"--partition",
help=(
"Genome partition file. "
"The file should be tab or space delimited without header, "
"with the first column being chromosome, "
"the second column being the start position, "
"and the third column being the end position."
"Each row contains only one LD block. "
"Supported modules: --ld-matrix, --relatedness."
),
)
common_parser.add_argument(
"--threads",
type=int,
help=(
"number of threads. "
"Supported modules: --read-image, --sumstats, --fpca, "
"--voxel-gwas, --heri-gc, --make-ldr, --cluster, --relatedness, "
"--rv-cluster."
),
),
common_parser.add_argument(
"--spark-conf",
help=(
"Spark configuration file. "
"Supported modules: --relatedness, --gwas, --make-mt, --cluster, "
"--make-rv-sumstats, --rv-annot, --rv-coding, --rv-noncoding, --rv, "
"--rv-cluster."
),
),
common_parser.add_argument(
"--loco-preds",
help=(
"Leave-one-chromosome-out prediction file. "
"Supported modules: --gwas, --cluster, --make-rv-sumstats, --rv-cluster."
),
)
common_parser.add_argument(
"--annot-ht",
help=(
"Directory to processed functional annotations "
"for rare variant analysis in hail.Table format. "
"Supported modules: --rv-coding, --rv-noncoding, --rv."
),
)
common_parser.add_argument(
"--rv-sumstats-part1",
"--rv-sumstats",
help=(
"Prefix of rare variants summary statistics (part1) specific to images. "
"Supported modules: --rv-coding, --rv-noncoding, --rv."
)
)
common_parser.add_argument(
"--rv-sumstats-part2",
help=(
"Prefix of rare variants summary statistics (part1) not specific to images. "
"Supported modules: --rv-coding, --rv-noncoding, --rv."
)
)
common_parser.add_argument(
"--annot-cols",
help=(
"Annotation columns. Multiple columns are separated by comma. "
"Supported modules: --rv-annot, --rv."
),
)
common_parser.add_argument(
"--variant-category",
help=(
"Variant category (case insensitive), "
"must be one or some of ('all', 'plof', 'plof_ds', 'missense', "
"'disruptive_missense', 'synonymous', 'ptv', 'ptv_ds') for coding variants, "
"or one or some of ('all', 'upstream', 'downstream', 'promoter_cage', 'promoter_dhs', "
"'enhancer_cage', 'enhancer_dhs') for noncoding variants, "
"where 'all' means all categories; "
"multiple categories should be separated by comma. "
"Supported modules: --rv-coding, --rv-noncoding."
),
)
common_parser.add_argument(
"--variant-sets",
help=(
"Variant sets file."
"The file should be tab or space delimited without header. "
"Each row contains only one variant set in format "
"<gene name> <chr:start,chr:end>. "
"Supported modules: --rv-coding, --rv-noncoding."
)
)
common_parser.add_argument(
"--sig-thresh",
type=float,
help=(
"p-Value threshold for significance, "
"can be specified in a decimal 0.00000005 "
"or in scientific notation 5e-08. "
"Supported modules: --voxel-gwas, --cluster, --rv-coding, "
"--rv-noncoding, --rv, --rv-cluster."
),
)
common_parser.add_argument(
"--staar-only",
action="store_true",
help=(
"Saving STAAR-O results only, the omnibus test aggregating all "
"methods and functional annotations. "
"Supported modules: --rv-coding, --rv-noncoding, --rv."
)
)
common_parser.add_argument(
"--mac-thresh",
type=int,
help=(
"A minor allele count threshold. "
"Variants with a MAC less than the threshold "
"will be marked as a super rare variants in ACAT-V analysis. "
"Default: 10. "
"Supported modules: --rv-coding, --rv-noncoding, --rv, --rv-cluster."
),
)
common_parser.add_argument(
"--null-model",
help=(
"Directory to null model. "
"Supported modules: --make-rv-sumstats, --rv-cluster."
)
)
common_parser.add_argument(
"--sparse-genotype",
help=(
"Prefix of sparse genotype data. "
"Supported modules: --make-rv-sumstats, --rv-cluster."
)
)
common_parser.add_argument(
"--n-bootstrap",
type=int,
help=(
"Number of bootstrap samples. Default: 50. "
"Supported modules: --cluster, --rv-cluster."
)
)
common_parser.add_argument(
"--cmac-min",
type=int,
help=(
"The minimal of cumulative MAC in a variant set. "
"Supported modules: --rv-coding, --rv-noncoding, --rv, --rv-cluster."
)
)
# arguments for herigc.py
herigc_parser.add_argument(
"--ld-inv",
help=(
"Prefix of inverse LD matrix. Multiple matrices can be specified using {:}, "
"e.g., `ld_inv_chr{1:22}_unrel`."
),
)
herigc_parser.add_argument(
"--ld",
help=(
"Prefix of LD matrix. Multiple matrices can be specified using {:}, "
"e.g., `ld_chr{1:22}_unrel`."
),
)
herigc_parser.add_argument(
"--y2-sumstats",
help="Prefix of preprocessed GWAS summary statistics of non-imaging traits.",
)
herigc_parser.add_argument(
"--overlap",
action="store_true",
help=(
"Flag for indicating sample overlap between LDR summary statistics "
"and non-imaging summary statistics. Only effective if --y2-sumstats is specified."
),
)
herigc_parser.add_argument(
"--heri-only",
action="store_true",
help=(
"Flag for only computing voxelwise heritability "
"and skipping voxelwise genetic correlation within images."
),
)
# arguments for image.py
image_parser.add_argument(
"--image-txt",
help=(
"Directory to images in txt format. "
"The file should be tab or space delimited, with each row only one subject."
),
)
image_parser.add_argument(
"--coord-txt",
help=(
"Directory to images in txt format. "
"The file should be tab or space delimited, with each row only one voxel (vertex)."
),
)
image_parser.add_argument(
"--image-dir",
help=(
"Directory to images. All images in the directory with matched suffix "
"(see --image-suffix) will be loaded. "
"Multiple directories can be provided and separated by comma. "
"--keep can be used to load a subset of images (see --keep). "
"The supported formats include NIFTI and CIFTI images "
"and FreeSurfer morphometry data file."
),
)
image_parser.add_argument(
"--image-suffix",
help=(
"Suffix of images. HEIG requires the name of each image in the format <ID><suffix>, "
"e.g., `1000001_masked_FAskel.nii.gz`, where `1000001` is the ID "
"and `_masked_FAskel.nii.gz` is the suffix. "
"HEIG will collect ID for each image. "
"Multiple suffixes can be specified and separated by comma "
"and the number of directories must match the number of suffices."
),
)
image_parser.add_argument(
"--coord-dir",
help=(
"Directory to mask or complementary image for coordinates. "
"It should be a NIFTI file (nii.gz) for NIFTI images; "
"a GIFTI file (gii) for CIFTI2 surface data; "
"a FreeSurfer surface mesh file (.pial) for FreeSurfer morphometry data."
),
)
image_parser.add_argument(
"--image-list",
help=(
"Directory to multiple image HDF5 files, separated by comma."
),
)
# arguments for fpca.py
fpca_parser.add_argument(
"--all-pc",
action="store_true",
help=(
"Flag for generating all principal components which is min(n_subs, n_voxels), "
"which may take longer time and very memory consuming."
),
)
fpca_parser.add_argument(
"--bw-opt",
type=float,
help=(
"The bandwidth you want to use in kernel smoothing. "
"HEIG will skip searching the optimal bandwidth. "
"For images of any dimension, just specify one number, e.g, 0.5 "
"for 3D images."
),
)
fpca_parser.add_argument(
"--skip-smoothing",
action='store_true',
help=(
"Skipping kernel smoothing. "
),
)
# arguments for ldmatrix.py
make_ld_parser.add_argument(
"--ld-regu",
help=(
"Regularization for LD matrix and its inverse. "
"Two values should be separated by a comma and between 0 and 1, "
"e.g., `0.85,0.80`."
),
)
# arguments for sumstats.py
sumstats_parser.add_argument(
"--ldr-gwas",
help=(
"Directory to raw LDR GWAS summary statistics files. "
"Multiple files can be provided using {:}, e.g., `ldr_gwas{1:10}.txt`."
),
)
sumstats_parser.add_argument(
"--ldr-gwas-heig",
help=(
"Directory to raw LDR GWAS summary statistics files produced by --gwas. "
"Multiple files can be provided using {:}, e.g., `ldr_gwas{1:10}.txt.bgz`. "
"One file may contain multiple LDRs. These files must be in order."
),
)
sumstats_parser.add_argument(
"--y2-gwas", help="Directory to raw non-imaging GWAS summary statistics file."
)
sumstats_parser.add_argument("--n", type=float, help="Sample size. A positive number.")
sumstats_parser.add_argument("--n-col", help="Sample size column.")
sumstats_parser.add_argument("--chr-col", help="Chromosome column.")
sumstats_parser.add_argument("--pos-col", help="Position column.")
sumstats_parser.add_argument("--snp-col", help="SNP column.")
sumstats_parser.add_argument("--a1-col", help="A1 column. The effective allele.")
sumstats_parser.add_argument("--a2-col", help="A2 column. The non-effective allele.")
sumstats_parser.add_argument(
"--effect-col",
help=(
"Genetic effect column, usually refers to beta or odds ratio, "
"should be specified in this format `BETA,0` where "
"BETA is the column name and 0 is the null value. "
"For odds ratio, the null value is 1."
),
)
sumstats_parser.add_argument(
"--se-col",
help=(
"Standard error column. For odds ratio, the standard error must be in "
"log(odds ratio) scale."
),
)
sumstats_parser.add_argument("--z-col", help="Z score column.")
sumstats_parser.add_argument("--p-col", help="p-Value column.")
sumstats_parser.add_argument("--maf-col", help="Minor allele frequency column.")
sumstats_parser.add_argument("--info-col", help="INFO score column.")
sumstats_parser.add_argument(
"--info-min", type=float, help="Minimum INFO score for screening SNPs."
)
# arguments for voxelgwas.py
# arguments for relatedness.py
relatedness_parser.add_argument(
"--bsize", type=int, help="Block size of genotype blocks. Default: 5000."
)
# arguments for gwas.py
gwas_parser.add_argument(
"--ldr-col", help="One-based LDR indices. E.g., `3,4,5,6` and `3:6`, must be consecutive"
)
# arguments for mt.py
make_mt_parser.add_argument(
"--qc-mode", help="Genotype data QC mode, either gwas or wgs. Default: gwas."
)
make_mt_parser.add_argument(
"--save-sparse-genotype", action="store_true",
help="Saving sparse genotype for rare variant analysis."
)
make_mt_parser.add_argument(
"--vcf",
help="Direcotory to a VCF file."
)
make_mt_parser.add_argument(
"--skip-qc",
action="store_true",
help="Skipping QC genotype data."
)
# arguments for annotation.py
rv_annotation_parser.add_argument(
"--favor-annot",
help=(
"Directory to unzipped FAVOR annotation files. "
"For multiple files, using * to match any string of characters. "
"E.g., favor_db/chr*.csv."
),
)
rv_annotation_parser.add_argument(
"--general-annot",
help=(
"Directory to general annotation files. "
"Each file should be tab or space delimited. "
"Missing values are not allowed. "
"Use double quote marks `\"`. "
"For multiple files, using * to match any string of characters. "
"E.g., chr*.csv."
),
)
# arguments for wgs.py
rv_sumstats_parser.add_argument(
"--bandwidth",
type=int,
help="Bandwidth of banded LD matrix. Default: 3000000 (3 MB)."
)
rv_sumstats_parser.add_argument(
"--make-part2",
action="store_true",
help="Generating rare variants summary statistics (part2) not specific to images."
)
# arguments for slidingwindow.py
rv_parser.add_argument(
"--window-length",
type=int,
help="Length of sliding window. E.g., 10000 means 10kb."
)
rv_parser.add_argument(
"--sliding-length",
type=int,
help="Sliding length. E.g., 10000 means 10kb. Default: --window-length // 2."
)
def check_accepted_args(module, args, log):
"""
Checking if the provided arguments are accepted by the module
"""
accepted_args = {
"heri_gc": {
"out",
"heri_gc",
"ld_inv",
"ld",
"y2_sumstats",
"overlap",
"heri_only",
"n_ldrs",
"ldr_sumstats",
"bases",
"ldr_cov",
"extract",
"exclude",
"threads",
},
"read_image": {
"out",
"read_image",
"keep",
"remove",
"image_txt",
"coord_txt",
"image_dir",
"image_suffix",
"image",
"image_list",
"coord_dir",
"threads",
},
"fpca": {
"out",
"fpca",
"image",
"all_pc",
"n_ldrs",
"keep",
"remove",
"bw_opt",
"skip_smoothing",
"threads",
},
"make_ldr": {
"out",
"make_ldr",
"image",
"bases",
"n_ldrs",
"covar",
"cat_covar_list",
"keep",
"remove",
"threads",
},
"ld_matrix": {
"out",
"ld_matrix",
"partition",
"ld_regu",
"bfile",
"keep",
"extract",
"maf_min",
},
"sumstats": {
"out",
"sumstats",
"ldr_gwas",
"y2_gwas",
"ldr_gwas_heig",
"n",
"n_col",
"chr_col",
"pos_col",
"snp_col",
"a1_col",
"a2_col",
"effect_col",
"se_col",
"z_col",
"p_col",
"maf_col",
"maf_min",
"info_col",
"info_min",
"threads",
},
"voxel_gwas": {
"out",
"voxel_gwas",
"sig_thresh",
"voxels",
"chr_interval",
"extract",
"exclude",
"ldr_sumstats",
"n_ldrs",
"ldr_cov",
"bases",
"threads",
},
"gwas": {
"out",
"gwas",
"keep",
"remove",
"extract",
"exclude",
"maf_min",
"maf_max",
"variant_type",
"hwe",
"call_rate",
"chr_interval",
"ldr_col",
"ldrs",
"n_ldrs",
"grch37",
"geno_mt",
"covar",
"cat_covar_list",
"loco_preds",
"spark_conf",
},
"relatedness": {
"relatedness",
"out",
"keep",
"remove",
"extract",
"exclude",
"ldrs",
"covar",
"cat_covar_list",
"partition",
"maf_min",
"maf_max",
"variant_type",
"hwe",
"call_rate",
"n_ldrs",
"grch37",
"geno_mt",
"bsize",
"spark_conf",
"threads"
},
"make_mt": {
"make_mt",
"out",
"keep",
"remove",
"extract",
"exclude",
"extract_locus",
"exclude_locus",
"bfile",
"vcf",
"geno_mt",
"maf_min",
"maf_max",
"variant_type",
"hwe",
"call_rate",
"chr_interval",
"spark_conf",
"qc_mode",
"save_sparse_genotype",
"grch37",
"skip_qc",
"threads"
},
"rv_null": {
"rv_null",
"out",
"ldrs",
"n_ldrs",
"bases",
"covar",
"cat_covar_list",
"keep",
"remove",
"threads",
},
"make_rv_sumstats":{
"make_rv_sumstats",
"out",