ZikunY / CARMA

GWAS genetics Fine-mapping method
GNU General Public License v3.0
16 stars 6 forks source link

Installation compilation error #5

Closed hlnicholls closed 1 year ago

hlnicholls commented 1 year ago

Hi, I am very interested in using this package but I'm having issues installing it. Originally I had an error stating fatal error: 'gsl/gsl_vector.h' file not found #include <gsl/gsl_vector.h> which I solved via setting up a symlink on my mac to my gsl include files inside /Users/name/Library/R/arm64/4.3/library/RcppGSL/include (I believe I needed to do this as I have gsl installed via homebrew in /opt/homebrew/Cellar/gsl).

However, I now get this error which I am stuck on:

> devtools::install_github("ZikunY/CARMA")
Downloading GitHub repo ZikunY/CARMA@HEAD
── R CMD build ──────────────────────────────────────────────────────────────────
✔  checking for file ‘/private/var/folders/mp/mm_rrrpj4cj0sf0lspp7vmvm0000gs/T/RtmpXRDSGy/remotes98718e97f9f/ZikunY-CARMA-8df428a/DESCRIPTION’ ...
─  preparing ‘CARMA’:
✔  checking DESCRIPTION meta-information ...
─  cleaning src
─  excluding invalid files
   Subdirectory 'R' contains invalid file names:
     ‘.Rhistory 3’
─  checking for LF line-endings in source and make files and shell scripts
─  checking for empty or unneeded directories
   Removed empty directory ‘CARMA/build’
─  building ‘CARMA_1.0.tar.gz’

