clivehoggart / BridgePRS

Estimation of trans-ancestry PRS
MIT License
5 stars 1 forks source link

Unbound Local Error when running BridgePRS #6

Open mpkol59 opened 3 days ago

mpkol59 commented 3 days ago

Hello there, Thank you for your great work on this software. I have encountered this error while trying to run BridgePRS using my East Asian and European ancestry data. My command line is as found below as well as the error message:

./bridgePRS tools check-pops -o mytestfulleas --pop EAS EUR --ld_path /path/AFR/CHRMS/1000G/ --sumstats_prefix /path/EAS/CHRMS/eas_chr /path/AFR/CHRMS/eur_chr --sumstats_size 1600 390278 --genotype_prefix /path/EAS/CHRMS/ceas_chr --phenotype_file /path/EAS/CHRMS/myeasphenos2.data

../../bridgePRS pipeline go -o out2 --config_files EAS.target.config EUR.base.config --phenotype y --debug_level 0

################################################################# Traceback (most recent call last): File "/path/BridgePRS/mytestfulleas/save/../../bridgePRS", line 372, in bridgePRS = BridgePRS(mps, sys.argv) ^^^^^^^^^^^^^^^^^^^^^^^^ File "/path/BridgePRS/src/Python/BridgePRS.py", line 27, in init elif self.args.module == 'pipeline': self.easyrun() ^^^^^^^^^^^^^^ File "/path/BridgePRS/src/Python/BridgePRS.py", line 46, in easyrun self.analyze(self.args.cmd, self.args.result_files, PATH = self.io.paths['home']) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/path/BridgePRS/src/Python/BridgePRS.py", line 69, in analyze self.run = BridgeRun(self).analyze(cmd, prs_results, PATH) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/path/BridgePRS/src/Python/Util/BridgeRun.py", line 65, in analyze self.results = [r1[0], r2[0]] + BridgeResult().read_combo(combine) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/path/BridgePRS/src/Python/Util/Bridge_Run/BridgeResult.py", line 40, in read_combo return [BridgeResult('prs-combine', combo.pop, True).add_triple([varexp[0], preds[0], snp_weights[0]]), BridgeResult('prs-weighted', combo.pop, True).add_triple([varexp[1], preds[1], snp_weights[1]])]
^^^^^^ UnboundLocalError: cannot access local variable 'varexp' where it is not associated with a value ##################################################################################

This is confusing since I ran the exact same command for my African and Eur populations and did not get this error. What I noticed is that the PRS-Single stage runs into some error at the beta estimation stage and just continues on to the final stage where the needed files for combining the models are then found missing, hence the error.

I would really appreciate your help with resolving this. Thanks as I look forward to hearing back from you.

Best wishes.

tadesouaiaia commented 3 days ago

Yes you are correct. Would you mind sending us the whole command line printout or the standard errors from inside the prs-single directories?

Thank you,

Tade

On Tue, Oct 22, 2024 at 12:46 PM mpkol59 @.***> wrote:

Hello there, Thank you for your great work on this software. I have encountered this error while trying to run BridgePRS using my East Asian and European ancestry data. My command line is as found below as well as the error message:

./bridgePRS tools check-pops -o mytestfulleas --pop EAS EUR --ld_path /path/AFR/CHRMS/1000G/ --sumstats_prefix /path/EAS/CHRMS/eas_chr /path/AFR/CHRMS/eur_chr --sumstats_size 1600 390278 --genotype_prefix /path/EAS/CHRMS/ceas_chr --phenotype_file /path/EAS/CHRMS/myeasphenos2.data

../../bridgePRS pipeline go -o out2 --config_files EAS.target.config EUR.base.config --phenotype y --debug_level 0

################################################################# Traceback (most recent call last): File "/path/BridgePRS/mytestfulleas/save/../../bridgePRS", line 372, in bridgePRS = BridgePRS(mps, sys.argv) ^^^^^^^^^^^^^^^^^^^^^^^^ File "/path/BridgePRS/src/Python/BridgePRS.py", line 27, in init elif self.args.module == 'pipeline': self.easyrun() ^^^^^^^^^^^^^^ File "/path/BridgePRS/src/Python/BridgePRS.py", line 46, in easyrun self.analyze(self.args.cmd, self.args.result_files, PATH = self.io.paths['home'])

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/path/BridgePRS/src/Python/BridgePRS.py", line 69, in analyze self.run = BridgeRun(self).analyze(cmd, prs_results, PATH) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/path/BridgePRS/src/Python/Util/BridgeRun.py", line 65, in analyze self.results = [r1[0], r2[0]] + BridgeResult().read_combo(combine) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/path/BridgePRS/src/Python/Util/Bridge_Run/BridgeResult.py", line 40, in read_combo return [BridgeResult('prs-combine', combo.pop, True).add_triple([varexp[0], preds[0], snp_weights[0]]), BridgeResult('prs-weighted', combo.pop, True).add_triple([varexp[1], preds[1], snp_weights[1]])] ^^^^^^ UnboundLocalError: cannot access local variable 'varexp' where it is not associated with a value

