MRCIEU / ieugwasr

R interface to the IEU GWAS database API
https://mrcieu.github.io/ieugwasr/
Other
67 stars 23 forks source link

ld_clump error: Error in file(file, "rt") : cannot open the connection #44

Open jdbusby opened 6 months ago

jdbusby commented 6 months ago

I am trying to clump locally via the ld_clump funciton:

Here is my code:

 IndeSNP=ld_clump(dplyr::tibble(rsid=dat$SNP, pval=dat$pval.exposure, id=dat$id.exposure),
               plink_bin= genetics.binaRies::get_plink_binary(),
               bfile="~/Research Project/plink/EUR",
               clump_r2=r2forClump)

and I receive the following error:

              Clumping jk7zwD, 21760 variants, using EUR population reference
              PLINK v1.90b7.1 64-bit (18 Oct 2023)           www.cog-genomics.org/plink/1.9/
              (C) 2005-2023 Shaun Purcell, Christopher Chang   GNU General Public License v3
              Logging to C:\Users\jbusby\AppData\Local\Temp\RtmpslJTJN\file1f05a452051.log.
              Options in effect:
                --bfile ~/Research Project/plink/EUR
                --clump C:\Users\jbusby\AppData\Local\Temp\RtmpslJTJN\file1f05a452051
                --clump-kb 10000
                --clump-p1 0.99
                --clump-r2 0.01
                --out C:\Users\jbusby\AppData\Local\Temp\RtmpslJTJN\file1f05a452051

              32420 MB RAM detected; reserving 16210 MB for main workspace.
              Clumping jk7zwD, 21760 variants, using EUR population reference
                Error in file(file, "rt") : cannot open the connection
                In addition: Warning message:
                In file(file, "rt") :
                  cannot open file 'C:\Users\jbusby\AppData\Local\Temp\RtmpslJTJN\file1f07f892de2.clumped': No such file or directory

I have tried to run other solutions I have seen on this site, including setting my wd to the EUR file locaiton but nothing seems to work. Any ideas on how to resolve?

remlapmot commented 6 months ago

I don't know, but given you are on Windows I'm not that keen on how you have specified your bfile argument,

bfile="~/Research Project/plink/EUR"

I would edit in 2 ways; I can't remember whether ~ expansion works on Windows so remove that, i.e., specufy full file path; and also you have a space in the file path, which is usually a bad idea, so put on one without a space.

helenaurquijo commented 5 months ago

I'm having the same issue with the ld_clump_local() function; I'm on linux, have no spaces in my paths and have used the bfile location successfully in the past for the generation of LD matrices using the ld_matrix_local() function.

greengarden0925 commented 4 months ago

I am trying to clump locally via the ld_clump funciton:

Here is my code:

 IndeSNP=ld_clump(dplyr::tibble(rsid=dat$SNP, pval=dat$pval.exposure, id=dat$id.exposure),
               plink_bin= genetics.binaRies::get_plink_binary(),
               bfile="~/Research Project/plink/EUR",
               clump_r2=r2forClump)

and I receive the following error:

              Clumping jk7zwD, 21760 variants, using EUR population reference
              PLINK v1.90b7.1 64-bit (18 Oct 2023)           www.cog-genomics.org/plink/1.9/
              (C) 2005-2023 Shaun Purcell, Christopher Chang   GNU General Public License v3
              Logging to C:\Users\jbusby\AppData\Local\Temp\RtmpslJTJN\file1f05a452051.log.
              Options in effect:
                --bfile ~/Research Project/plink/EUR
                --clump C:\Users\jbusby\AppData\Local\Temp\RtmpslJTJN\file1f05a452051
                --clump-kb 10000
                --clump-p1 0.99
                --clump-r2 0.01
                --out C:\Users\jbusby\AppData\Local\Temp\RtmpslJTJN\file1f05a452051

              32420 MB RAM detected; reserving 16210 MB for main workspace.
              Clumping jk7zwD, 21760 variants, using EUR population reference
                Error in file(file, "rt") : cannot open the connection
                In addition: Warning message:
                In file(file, "rt") :
                  cannot open file 'C:\Users\jbusby\AppData\Local\Temp\RtmpslJTJN\file1f07f892de2.clumped': No such file or directory

I have tried to run other solutions I have seen on this site, including setting my wd to the EUR file locaiton but nothing seems to work. Any ideas on how to resolve?

You could try to download the "plink.exe" from "https://www.cog-genomics.org/plink/" and choose the build that fits your OS. Place the "plink.exe" in your working directory and assign plink_bin=".\plink.exe". You should change your bfile="~/Research Project/plink/EUR" to bfile="./Research Project/plink/EUR".Rerunning the scripts to see if they work or not. It worked for me.

This error happened for the reason of that the function "ld_clump_local" within "ld_clump" takes plink codes to run the clumping. The plink code from my analaysis looks like, "./plink_win64_20231211/plink.exe" --bfile "Data\1000genomeLDreference\EUR" --clump "C:\Users\miler\AppData\Local\Temp\Rtmp46wYQI\file3bac27f6d88" --clump-p1 0.99 --clump-r2 0.001 --clump-kb 10000 --out "C:\Users\miler\AppData\Local\Temp\Rtmp46wYQI\file3bac27f6d88". If you assign the "plink_bin" or "bfile" with the wrong file path format, it would came up with the error. I hope this suggestion would be helpful. Good luck.