-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathSMR.cpp
1335 lines (1282 loc) · 57.2 KB
/
SMR.cpp
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
//
// SMR.cpp
// SRM_CPP
//
// Created by Yang Wu on 06/08/2022.
// Copyright (c) 2022 Yang Wu. All rights reserved.
//
#include "StrFunc.h"
#include "SMR_data.h"
#include "OPERA.h"
#include "SMR_data_p1.h"
#include "SMR_data_p2.h"
#include "SMR_data_p3.h"
#include "SMR_plot.h"
#include "bfile.hpp"
#include "SMR.h"
using namespace SMRDATA;
using namespace StatFunc;
int thread_num;
int xh=0;
bool forcefrqck = true;
char* outFileName=NULL;
int main(int argc, char** argv) {
cout << "*******************************************************************" << endl;
cout << "* Omics pleiotropic association (OPERA)" << endl;
cout << "* version 1.18"<< endl;
cout << "* (C) 2022 Yang Wu, Jian Zeng and Jian Yang" << endl;
cout << "* The University of Queensland" << endl;
cout << "* MIT License" << endl;
cout << "*******************************************************************" << endl;
FLAGS_VALID_CK(argc,argv);
long int time_used = 0, start = time(NULL);
string months[] = {"Jan", "Feb", "Mar", "Apr", "May",
"Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
string weeks[] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri",
"Sat"};
time_t t = time(0);
tm* now = localtime(&t);
cout << "Analysis started: "<<now->tm_hour<<":"<<now->tm_min<<":"<< now->tm_sec<<","<<weeks[now->tm_wday]<<" "<<months[(now->tm_mon)]<<" "<<now->tm_mday<<","<<(now->tm_year + 1900)<<endl;
// cout << "Analysis started: "<< ctime(&t) << endl;
cout << "\nOptions:" << endl;
try {
option(argc, argv);
} catch (const string &err_msg) {
cerr << "\n" << err_msg << endl;
} catch (const char *err_msg) {
cerr << "\n" << err_msg << endl;
}
t = time(0);
now = localtime(&t);
cout << "\nAnalysis completed: "<<now->tm_hour<<":"<<now->tm_min<<":"<< now->tm_sec<<","<<weeks[now->tm_wday]<<" "<<months[(now->tm_mon)]<<" "<<now->tm_mday<<","<<(now->tm_year + 1900)<<endl;
// cout << "\nAnalysis completed: "<< ctime(&t) << endl;
time_used = time(NULL) - start;
cout << "Computational time: " << time_used / 3600 << ":" << (time_used % 3600) / 60 << ":" << time_used % 60 << endl;
return 0;
}
void option(int option_num, char* option_str[])
{
char* bFileName=NULL;
char* gwasFileName=NULL;
char* eqtlFileName=NULL;
char* indilstName=NULL;
char* snplstName=NULL;
char* indilst2remove=NULL;
char* snplst2exclde=NULL;
char* problst2exclde=NULL;
char* eproblst2exclde=NULL;
char* oproblst2exclde=NULL;
bool bFlag=false;// for binary file
double maf=0.0;
double p_hetero=1.5654e-3;
double p_smr=5.0e-8;
double ld_prune=0.9;
double ld_min=0.05;
double ld_prune_multi=0.1;
unsigned int m_hetero=3;
int opt_hetero=20;
bool smr_flag=true;
bool smr_trans_flag=false;
// for data management
bool make_besd_flag=false;
char* problstName=NULL;
char* eproblstName=NULL;
char* oproblstName=NULL;
char* targetsnpproblstName=NULL;
char* snpproblstName=NULL;
char* eFileName=NULL;
bool eremlFlag=false;
double pexsnp = -9;
double pinsnp = -9;
// for filtering
bool cis_flag=false;
int cis_itvl=2000;
int trans_itvl=1000;
float transThres=5.0e-8;
float restThres=1.0e-5;
// for lookup
double plookup=5e-8;
bool lookup_flag=false;
char* genelistName=NULL;
int chr=0;
int prbchr=0;
int snpchr=0;
char* snprs=NULL;
char* prbname=NULL;
char* fromsnprs=NULL;
char* tosnprs=NULL;
char* fromprbname=NULL;
char* toprbname=NULL;
int snpWind=50; //Kb
int prbWind=1000; //Kb
char* genename=NULL;
int fromsnpkb=-9;
int tosnpkb=-9;
int fromprbkb=-9;
int toprbkb=-9;
bool snpwindFlag=false;
bool prbwindFlag=false;
char* refSNP=NULL;
bool heidioffFlag = false;
thread_num = 1;
bool combineFlg = false;
char* eqtlsmaslstName = NULL;
//
char* gwasFileName2=NULL;
char* eqtlFileName2=NULL;
char* traitlstName=NULL; // for the outcome trait
//
bool plotflg=false;
//
char* syllabusName=NULL;
bool gctaflag=false;
bool plinkflag=false;
bool gemmaflag=false;
bool merlinflag=false;
bool boltflag=false;
bool mateqtlflag = false;
bool fastqtlnflag = false;
bool fastqtlpflag = false;
bool genouni=false;
char* freqName=NULL;
bool esdstd=false;
char* vpFileName=NULL;
bool metaflg=false;
bool est_effe_spl_size_flg=false;
// for SMR e2me
int outcomePrbWind=2000; //kb
char* eprobe=NULL;
char* oprobe=NULL;
char* eprobe2rm=NULL;
char* oprobe2rm=NULL;
// for internal test
char* smrRltFileName = NULL;
bool interanlflg=false;
bool recodeflg=false;
// for setBased SMR
char* geneAnnoName=NULL;
char* setlstName=NULL;
int setWind=-9;
bool ssmrflg=false;
//
char* queryFileName=NULL;
bool queryfileflg=false;
bool save_dense_flag=false;
double pthres_me2esmr=1.0;
bool diffflag=false;
double threshpsmrest=1.0;
double threshphet=0.0;
bool qcflag=false;
int qcmtd=0;
int z_thresh=3;
bool new_het_mth=true;
bool make_query=false;
char* f1FileName=NULL;
char* f2FileName=NULL;
bool count_cis_flag = false;
bool count_trans_flag = false;
// for pick up instrument.// inflation, DO NOT USE
bool opt_slct_flag = false;
int meta_mtd = 0; //0 for meta, 1 for mecs
double pmecs = 0.01;
bool extract_cis_only = false;
bool rm_technical = false;
char* prbseqregion = NULL;
double ptech = 5.0e-8;
int addn=-9;
bool shownflag=false;
char* refepiName = NULL;
char* refesiName = NULL;
//for molecular trait
bool cis2all = false;
bool sampleoverlap = false;
int minsnpcor = 2;
// +++++++++++++++++++++++
// OPERA, YW 05.08.2022
// +++++++++++++++++++++++
char* mbFileName=NULL;
char* piFileName=NULL;
char* sigmaFileName=NULL;
char* rhoFileName=NULL;
char* numFilename = NULL;
char* ppaFilename = NULL;
bool bfileflag = false;
bool inputpiflag = false;
bool inputsigmaflag = false;
bool jointsmrflag = true;
bool operasmrflag = false;
bool condismrflag = false;
bool operaflag = false; // to aviod conflict with SMR function
bool inputlociflag = false;
bool printcombppaflag = false;
bool printsmrflag = false;
bool multiexposuresmrflag = true;
bool multioutcomesmrflag = false;
//char* outcomelistFileName=NULL;
char* targetcojosnplstName = NULL;
char* GWAScojosnplstName = NULL;
bool piflag = false;
bool summaryppaflag= false;
double thresh_PP = 0.9;
double thresh_PP_out = 0;
double thresh_smr = 0.05; //0.01; filter probes
double thresh_gwas = 1; //1
double thresh_heidi = 0.01; // thresh_heidi_filter = 1e-6 filter probes
double sigma_def = 0.02;
double alpha_def = 1e-1;
int piWind = 500;
outcomePrbWind = 1000;
string priorstr;
string sigmastr;
// end
double diff_freq = 0.2;
double diff_freq_ratio = 0.05;
int ldWind = 2000;
bool ldr = false;
bool ldr2 = false;
for(int i=0;i<option_num;i++)
{
// Plink files for LD from a reference sample
if(0==strcmp(option_str[i],"--bfile")) {
bFileName=option_str[++i];
FLAG_VALID_CK("--bfile", bFileName);
printf("--bfile %s\n",bFileName);
if(bfileflag)
{
fprintf (stderr, "Error: --bfile conflicts with --mbfile, please turn off one.\n");
exit (EXIT_FAILURE);
}
bfileflag=true;
}
else if(0==strcmp(option_str[i],"--mbfile")) {
mbFileName=option_str[++i];
FLAG_VALID_CK("--mbfile", mbFileName);
printf("--mbfile %s\n",mbFileName);
if(bfileflag)
{
fprintf (stderr, "Error: --mbfile conflicts with --bfile, please turn off one.\n");
exit (EXIT_FAILURE);
}
bfileflag=true;
}
// gwas data file as cojo format
else if(0==strcmp(option_str[i],"--gwas-summary")){
if(gwasFileName ==NULL){
gwasFileName=option_str[++i];
FLAG_VALID_CK("--gwas-summary", gwasFileName);
printf("--gwas-summary %s\n",gwasFileName);
CommFunc::FileExist(gwasFileName);
}else
{
gwasFileName2=option_str[++i];
FLAG_VALID_CK("--gwas-summary", gwasFileName2);
printf("--gwas-summary %s\n",gwasFileName2);
CommFunc::FileExist(gwasFileName2);
}
}
// eQTL files
else if(0==strcmp(option_str[i],"--eqtl-summary")){
if(eqtlFileName==NULL)
{
eqtlFileName=option_str[++i];
FLAG_VALID_CK("--eqtl-summary", eqtlFileName);
printf("--eqtl-summary %s\n",eqtlFileName);
}else{
eqtlFileName2=option_str[++i];
FLAG_VALID_CK("--eqtl-summary", eqtlFileName2);
printf("--eqtl-summary %s\n",eqtlFileName2);
}
}
else if(0==strcmp(option_str[i],"--beqtl-summary")){
bFlag=true;
if(eqtlFileName==NULL)
{
eqtlFileName=option_str[++i];
FLAG_VALID_CK("--beqtl-summary", eqtlFileName);
printf("--beqtl-summary %s\n",eqtlFileName);
}else{
eqtlFileName2=option_str[++i];
FLAG_VALID_CK("--beqtl-summary", eqtlFileName2);
printf("--beqtl-summary %s\n",eqtlFileName2);
}
}
else if(strcmp(option_str[i],"--keep")==0){
indilstName=option_str[++i];
FLAG_VALID_CK("--keep", indilstName);
cout<<"--keep "<<indilstName<<endl;
CommFunc::FileExist(indilstName);
}
else if(strcmp(option_str[i],"--remove")==0){
indilst2remove=option_str[++i];
FLAG_VALID_CK("--remove", indilst2remove);
cout<<"--remove "<<indilst2remove<<endl;
CommFunc::FileExist(indilst2remove);
}
else if(strcmp(option_str[i],"--extract-snp")==0){
snplstName=option_str[++i];
FLAG_VALID_CK("--extract-snp", snplstName);
cout<<"--extract-snp "<<snplstName<<endl;
CommFunc::FileExist(snplstName);
}
else if(strcmp(option_str[i],"--extract-snp-p")==0){
pinsnp=atof(option_str[++i]);
cout<<"--extract-snp-p "<<pinsnp<<endl;
if(pinsnp<0 || pinsnp>1)
{
fprintf (stderr, "Error: --extract-snp-p should be within the range from 0 to 1.\n");
exit (EXIT_FAILURE);
}
}
else if(strcmp(option_str[i],"--exclude-snp-p")==0){
pexsnp=atof(option_str[++i]);
cout<<"--exclude-snp-p "<<pexsnp<<endl;
if(pexsnp<0 || pexsnp>1)
{
fprintf (stderr, "Error: --exclude-snp-p should be within the range from 0 to 1.\n");
exit (EXIT_FAILURE);
}
}
else if(strcmp(option_str[i],"--extract-probe")==0){
problstName=option_str[++i];
FLAG_VALID_CK("--extract-probe", problstName);
cout<<"--extract-probe "<<problstName<<endl;
CommFunc::FileExist(problstName);
}
else if(strcmp(option_str[i],"--extract-exposure-probe")==0){
eproblstName=option_str[++i];
FLAG_VALID_CK("--extract-exposure-probe", eproblstName);
cout<<"--extract-exposure-probe "<<eproblstName<<endl;
CommFunc::FileExist(eproblstName);
}
else if(strcmp(option_str[i],"--extract-outcome-probe")==0){
oproblstName=option_str[++i];
FLAG_VALID_CK("--extract-outcome-probe", oproblstName);
cout<<"--extract-outcome-probe "<<oproblstName<<endl;
CommFunc::FileExist(oproblstName);
}
else if(strcmp(option_str[i],"--exclude-snp")==0){
snplst2exclde=option_str[++i];
FLAG_VALID_CK("--exclude-snp", snplst2exclde);
cout<<"--exclude-snp "<<snplst2exclde<<endl;
CommFunc::FileExist(snplst2exclde);
}
else if(strcmp(option_str[i],"--exclude-probe")==0){
problst2exclde=option_str[++i];
FLAG_VALID_CK("--exclude-probe", problst2exclde);
cout<<"--exclude-probe "<<problst2exclde<<endl;
CommFunc::FileExist(problst2exclde);
}
else if(strcmp(option_str[i],"--exclude-exposure-probe")==0){
eproblst2exclde=option_str[++i];
FLAG_VALID_CK("--exclude-exposure-probe", eproblst2exclde);
cout<<"--exclude-exposure-probe "<<eproblst2exclde<<endl;
CommFunc::FileExist(eproblst2exclde);
}
else if(strcmp(option_str[i],"--exclude-outcome-probe")==0){
oproblst2exclde=option_str[++i];
FLAG_VALID_CK("--exclude-outcome-probe", oproblst2exclde);
cout<<"--exclude-outcome-probe "<<oproblst2exclde<<endl;
CommFunc::FileExist(oproblst2exclde);
}
else if(strcmp(option_str[i],"--maf")==0){
maf=atof(option_str[++i]);
cout<<"--maf "<<maf<<endl;
if(maf<0 || maf>0.5)
{
fprintf (stderr, "Error: --maf should be within the range from 0 to 0.5.\n");
exit (EXIT_FAILURE);
}
}
else if(strcmp(option_str[i],"--make-besd")==0){
make_besd_flag=true;
cout<<"--make-besd "<<endl;
}
else if (0 == strcmp(option_str[i], "--out")){
outFileName = option_str[++i];
if(outFileName !=NULL && has_prefix(outFileName, "--"))
{
outFileName=NULL;
i--;
}else printf("--out %s\n", outFileName);
}
else if (0 == strcmp(option_str[i], "--peqtl-smr")){
p_smr = atof(option_str[++i]);
printf("--peqtl-smr %10.2e\n", p_smr);
if(p_smr<0 || p_smr>1)
{
fprintf (stderr, "Error: --peqtl-smr should be within the range from 0 to 1.\n");
exit (EXIT_FAILURE);
}
}
else if (0 == strcmp(option_str[i], "--peqtl-heidi")){
p_hetero = atof(option_str[++i]);
printf("--peqtl-heidi %10.2e\n", p_hetero);
if(p_hetero<0 || p_hetero>1)
{
fprintf (stderr, "Error: --peqtl-heidi should be within the range from 0 to 1.\n");
exit (EXIT_FAILURE);
}
}
else if (0 == strcmp(option_str[i], "--heidi-min-m")){
m_hetero = atoi(option_str[++i]);
printf("--heidi-min-m %d\n", m_hetero);
}
else if (0 == strcmp(option_str[i], "--heidi-max-m")){
opt_hetero = atoi(option_str[++i]);
printf("--heidi-max-m %d\n", opt_hetero);
}
else if (0 == strcmp(option_str[i], "--heidi-mtd")){
int mtd=atoi(option_str[++i]);
if(mtd==0) new_het_mth=false;
else if(mtd==1) new_het_mth=true;
else {
printf("ERROR: only two HEIDI methold avaliable.\n");
exit(EXIT_FAILURE);
}
printf("--heidi-mtd %d\n", mtd);
}
else if (0 == strcmp(option_str[i], "--smr-multi")){
ssmrflg=true;
printf("--smr-multi \n");
}
else if (0 == strcmp(option_str[i], "--ld-upper-limit")){
ld_prune = atof(option_str[++i]);
printf("--ld-upper-limit %f\n", ld_prune);
if(ld_prune<0 || ld_prune>1)
{
fprintf (stderr, "Error: --ld-upper-limit should be within the range from 0 to 1.\n");
exit (EXIT_FAILURE);
}
}
else if (0 == strcmp(option_str[i], "--ld-multi-snp")){
ld_prune_multi = atof(option_str[++i]);
printf("--ld-multi-snp %f\n", ld_prune_multi);
if(ld_prune_multi<0 || ld_prune_multi>1)
{
fprintf (stderr, "Error: --ld-multi-snp should be within the range from 0 to 1.\n");
exit (EXIT_FAILURE);
}
}
else if (0 == strcmp(option_str[i], "--smr")){
smr_flag=true;
printf("--smr \n");
}
else if (0 == strcmp(option_str[i], "--make-besd-dense")){
make_besd_flag=true;
save_dense_flag=true;
printf("--make-besd-dense \n");
}
else if(strcmp(option_str[i],"--cis-wind")==0){
cis_flag=true;
cis_itvl=atoi(option_str[++i]);
printf("--cis-wind %d Kb\n", cis_itvl);
if(cis_itvl<=0 )
{
fprintf (stderr, "Error: --cis-wind should be over 0.\n");
exit (EXIT_FAILURE);
}
}
else if(strcmp(option_str[i],"--trans-wind")==0){
trans_itvl=atoi(option_str[++i]);
printf("--trans-wind %d Kb\n", trans_itvl);
if(trans_itvl<0 )
{
fprintf (stderr, "Error: --trans-wind should be over 0.\n");
exit (EXIT_FAILURE);
}
}
else if(strcmp(option_str[i],"--peqtl-trans")==0){
transThres=atof(option_str[++i]);
printf("--peqtl-trans %10.2e\n", transThres);
if(transThres<0 || transThres>1)
{
fprintf (stderr, "Error: --peqtl-trans should be within the range from 0 to 1.\n");
exit (EXIT_FAILURE);
}
}
else if(strcmp(option_str[i],"--peqtl-other")==0){
restThres=atof(option_str[++i]);
printf("--peqtl-other %10.2e\n", restThres);
if(restThres<0 || restThres>1)
{
fprintf (stderr, "Error: --peqtl-other should be within the range from 0 to 1.\n");
exit (EXIT_FAILURE);
}
}
else if (0 == strcmp(option_str[i], "--efile")){
eremlFlag=true;
eFileName = option_str[++i];
FLAG_VALID_CK("--efile", eFileName);
printf("--efile %s\n", eFileName);
}
else if (0 == strcmp(option_str[i], "--query")){
lookup_flag=true;
if(i+1==option_num || has_prefix(option_str[i+1],"--")) plookup = 5.0e-8;
else plookup = atof (option_str[++i]);
printf("--query %10.2e\n", plookup);
if(plookup<0 || plookup>1)
{
fprintf (stderr, "Error: --query should be within the range from 0 to 1.\n");
exit (EXIT_FAILURE);
}
}
else if(strcmp(option_str[i],"--genes")==0){
genelistName=option_str[++i];
FLAG_VALID_CK("--genes", genelistName);
cout<<"--genes "<<genelistName<<endl;
CommFunc::FileExist(genelistName);
}
else if(strcmp(option_str[i],"--gene-list")==0){
geneAnnoName=option_str[++i];
FLAG_VALID_CK("--gene-list", geneAnnoName);
cout<<"--gene-list "<<geneAnnoName<<endl;
CommFunc::FileExist(geneAnnoName);
}
else if(strcmp(option_str[i],"--set-list")==0){
setlstName=option_str[++i];
FLAG_VALID_CK("--set-list", setlstName);
cout<<"--set-list "<<setlstName<<endl;
CommFunc::FileExist(setlstName);
}
else if (0 == strcmp(option_str[i], "--target-snp")){
refSNP = option_str[++i];
FLAG_VALID_CK("--target-snp", refSNP);
printf("--target-snp %s\n", refSNP);
}
else if (0 == strcmp(option_str[i], "--heidi-off")){
heidioffFlag = true;
printf("--heidi-off \n");
}
else if(0 == strcmp(option_str[i],"--thread-num")){
thread_num=atoi(option_str[++i]);
printf("--thread-num %d\n", thread_num);
}
else if (0 == strcmp(option_str[i], "--besd-flist")){
combineFlg=true;
eqtlsmaslstName = option_str[++i];
FLAG_VALID_CK("--besd-flist", eqtlsmaslstName);
printf("--besd-flist %s\n", eqtlsmaslstName);
CommFunc::FileExist(eqtlsmaslstName);
}
else if (0 == strcmp(option_str[i], "--plot")){
plotflg = true;
printf("--plot \n" );
}
else if (0 == strcmp(option_str[i], "--trans")){
smr_trans_flag = true;
printf("--trans \n" );
}
else if (0 == strcmp(option_str[i], "--eqtl-flist")){
syllabusName = option_str[++i];
gctaflag = true;
if(syllabusName !=NULL && has_prefix(syllabusName, "--"))
{
syllabusName=NULL;
i--;
}else printf("--eqtl-flist %s\n", syllabusName);
}
else if (0 == strcmp(option_str[i], "--smr-format")){
gctaflag = true;
printf("--smr-format \n" );
}
else if (0 == strcmp(option_str[i], "--plink-qassoc-format")){
plinkflag = true;
gctaflag = false;
printf("--plink-qassoc-format \n" );
}
else if (0 == strcmp(option_str[i], "--gemma-format")){
gemmaflag = true;
gctaflag = false;
printf("--gemma-format \n" );
}
else if (0 == strcmp(option_str[i], "--bolt-assoc-format")){
boltflag = true;
gctaflag = false;
printf("--bolt-assoc-format \n" );
}
else if (0 == strcmp(option_str[i], "--geno-uni")){
genouni = true;
printf("--geno-uni \n" );
}
else if (0 == strcmp(option_str[i], "--merlin-fastassoc-format")){
merlinflag = true;
gctaflag = false;
printf("--merlin-fastassoc-format \n" );
}
else if (0 == strcmp(option_str[i], "--matrix-eqtl-format")){
mateqtlflag = true;
gctaflag = false;
printf("--matrix-eqtl-format \n" );
}
else if (0 == strcmp(option_str[i], "--fastqtl-nominal-format")){
fastqtlnflag = true;
gctaflag = false;
printf("--fastqtl-nominal-format \n" );
}
else if (0 == strcmp(option_str[i], "--fastqtl-permu-format")){
fastqtlpflag = true;
gctaflag = false;
printf("--fastqtl-permu-format \n" );
}
else if(strcmp(option_str[i],"--extract-trait")==0){
traitlstName=option_str[++i];
FLAG_VALID_CK("--extract-trait", traitlstName);
cout<<"--extract-trait "<<traitlstName<<endl;
CommFunc::FileExist(traitlstName);
}
else if(strcmp(option_str[i],"--esd-std")==0){
esdstd=true;
cout<<"--esd-std "<<endl;
}
else if(strcmp(option_str[i],"--update-freq")==0){
freqName=option_str[++i];
FLAG_VALID_CK("--update-freq", freqName);
cout<<"--update-freq "<<freqName<<endl;
CommFunc::FileExist(freqName);
}
else if(strcmp(option_str[i],"--probe-var")==0){
vpFileName=option_str[++i];
FLAG_VALID_CK("--probe-var", vpFileName);
cout<<"--probe-var "<<vpFileName<<endl;
CommFunc::FileExist(vpFileName);
}
else if(strcmp(option_str[i],"--meta")==0){
metaflg=true;
combineFlg=false;
smr_flag=false;
cout<<"--meta "<<endl;
}
else if(0==strcmp(option_str[i],"--mecs")){
metaflg=true;
meta_mtd=1;
printf("--mecs\n");
}
else if(0==strcmp(option_str[i],"--pmecs")){
pmecs=atof(option_str[++i]);
if (pmecs < 0 || pmecs > 1) {
printf("\nError: --pmecs should be between 0 to 1.\n");
exit (EXIT_FAILURE);
}
printf("--pmecs %0.2e\n", pmecs);
}
else if(strcmp(option_str[i],"--smr-wind")==0){
if(smr_trans_flag)
{
trans_itvl=atoi(option_str[++i]);
printf("--smr-wind %d Kb\n", trans_itvl);
if(trans_itvl<0 )
{
fprintf (stderr, "Error: --smr-wind should be over 0.\n");
exit (EXIT_FAILURE);
}
}
else
{
cis_itvl=atoi(option_str[++i]);
printf("--smr-wind %d Kb\n", cis_itvl);
if(cis_itvl<0 )
{
fprintf (stderr, "Error: --smr-wind should be over 0.\n");
exit (EXIT_FAILURE);
}
}
}
else if(strcmp(option_str[i],"--outcome-wind")==0){
outcomePrbWind=atoi(option_str[++i]);
printf("--outcome-wind %d Kb\n", outcomePrbWind);
if(outcomePrbWind<0 )
{
fprintf (stderr, "Error: --outcome-wind should be over 0.\n");
exit (EXIT_FAILURE);
}
}
else if(strcmp(option_str[i],"--set-wind")==0){
setWind=atoi(option_str[++i]);
printf("--set-wind %d kb\n", setWind);
if(setWind<=0 )
{
fprintf (stderr, "Error: --set-wind should be over 0.\n");
exit (EXIT_FAILURE);
}
}
else if(strcmp(option_str[i],"--est-n")==0){
est_effe_spl_size_flg=true;
combineFlg=false;
cout<<"--est-n "<<endl;
}
else if(strcmp(option_str[i],"--internal-test")==0){
interanlflg=true;
cout<<"--internal-test "<<endl;
}
else if(strcmp(option_str[i],"--smr-file")==0){
smrRltFileName=option_str[++i];
FLAG_VALID_CK("--smr-file", smrRltFileName);
cout<<"--smr-file "<<smrRltFileName<<endl;
CommFunc::FileExist(smrRltFileName);
}
else if(strcmp(option_str[i],"--recode")==0){
recodeflg=true;
cout<<"--recode "<<endl;
}
else if(strcmp(option_str[i],"--chr")==0){
char* tmpstr=option_str[++i];
if(strncmp(tmpstr,"X",1)==0) chr=23;
else if(strncmp(tmpstr,"Y",1)==0) chr=24;
else chr=atoi(tmpstr);
FLAG_VALID_CK("--chr", tmpstr);
cout<<"--chr "<<tmpstr<<endl;
}
else if(strcmp(option_str[i],"--probe-chr")==0){
char* tmpstr=option_str[++i];
if(strncmp(tmpstr,"X",1)==0) prbchr=23;
else if(strncmp(tmpstr,"Y",1)==0) prbchr=24;
else prbchr=atoi(tmpstr);
FLAG_VALID_CK("--probe-chr", tmpstr);
cout<<"--probe-chr "<<tmpstr<<endl;
}
else if(strcmp(option_str[i],"--snp-chr")==0){
char* tmpstr=option_str[++i];
if(strncmp(tmpstr,"X",1)==0) snpchr=23;
else if(strncmp(tmpstr,"Y",1)==0) snpchr=24;
else snpchr=atoi(tmpstr);
FLAG_VALID_CK("--snp-chr", tmpstr);
cout<<"--snp-chr "<<tmpstr<<endl;
}
else if (0 == strcmp(option_str[i], "--snp")){
snprs = option_str[++i];
FLAG_VALID_CK("--snp", snprs);
printf("--snp %s\n", snprs);
}
else if (0 == strcmp(option_str[i], "--from-snp")){
fromsnprs = option_str[++i];
FLAG_VALID_CK("--from-snp", fromsnprs);
printf("--from-snp %s\n", fromsnprs);
}
else if (0 == strcmp(option_str[i], "--to-snp")){
tosnprs = option_str[++i];
FLAG_VALID_CK("--to-snp", tosnprs);
printf("--to-snp %s\n", tosnprs);
}
else if (0 == strcmp(option_str[i], "--probe")){
prbname = option_str[++i];
FLAG_VALID_CK("--probe", prbname);
printf("--probe %s\n", prbname);
}
else if (0 == strcmp(option_str[i], "--from-probe")){
fromprbname = option_str[++i];
FLAG_VALID_CK("--from-probe", fromprbname);
printf("--from-probe %s\n", fromprbname);
}
else if (0 == strcmp(option_str[i], "--to-probe")){
toprbname = option_str[++i];
FLAG_VALID_CK("--to-probe", toprbname);
printf("--to-probe %s\n", toprbname);
}
else if(strcmp(option_str[i],"--snp-wind")==0){
snpwindFlag=true;
char* tmpstr=option_str[++i];
if(tmpstr==NULL || SMRDATA::has_prefix(tmpstr, "--")) i--;
else snpWind=atoi(tmpstr);
printf("--snp-wind %d Kb\n", snpWind);
if(snpWind<0 )
{
fprintf (stderr, "Error: --snp-wind should be over 0.\n");
exit (EXIT_FAILURE);
}
}
else if(strcmp(option_str[i],"--probe-wind")==0){
prbwindFlag=true;
char* tmpstr=option_str[++i];
if(tmpstr==NULL || SMRDATA::has_prefix(tmpstr, "--")) i--;
else prbWind=atoi(tmpstr);
printf("--probe-wind %d Kb\n", prbWind);
if(prbWind<0 )
{
fprintf (stderr, "Error: --probe-wind should be over 0.\n");
exit (EXIT_FAILURE);
}
}
else if (0 == strcmp(option_str[i], "--gene")){
genename = option_str[++i];
FLAG_VALID_CK("--gene", genename);
printf("--gene %s\n", genename);
}
else if(strcmp(option_str[i],"--from-snp-kb")==0){
fromsnpkb=atoi(option_str[++i]);
printf("--from-snp-kb %d Kb\n", fromsnpkb);
if(fromsnpkb<0 )
{
fprintf (stderr, "Error: --from-snp-kb should be over 0.\n");
exit (EXIT_FAILURE);
}
}
else if(strcmp(option_str[i],"--to-snp-kb")==0){
tosnpkb=atoi(option_str[++i]);
printf("--to-snp-kb %d Kb\n", tosnpkb);
if(tosnpkb<0 )
{
fprintf (stderr, "Error: --to-snp-kb should be over 0.\n");
exit (EXIT_FAILURE);
}
}
else if(strcmp(option_str[i],"--from-probe-kb")==0){
fromprbkb=atoi(option_str[++i]);
printf("--from-probe-kb %d Kb\n", fromprbkb);
if(fromprbkb<0 )
{
fprintf (stderr, "Error: --from-probe-kb should be over 0.\n");
exit (EXIT_FAILURE);
}
}
else if(strcmp(option_str[i],"--to-probe-kb")==0){
toprbkb=atoi(option_str[++i]);
printf("--to-probe-kb %d Kb\n", toprbkb);
if(toprbkb<0 )
{
fprintf (stderr, "Error: --to-probe-kb should be over 0.\n");
exit (EXIT_FAILURE);
}
}
else if(strcmp(option_str[i],"--extract-single-exposure-probe")==0){
eprobe=option_str[++i];
FLAG_VALID_CK("--extract-single-exposure-probe", eprobe);
cout<<"--extract-single-exposure-probe "<<eprobe<<endl;
}
else if(strcmp(option_str[i],"--extract-single-outcome-probe")==0){
oprobe=option_str[++i];
FLAG_VALID_CK("--extract-single-outcome-probe", oprobe);
cout<<"--extract-single-outcome-probe "<<oprobe<<endl;
}
else if(strcmp(option_str[i],"--exclude-single-exposure-probe")==0){
eprobe2rm=option_str[++i];
FLAG_VALID_CK("--exclude-single-exposure-probe", eprobe2rm);
cout<<"--exclude-single-exposure-probe "<<eprobe2rm<<endl;
}
else if(strcmp(option_str[i],"--exclude-single-outcome-probe")==0){
oprobe2rm=option_str[++i];
FLAG_VALID_CK("--exclude-single-outcome-probe", oprobe2rm);
cout<<"--exclude-single-outcome-probe "<<oprobe2rm<<endl;
}
else if(0==strcmp(option_str[i],"--qfile")){
queryfileflg=true;
queryFileName=option_str[++i];
FLAG_VALID_CK("--qfile", queryFileName);
printf("--qfile %s\n",queryFileName);
}
else if(strcmp(option_str[i],"--diff")==0){
diffflag=true;
cout<<"--diff "<<endl;
}
else if(strcmp(option_str[i],"--beqtl-qc")==0){
qcflag=true;
qcmtd = atoi(option_str[++i]);
if(qcmtd<0 || qcmtd>2)
{
fprintf (stderr, "Error: --beqtl-qc should be 0,1 or 2.\n"); // 1 for SD, 2 for MAD
exit (EXIT_FAILURE);
}
cout<<"--beqtl-qc "<<qcmtd<<endl;
}
else if(strcmp(option_str[i],"--z-thresh")==0){
z_thresh = atoi(option_str[++i]);
if(z_thresh<0 )
{
fprintf (stderr, "Error: --z-thresh should be positive.\n");
exit (EXIT_FAILURE);
}
cout<<"--z-thresh "<<z_thresh<<endl;
}
else if (0 == strcmp(option_str[i], "--psmr")){
threshpsmrest = atof(option_str[++i]);
printf("--psmr %10.2e\n", threshpsmrest);
if(threshpsmrest<0 || threshpsmrest>1)
{
fprintf (stderr, "Error: --psmr should be within the range from 0 to 1.\n");
exit (EXIT_FAILURE);
}
}
else if (0 == strcmp(option_str[i], "--phet")){
threshphet = atof(option_str[++i]);
printf("--phet %10.2e\n", threshphet);
if(threshphet<0 || threshphet>1)
{
fprintf (stderr, "Error: --phet should be within the range from 0 to 1.\n");
exit (EXIT_FAILURE);
}
}
else if(0==strcmp(option_str[i],"--make-query-rug.nl")){
make_query=true;
printf("--make-query-rug.nl %s\n",queryFileName);
}
else if(0==strcmp(option_str[i],"--f1-raw-rug.nl")){
f1FileName=option_str[++i];
FLAG_VALID_CK("--f1-raw-rug.nl", f1FileName);
printf("--f1-raw-rug.nl %s\n",f1FileName);
}
else if(0==strcmp(option_str[i],"--f2-af-rug.nl")){
f2FileName=option_str[++i];
FLAG_VALID_CK("--f2-af-rug.nl", f2FileName);
printf("--f2-af-rug.nl %s\n",f2FileName);
}
else if(0==strcmp(option_str[i],"--count-cis")){
count_cis_flag=true;
printf("--count-cis\n");
}
else if(0==strcmp(option_str[i],"--count-trans")){
count_trans_flag=true;
printf("--count-trans\n");
}
else if(0==strcmp(option_str[i],"--opt-selection")){
opt_slct_flag=true;
printf("--opt-selection\n");
}
else if (0 == strcmp(option_str[i], "--extract-cis")){
extract_cis_only=true;
printf("--extract-cis \n");
}
else if (0 == strcmp(option_str[i], "--rm-technical")){
rm_technical=true;
prbseqregion=option_str[++i];
printf("--rm-technical %s\n",prbseqregion);
}
else if (0 == strcmp(option_str[i], "--p-technical")){
ptech = atof(option_str[++i]);
printf("--p-technical %10.2e\n", p_smr);
if(ptech<0 || ptech>1)
{
fprintf (stderr, "Error: --p-technical should be within the range from 0 to 1.\n");
exit (EXIT_FAILURE);
}
}
else if (0 == strcmp(option_str[i], "--ld-lower-limit")){
ld_min = atof(option_str[++i]);
printf("--ld-lower-limit %f\n", ld_min);
if(ld_min<0 || ld_min>1)
{
fprintf (stderr, "Error: --ld-lower-limit should be within the range from 0 to 1.\n");
exit (EXIT_FAILURE);
}