Installing package into ‘/Users/name/Library/R/arm64/4.3/library’
(as ‘lib’ is unspecified)
* installing *source* package ‘CARMA’ ...
** using staged installation
** libs
using C++ compiler: ‘Apple clang version 14.0.3 (clang-1403.0.22.14.1)’
using C++11
using SDK: ‘MacOSX13.3.sdk’
clang++ -arch arm64 -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/include -I. -I../inst/include -I'/Users/name/Library/R/arm64/4.3/library/Rcpp/include' -I'/Users/name/Library/R/arm64/4.3/library/RcppArmadillo/include' -I'/Users/name/Library/R/arm64/4.3/library/RcppGSL/include' -I/opt/R/arm64/include    -fPIC  -falign-functions=64 -Wall -g -O2  -c RcppExports.cpp -o RcppExports.o
clang++ -arch arm64 -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/include -I. -I../inst/include -I'/Users/name/Library/R/arm64/4.3/library/Rcpp/include' -I'/Users/name/Library/R/arm64/4.3/library/RcppArmadillo/include' -I'/Users/name/Library/R/arm64/4.3/library/RcppGSL/include' -I/opt/R/arm64/include    -fPIC  -falign-functions=64 -Wall -g -O2  -c cauchy.cpp -o cauchy.o
clang++ -arch arm64 -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/include -I. -I../inst/include -I'/Users/name/Library/R/arm64/4.3/library/Rcpp/include' -I'/Users/name/Library/R/arm64/4.3/library/RcppArmadillo/include' -I'/Users/name/Library/R/arm64/4.3/library/RcppGSL/include' -I/opt/R/arm64/include    -fPIC  -falign-functions=64 -Wall -g -O2  -c cauchy_fixed_sigma.cpp -o cauchy_fixed_sigma.o
clang++ -arch arm64 -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/include -I. -I../inst/include -I'/Users/name/Library/R/arm64/4.3/library/Rcpp/include' -I'/Users/name/Library/R/arm64/4.3/library/RcppArmadillo/include' -I'/Users/name/Library/R/arm64/4.3/library/RcppGSL/include' -I/opt/R/arm64/include    -fPIC  -falign-functions=64 -Wall -g -O2  -c hyper-g.cpp -o hyper-g.o
clang++ -arch arm64 -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/include -I. -I../inst/include -I'/Users/name/Library/R/arm64/4.3/library/Rcpp/include' -I'/Users/name/Library/R/arm64/4.3/library/RcppArmadillo/include' -I'/Users/name/Library/R/arm64/4.3/library/RcppGSL/include' -I/opt/R/arm64/include    -fPIC  -falign-functions=64 -Wall -g -O2  -c hyper-g_fixed_sigma.cpp -o hyper-g_fixed_sigma.o
clang++ -arch arm64 -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/include -I. -I../inst/include -I'/Users/name/Library/R/arm64/4.3/library/Rcpp/include' -I'/Users/name/Library/R/arm64/4.3/library/RcppArmadillo/include' -I'/Users/name/Library/R/arm64/4.3/library/RcppGSL/include' -I/opt/R/arm64/include    -fPIC  -falign-functions=64 -Wall -g -O2  -c inde_normal_fixed_sigma.cpp -o inde_normal_fixed_sigma.o
clang++ -arch arm64 -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/include -I. -I../inst/include -I'/Users/name/Library/R/arm64/4.3/library/Rcpp/include' -I'/Users/name/Library/R/arm64/4.3/library/RcppArmadillo/include' -I'/Users/name/Library/R/arm64/4.3/library/RcppGSL/include' -I/opt/R/arm64/include    -fPIC  -falign-functions=64 -Wall -g -O2  -c normal.cpp -o normal.o
clang++ -arch arm64 -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/include -I. -I../inst/include -I'/Users/name/Library/R/arm64/4.3/library/Rcpp/include' -I'/Users/name/Library/R/arm64/4.3/library/RcppArmadillo/include' -I'/Users/name/Library/R/arm64/4.3/library/RcppGSL/include' -I/opt/R/arm64/include    -fPIC  -falign-functions=64 -Wall -g -O2  -c normal_fixed_sigma.cpp -o normal_fixed_sigma.o
clang++ -arch arm64 -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/include -I. -I../inst/include -I'/Users/name/Library/R/arm64/4.3/library/Rcpp/include' -I'/Users/name/Library/R/arm64/4.3/library/RcppArmadillo/include' -I'/Users/name/Library/R/arm64/4.3/library/RcppGSL/include' -I/opt/R/arm64/include    -fPIC  -falign-functions=64 -Wall -g -O2  -c outlier_cauchy_fixed_sigma.cpp -o outlier_cauchy_fixed_sigma.o
clang++ -arch arm64 -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/include -I. -I../inst/include -I'/Users/name/Library/R/arm64/4.3/library/Rcpp/include' -I'/Users/name/Library/R/arm64/4.3/library/RcppArmadillo/include' -I'/Users/name/Library/R/arm64/4.3/library/RcppGSL/include' -I/opt/R/arm64/include    -fPIC  -falign-functions=64 -Wall -g -O2  -c outlier_inde_normal_fixed_sigma.cpp -o outlier_inde_normal_fixed_sigma.o
clang++ -arch arm64 -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/include -I. -I../inst/include -I'/Users/name/Library/R/arm64/4.3/library/Rcpp/include' -I'/Users/name/Library/R/arm64/4.3/library/RcppArmadillo/include' -I'/Users/name/Library/R/arm64/4.3/library/RcppGSL/include' -I/opt/R/arm64/include    -fPIC  -falign-functions=64 -Wall -g -O2  -c outlier_normal_fixed_sigma.cpp -o outlier_normal_fixed_sigma.o
clang++ -arch arm64 -std=gnu++11 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/opt/R/arm64/lib -o CARMA.so RcppExports.o cauchy.o cauchy_fixed_sigma.o hyper-g.o hyper-g_fixed_sigma.o inde_normal_fixed_sigma.o normal.o normal_fixed_sigma.o outlier_cauchy_fixed_sigma.o outlier_inde_normal_fixed_sigma.o outlier_normal_fixed_sigma.o -L/lib -lgsl -lgslcblas -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
ld: warning: directory not found for option '-L/lib'
ld: library not found for -lgsl
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [CARMA.so] Error 1
ERROR: compilation failed for package ‘CARMA’
* removing ‘/Users/name/Library/R/arm64/4.3/library/CARMA’
Warning message:
In i.p(...) :
  installation of package ‘/var/folders/mp/mm_rrrpj4cj0sf0lspp7vmvm0000gs/T//RtmpXRDSGy/file987130c6a850/CARMA_1.0.tar.gz’ had non-zero exit status

I've tried setting the library path for lgsl by checking my gsl-config and then running:

gsl-config --libs
-L/opt/homebrew/Cellar/gsl/2.7.1/lib -lgsl -lgslcblas
> Sys.setenv(PKG_LIBS = "-L/opt/homebrew/Cellar/gsl/2.7.1/lib -lgsl -lgslcblas")
> devtools::install_github("ZikunY/CARMA")

I've also tried: export LIBRARY_PATH=-/opt/homebrew/Cellar/gsl/2.7.1/lib

However, these output the same error. In general, from googling, I can't find my specific error's solution - is there anything I am missing to install CARMA with my setup?

I'm using an M1 apple mac and my R session is:

