getian107 / PRScsx

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

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

Closed nzernov01 closed 11 months ago

nzernov01 commented 1 year ago

Hello, I am trying to run PRScsx test by command as follow:

python PRScsx.py --ref_dir=/home/nzernov/med_partners/LRC/prscsx/reference_dir/UK_biobank --bim_prefix=/home/nzernov/med_partners/LRC/prscsx/PRScsx/test_data/test --sst_file=/home/nzernov/med_partners/LRC/prscsx/PRScsx/test_data/EUR_sumstats.txt --n_gwas=200000 --pop=EUR --out_dir=/home/nzernov/med_partners/LRC/prscsx/prscsx_results --out_name=test_LRC_posterior_effect_size --chrom=22 but keep getting the same error:

--ref_dir=/home/nzernov/med_partners/LRC/prscsx/reference_dir/UK_biobank
--bim_prefix=/home/nzernov/med_partners/LRC/prscsx/PRScsx/test_data/test
--sst_file=['/home/nzernov/med_partners/LRC/prscsx/PRScsx/test_data/EUR_sumstats.txt']
--a=1
--b=0.5
--phi=None
--n_gwas=[200000]
--pop=['EUR']
--n_iter=1000
--n_burnin=500
--thin=5
--out_dir=/home/nzernov/med_partners/LRC/prscsx/prscsx_results
--out_name=test_LRC_posterior_effect_size
--chrom=['22']
--meta=FALSE
--seed=None

*** only 1 discovery population detected ***

##### process chromosome 22 #####
... parse bim file: /home/nzernov/med_partners/LRC/prscsx/PRScsx/test_data/test.bim ...
... 1000 SNPs on chromosome 22 read from /home/nzernov/med_partners/LRC/prscsx/PRScsx/test_data/test.bim ...
Traceback (most recent call last):
  File "/home/nzernov/med_partners/LRC/prscsx/PRScsx/PRScsx.py", line 154, in <module>
    main()
  File "/home/nzernov/med_partners/LRC/prscsx/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

Could you please explain what is going wrong? Thank you in advance!

getian107 commented 1 year ago

Could you double check that you have population-specific reference panels (specifically snpinfo_mult_ukbb_hm3 and ldblk_ukbb_eur) under /home/nzernov/med_partners/LRC/prscsx/reference_dir/UK_biobank

Also if you only have one set of summary statistics you can use PRS-CS, although PRS-CSx should be mathematically equivalent to PRS-CS when there is only input from a single population.

nzernov01 commented 1 year ago

Here is content of the /UK_biobankdirectory:

ls -F /home/nzernov/med_partners/LRC/prscsx/reference_dir/UK_biobank
'ldblk_ukbb_afr.tar.gz?dl=0'  'ldblk_ukbb_eas.tar.gz?dl=0'  'ldblk_ukbb_eur.tar.gz?dl=0'  'snpinfo_mult_ukbb_hm3?dl=0'
'ldblk_ukbb_amr.tar.gz?dl=0'   ldblk_ukbb_eur/              'ldblk_ukbb_sas.tar.gz?dl=0'

I've tried to move the 'snpinfo_mult_ukbb_hm3?dl=0' file to the ldblk_ukbb_eur/ directory, but it doesn't work. The same error occured. Maybe I'm missing some file?

Also I've tried to test the PRS-CS by the following command:

PRScs.py \
--ref_dir=/home/nzernov/med_partners/LRC/prscsx/reference_dir/UK_biobank/ldblk_ukbb_eur \
--bim_prefix=/home/nzernov/med_partners/LRC/prscsx/PRScsx/test_data/test \
--sst_file=/home/nzernov/med_partners/LRC/prscsx/PRScsx/test_data/EUR_sumstats.txt \
--n_gwas=200000 \
--chrom=22 \
--out_dir=/home/nzernov/med_partners/LRC/prscs/prscs_results

It works! Thank you for the suggestion to use PRS-CS in case of one set of summary statistics.

getian107 commented 1 year ago

Great - if you want to get PRS-CSx working in the future when you have more than one set of summary statistics:

The download for those files with "?dl=0" at the end of the filename didn't seem to be complete. You might want to try downloading again.