##################################################################################

This is confusing since I ran the exact same command for my African and Eur populations and did not get this error. What I noticed is that the PRS-Single stage runs into some error at the beta estimation stage and just continues on to the final stage where the needed files for combining the models are then found missing, hence the error.

I would really appreciate your help with resolving this. Thanks as I look forward to hearing back from you.

Best wishes.

— Reply to this email directly, view it on GitHub https://github.com/clivehoggart/BridgePRS/issues/6, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABRCX7TT4RFRUTOV3GYX4WTZ4Z6OFAVCNFSM6AAAAABQM53UZGVHI2DSMVQWIX3LMV43ASLTON2WKOZSGYYDKOJXGM4DMNI . You are receiving this because you are subscribed to this thread.Message ID: @.***>

mpkol59 commented 3 days ago

Thank you very much for your swift response. Here it is:

BridgePRS Begins at Thu Oct 17 13:07:31 2024 Bridge Command-Line: ../../bridgePRS pipeline go -o out2 --config_files EAS.target.config EUR.base.config --phenotype y --debug_level 0 Checking Requirements: System: platform=linux, cores(available)=128, cores(used)=127 Plink: found=false, path=NA (Using included version: /path/BridgePRS/src/Python/Xtra/plink) R: found=true, path=/apps/spack/negishi/apps/r/4.2.2-gcc-12.2.0-524zdta/bin/R, version=4.2.2 (packages=up to date)
Python3: found=true, path=/apps/external/apps/conda/2024.09/bin/python3, matplotlib=false (NOTE: Please Install Matplotlib To Enable Plotting)
Complete Complete

Reading Population Data: Target Data: Names: POP=EAS LDPOP=EAS LD_PATH=/path/AFR/CHRMS/1000G Sumstats: SOURCE_PREFIX=/path/BridgePRS/mytestfulleas/save/sumstats/ss.EAS. SOURCE_SUFFIX=.out.gz SUMSTATS_PREFIX=/path/BridgePRS/mytestfulleas/save/out2/save/sumstats/ss.EAS. SUMSTATS_SUFFIX=.out.gz SUMSTATS_FIELDS=ID,REF,A1,P,BETA SUMSTATS_SIZE=1600 QC-Snps: SNP_FILE=/path/BridgePRS/mytestfulleas/save/snps.eas_valid.txt Genotype/Phenotype: GENOTYPE_PREFIX=/path/EAS/CHRMS/ceas_chr PHENOTYPE_FILE=/path/BridgePRS/mytestfulleas/save/EAS.test_phenos.dat VALIDATION_FILE=/path/BridgePRS/mytestfulleas/save/EAS.valid_phenos.dat CHROMOSOMES=1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22 PHENOTYPE_VARIABLES=y,PC1,PC2,PC3 DECLARED_PHENOTYPE=y **Target Config Made: /path/BridgePRS/mytestfulleas/save/out2/save/EAS.target.config

           Base Data:
               Names: POP=EUR
                      LDPOP=EUR
                      LD_PATH=/path/AFR/CHRMS/1000G
            Sumstats: SOURCE_PREFIX=/path/BridgePRS/mytestfulleas/save/sumstats/ss.EUR.
                      SOURCE_SUFFIX=.out.gz
                      SUMSTATS_PREFIX=/path/BridgePRS/mytestfulleas/save/out2/save/sumstats/ss.EUR.
                      SUMSTATS_SUFFIX=.out.gz
                      SUMSTATS_FIELDS=ID,REF,A1,P,BETA
                      SUMSTATS_SIZE=390278
             QC-Snps: SNP_FILE=/path/BridgePRS/mytestfulleas/save/snps.eas_valid.txt
  Genotype/Phenotype: GENOTYPE_PREFIX=/path/EAS/CHRMS/ceas_chr
                      PHENOTYPE_FILE=/path/EAS/CHRMS/myeasphenos2.data
                      CHROMOSOMES=1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22
                      PHENOTYPE_VARIABLES=y,PC1,PC2,PC3
                      DECLARED_PHENOTYPE=y
**Base Config Made: /path/BridgePRS/mytestfulleas/save/out2/save/EUR.base.config