> sessionInfo()
R version 4.3.0 (2023-04-21)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Ventura 13.3.1

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib 
LAPACK: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.11.0

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: Europe/London
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
[1] compiler_4.3.0 tools_4.3.0 
ZikunY commented 1 year ago

Hi, thank you for taking an interest in CARMA!

I am positive the installation error is associated with the M1 chip, as CARMA can be installed on Win, Linux, Mac with Intel chip. I experienced the errors with M1 chip before for installing CARMA. Unfortunately, I don't have a M1 apple at hand, but I will try to find one and see if I can work this out.

In the meantime, if you solved the problem, please let me know the solution. It would be a great help. Thanks.

hlnicholls commented 1 year ago

Thank you for your response! I'm keen to run CARMA locally so I'll keep trying to find the M1 solution and let you know if I find one.

In the meantime, I've installed CARMA on a linux OS, and I have a follow-up question if that's ok. I'm running CARMA and getting this error:

CARMA.results<-CARMA_fixed_sigma(z.list,ld.list,lambda.list=lambda.list,
                                 outlier.switch=F)
  set.index gamma.set.index   margin
1         1              NA       NA
2         1             426 1957.626
3         1              NA       NA
[1] "this is running S: 426"
  set.index gamma.set.index    margin
1         1               1     0.000
2         2             346 27803.580
3         3             425  1887.074
[1] "this is running S: 346,426"
  set.index gamma.set.index    margin
1         1               2  1957.626
2         2             424 32094.078
3         3             906  6114.166
[1] "this is running S: 346,425,426"
  set.index gamma.set.index   margin
1         1               2 27803.58
2         2             392 58621.64
3         3            2074 31496.53

...

[1] "this is running S: 346,393,398,402,419,423,425,426,431,436"
  set.index gamma.set.index   margin
1         1               7 125887.6
2         2             398 137111.4
3         3            5402 133102.8
[1] "this is running S: 346,393,398,401,419,423,425,426,431,436"
  set.index gamma.set.index   margin
1         1               7 125887.6
2         2             398 137111.4
3         3            5402 134122.9
[1] "this is running S: 346,393,398,402,419,423,425,426,431,436"
  set.index gamma.set.index   margin
1         1               7 125887.6
2         2             398 137111.4
3         3            5402 133102.8
[1] "this is running S: 346,393,398,401,419,423,425,426,431,436"
[1] 0
[1] "This is locus 1 computing time"
Time difference of 49.86474 secs
[1] "This is difference; 0"
Error in if (sum(pip[cor.group]) > rho) { : 
  missing value where TRUE/FALSE needed

Is there something potentially wrong with my input data that would cause this error? For example, I am just putting in summary statistics but I haven't ran any conditional analysis to refine my SNPs beforehand. The margins also look much larger than the package's simulated example.

ZikunY commented 1 year ago

Hi, thank you for the reply. One thing I notice here is that the outlier detection function has been turned off, which is suggested to be turned on for potential discrepancies. As shown in the second iteration here, it seems like the LD between the two selected SNPs significantly increased the likelihood, which could be due to discrepancies.

Another thing that I noticed is the large values of the input Z-scores. In general, the null Z-scores should follow a standard normal distribution, and the Z-scores with signals should not be greater than 10 more or less. If the loci you are examining here have extremely strong signals, I suggest increasing the prior variance and restricting the total number of causal variant L, such as L=3 etc..

hlnicholls commented 1 year ago

Thank you so much for your response, I really appreciate the guidance. From testing the parameter settings, only changing the tau setting to at least 5 seems to get the function to run without that error - although despite having a SNP with < 5x10-8 p-value the PIPs are all quite low and no SNPs are in the credible set. No SNPs are also in the credible set on running the example simulated data either (running on the example function parameter settings) so not sure if I've got something else wrong too.

From checking my z-scores they seem ok in terms of not being greater than 10 (min value is -8, max value is 4.2, median is 0.16 and mean is -0.2540) but at any rate, I'll investigate this further, and see if the issue is my data.

Thank you again for your help! I'll let you know if I address the M1 issue in the future.

ZikunY commented 1 year ago

Hi,

I have been trying to install CARMA on my M1 Mac, and finally successfully installed CARMA on M1. One difference between what you showed here and what I did is that I added one line in the .R/Makevars file,

"PKG_LIBS=-L/opt/homebrew/lib -lgsl -lgslcblas -lm"

And it fixed the problem. I guess you can also use Sys.setenv function to local the lib. Please give it a try and see if it works.

hlnicholls commented 1 year ago

Hi, this also works for me and I now have CARMA running locally with no issues! Thank you for looking into this further, I really appreciate it!