jrs95 / hyprcoloc

Hypothesis Prioritisation in multi-trait Colocalization
https://jrs95.github.io/hyprcoloc/
GNU General Public License v3.0
46 stars 12 forks source link

Installation method for ARM chip on Macbook #33

Open laleoarrow opened 3 months ago

laleoarrow commented 3 months ago

After several days of struggling to install hyprcoloc on my Macbook, I finally find out why it cannot be installed normally. It turns out that MacOS does not include default libraries for r-package compilation. You need to manually install X-code for it, and for more complex packages (like this one), the GNU Fortran compiler (https://mac.r-project.org/tools/) is also required!

Here is the warpped up solution for installing hyprcoloc.

Step 1: (Ref: https://zhuanlan.zhihu.com/p/111748325)

brew install gcc
# or
brew reinstall gcc

if necessary, create a directory for R to know where the gfortran are at. In my case,

ls *libgfortran*        
libgfortran.5.dylib libgfortran.a       libgfortran.dylib   libgfortran.spec
pwd
/opt/homebrew/opt/gcc/lib/gcc/14

sudo mkdir -p /opt/gfortran/lib/gcc/aarch64-apple-darwin20.0/12.2.0
# sudo mkdir -p /opt/gfortran/lib
sudo cp /opt/homebrew/opt/gcc/lib/gcc/14/libgfortran.* /opt/gfortran/lib/gcc/aarch64-apple-darwin20.0/12.2.0

Step 2: add gfortran also to your Makevars file. (Ref: https://github.com/xzhoulab/SPARK/issues/12)

which gfortran # /opt/homebrew/bin/gfortran in my case
mkdir -p ~/.R  
nano ~/.R/Makevars # or use vi

Then add this to it

FC = /opt/homebrew/bin/gfortran
F77 = /opt/homebrew/bin/gfortran
FLIBS = -L/opt/homebrew/lib/gcc/14 -lgfortran -lquadmath -lm

Note that your gcc version could be different from my case, so make sure to change it correctly.

Step 3: Then, install the RcppEigen (version 0.3.3.9.3) manually or as instructed by the main page. In my case, I installed it manually. RcppEigen_0.3.3.9.3.tar.gz

install.packages("~/Documents/tmp/RcppEigen_0.3.3.9.3.tar.gz", repos = NULL, type = "source")
# Then finally is successfully installed it! Congrats!
install_github("cnfoley/hyprcoloc", build_opts = c("--resave-data", "--no-manual"), build_vignettes = TRUE)