Setting Program Parameters: Flags: OFF=VERBOSE,RESTART

Begin Module: Stage1: prs-single JOB1: Clumping Pop Data (prs-single clump)..........(Parallelizing Across 127 Cores)......... BridgePipelineWarning: UNKNOWN R-OUTPUT IN STDERR (Program may have failed): ...................................................................................................Complete [File(s) Generated: clump_prefix=out2/prs-single_EAS/clump/EAS_clump] JOB2: Calculating SNP Weights (prs-single beta)...............................................Complete [File(s) Generated: beta_prefix=out2/prs-single_EAS/beta/EAS_beta] JOB3: Generating Polygenic Predictions (prs-single predict).................... BridgePipelineWarning: UNKNOWN R-OUTPUT IN STDERR (Program may have failed): ...................................................................................................Complete [File(s) Generated: predict_prefix=out2/prs-single_EAS/predict/EAS_predict] JOB4: Quantifying PRS Result (prs-single quantify).......................... BridgePipelineWarning: UNKNOWN R-OUTPUT IN STDERR (Program may have failed): ...................................................................................................Complete [File(s) Generated: quantify_prefix=out2/prs-single_EAS/quantify/EAS_quantify] Begin Module: build-model JOB1: Clumping Pop Data (build-model clump).........(Parallelizing Across 127 Cores)..........Complete [File(s) Generated: clump_prefix=out2/build-model_EUR/clump/EUR_clump] JOB2: Calculating SNP Weights (build-model beta)..............................................Complete [File(s) Generated: beta_prefix=out2/build-model_EUR/beta/EUR_beta] JOB3: Generating Polygenic Predictions (build-model predict).................... BridgePipelineWarning: UNKNOWN R-OUTPUT IN STDERR (Program may have failed): ...................................................................................................Complete [File(s) Generated: predict_prefix=out2/build-model_EUR/predict/EUR_predict] JOB4: Saving SNP Priors (build-model prior)...................................................Complete [File(s) Generated: prior_prefix=out2/build-model_EUR/prior/EUR_prior] Begin Module: Stage2: prs-prior Previously Generated: model_file=out2/build-model_EUR/bridge.eur.build-model.result JOB1: Calculating SNP Weights (prs-prior beta).......................... BridgePipelineWarning: UNKNOWN R-OUTPUT IN STDERR (Program may have failed): ...................................................................................................Complete [File(s) Generated: beta_prefix=out2/prs-prior_EAS-EUR/beta/EAS_beta] JOB2: Generating Polygenic Predictions (prs-prior predict).................... BridgePipelineWarning: UNKNOWN R-OUTPUT IN STDERR (Program may have failed): ...................................................................................................Complete [File(s) Generated: predict_prefix=out2/prs-prior_EAS-EUR/predict/EAS_predict] JOB3: Quantifying PRS Result (prs-prior quantify).......................... BridgePipelineWarning: UNKNOWN R-OUTPUT IN STDERR (Program may have failed): ...................................................................................................Complete [File(s) Generated: quantify_prefix=out2/prs-prior_EAS-EUR/quantify/EAS_quantify] Begin Module: analyze JOB1: Combining The Results (analyze combine).................................................Complete Traceback (most recent call last): File "/path/BridgePRS/mytestfulleas/save/../../bridgePRS", line 372, in bridgePRS = BridgePRS(mps, sys.argv) ^^^^^^^^^^^^^^^^^^^^^^^^ File "/path/BridgePRS/src/Python/BridgePRS.py", line 27, in init elif self.args.module == 'pipeline': self.easyrun() ^^^^^^^^^^^^^^ File "/path/BridgePRS/src/Python/BridgePRS.py", line 46, in easyrun self.analyze(self.args.cmd, self.args.result_files, PATH = self.io.paths['home']) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/path/BridgePRS/src/Python/BridgePRS.py", line 69, in analyze self.run = BridgeRun(self).analyze(cmd, prs_results, PATH) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/path/BridgePRS/src/Python/Util/BridgeRun.py", line 65, in analyze self.results = [r1[0], r2[0]] + BridgeResult().read_combo(combine) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/path/BridgePRS/src/Python/Util/Bridge_Run/BridgeResult.py", line 40, in read_combo return [BridgeResult('prs-combine', combo.pop, True).add_triple([varexp[0], preds[0], snp_weights[0]]), BridgeResult('prs-weighted', combo.pop, True).add_triple([varexp[1], preds[1], snp_weights[1]])]
^^^^^^ UnboundLocalError: cannot access local variable 'varexp' where it is not associated with a value