getian107 / PRScsx

Cross-population polygenic prediction
MIT License
69 stars 20 forks source link

UnboundLocalError: cannot access local variable 'ref_dict' where it is not associated with a value #57

Closed YangRT11 closed 3 weeks ago

YangRT11 commented 3 weeks ago

Hi, the reference file doesn't seem to be called when I run the test file, I have placed the folders ldblk_1kg_eur, ldblk_1kg_eas and the snpinfo_mult_1kg_hm3.txt under the 1000G_sample file. But after running the code it still reports an error.Is there something wrong with my code or my reference file? Is it possible to show in detail the format of the correct reference document and the code?

My code: python PRScsx.py --ref_dir=./1000G_sample --bim_prefix=./test_data/test --sst_file=./test_data/EUR_sumstats.txt,./test_data/EAS_sumstats.txt --n_gwas=200000,100000 --pop=EUR,EAS --chrom=22 --phi=1e-2 --out_dir=./output --out_name=test

My bash: --ref_dir=./1000G_sample --bim_prefix=./test_data/test --sst_file=['./test_data/EUR_sumstats.txt', './test_data/EAS_sumstats.txt'] --a=1 --b=0.5 --phi=0.01 --n_gwas=[200000, 100000] --pop=['EUR', 'EAS'] --n_iter=2000 --n_burnin=1000 --thin=5 --out_dir=./output --out_name=test --chrom=['22'] --meta=FALSE --seed=None

2 discovery populations detected

process chromosome 22

... parse bim file: ./test_data/test.bim ... ... 1000 SNPs on chromosome 22 read from ./test_data/test.bim ... Traceback (most recent call last): File "/Users/buchiyu/Desktop/博士/博士论文/毕业课题/毕业论文/GWAS/PRS-CSx/PRScsx/PRScsx.py", line 154, in main() File "/Users/buchiyu/Desktop/博士/博士论文/毕业课题/毕业论文/GWAS/PRS-CSx/PRScsx/PRScsx.py", line 137, in main sst_dict[pp] = parse_genet.parse_sumstats(ref_dict, vld_dict, param_dict['sst_file'][pp], param_dict['pop'][pp], param_dict['n_gwas'][pp]) ^^^^^^^^ UnboundLocalError: cannot access local variable 'ref_dict' where it is not associated with a value

getian107 commented 3 weeks ago

The command line looks good to me. I'd try using the full, absolute path. If that doesn't fix the problem, could you take a snapshot of the files in the '1000G_sample' so I can take a look?

YangRT11 commented 3 weeks ago

Hi, Thank you so much! I have solved the problem, I found that the snpinfo_mult_1kg_hm3.txt format is not working, only snpinfo_mult_1kg_hm3 works fine!