velocyto.R
velocyto.R copied to clipboard
Problem installing VelocytoR in macOS
Hello
I have tried to install VelocytoR in macOS ( on a MacBook Pro M1 series). But When I run below line I faced with following error :
library(devtools)
install_github("velocyto-team/velocyto.R")
The error appear in R :
clang++ -mmacosx-version-min=10.13 -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/usr/local/lib -o velocyto.R.so RcppExports.o points_within.o routines.o -lboost_filesystem -lboost_system -lstdc++ -L/Library/Frameworks/R.framework/Resources/lib -lRlapack -L/Library/Frameworks/R.framework/Resources/lib -lRblas -L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin18/8.2.0 -L/usr/local/gfortran/lib -lgfortran -lquadmath -lm -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
ld: warning: directory not found for option '-L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin18/8.2.0'
ld: warning: directory not found for option '-L/usr/local/gfortran/lib'
ld: library not found for -lboost_filesystem
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [velocyto.R.so] Error 1
ERROR: compilation failed for package ‘velocyto.R’
How can I fix it !?
Hello,
I got the same issue but managed to fix it by first installing the following packages from CRAN: boostr and hdf5r and then running again library(devtools) install_github("velocyto-team/velocyto.R")
Is this working for you?
Hello. I'm also using the M1 MacBook, and I had spent hours struggling with exactly the same error message with you. I've just solved this problem. I'm not sure if my solution could help you, but give it a try!
- Install
boost
packages using homebrew (Perhaps the problem with-lboost-filesystem
arises because thisboost
package is not installed. )
brew install boost
My boost package was installed in this path : /opt/homebrew/Cellar/boost/
and the version is 1.76.0.
-
Now, you should directly modify the
Makevars
file in this github. Fork this github to your repository. -
In your repo, go to the
src
folder, and open theMakevars
file. At the end of thePKG_LIBS
statement, you should add a path to thelib
directory that exists within the boost package you just installed. So, change theMakevars
file like this.
CXX_STD = CXX11
PKG_CXXFLAGS= $(SHLIB_OPENMP_CXXFLAGS)
PKG_CFLAGS=$(SHLIB_OPENMP_CFLAGS)
PKG_LIBS=-lboost_filesystem -lboost_system -lstdc++ $(LAPACK_LIBS) $(BLAS_LIBS) $(SHLIB_OPENMP_CFLAGS) $(FLIBS) -L /opt/homebrew/Cellar/boost/1.76.0/lib/
- Try again to install the
velocyto.R
using your github repo in the Rstudio.
install_github("ssun1116/velocyto.R")
This is all! Hope this instructions work well 🙏
I fix it by using a process similar to https://github.com/kharchenkolab/conos/wiki/Installing-Conos-for-Mac-OS.
i.e., modify my Makevars
files to the following:
XCBASE:=$(shell xcrun --show-sdk-path)
LLVMBASE:=$(shell brew --prefix llvm)
GCCBASE:=$(shell brew --prefix gcc)
GETTEXT:=$(shell brew --prefix gettext)
CC=$(LLVMBASE)/bin/clang -fopenmp
CXX=$(LLVMBASE)/bin/clang++ -fopenmp
CXX11=$(LLVMBASE)/bin/clang++ -fopenmp
CXX14=$(LLVMBASE)/bin/clang++ -fopenmp
CXX17=$(LLVMBASE)/bin/clang++ -fopenmp
CXX1X=$(LLVMBASE)/bin/clang++ -fopenmp
CPPFLAGS=-isystem "$(LLVMBASE)/include" -isysroot "$(XCBASE)"
LDFLAGS=-L"$(LLVMBASE)/lib" -L"$(GETTEXT)/lib" --sysroot="$(XCBASE)"
FC=$(GCCBASE)/bin/gfortran -fopenmp
F77=$(GCCBASE)/bin/gfortran -fopenmp
FLIBS=-L$(GCCBASE)/lib/gcc/9/ -lm
I am using M1Pro MacBook. I solved this question by combining the methods of ssun1116 and MikaQiao.
1.brew install boost /opt/homebrew/Cellar/boost/(install path)
2.mkdir ~/.R 3.touch Makevars
4.vi Makevars
CXX_STD = CXX11 PKG_CXXFLAGS= $(SHLIB_OPENMP_CXXFLAGS) PKG_CFLAGS=$(SHLIB_OPENMP_CFLAGS) PKG_LIBS=-lboost_filesystem -lboost_system -lstdc++ $(LAPACK_LIBS) $(BLAS_LIBS) $(SHLIB_OPENMP_CFLAGS) $(FLIBS) -L /opt/homebrew/Cellar/boost/1.76.0/lib/
5.install_github("ssun1116/velocyto.R")
Hello. I'm also using the M1 MacBook, and I had spent hours struggling with exactly the same error message with you. I've just solved this problem. I'm not sure if my solution could help you, but give it a try! (I am not really good at English, so it can be a little difficult to understand.)
- Install
boost
packages using homebrew (Perhaps the problem with-lboost-filesystem
arises because thisboost
package is not installed. )brew install boost
My boost package was installed in this path :
/opt/homebrew/Cellar/boost/
and the version is 1.76.0.
- Now, you should directly modify the
Makevars
file in this github. Fork this github to your repository.- In your repo, go to the
src
folder, and open theMakevars
file. At the end of thePKG_LIBS
statement, you should add a path to thelib
directory that exists within the boost package you just installed. So, change theMakevars
file like this.CXX_STD = CXX11 PKG_CXXFLAGS= $(SHLIB_OPENMP_CXXFLAGS) PKG_CFLAGS=$(SHLIB_OPENMP_CFLAGS) PKG_LIBS=-lboost_filesystem -lboost_system -lstdc++ $(LAPACK_LIBS) $(BLAS_LIBS) $(SHLIB_OPENMP_CFLAGS) $(FLIBS) -L /opt/homebrew/Cellar/boost/1.76.0/lib/
- Try again to install the
velocyto.R
using your github repo in the Rstudio.install_github("ssun1116/velocyto.R")
This is all! Hope this instructions work well 🙏
Your solution works very well on my M1 MAC, thanks for sharing it!!!
If you are only installing this package to use the SeuratWrappers vignette on RNA velocity using scVelo link then you only need the read.loom.matrices function, for which the code is below. So just copy that into R studio as a formula and use 'read.loom.matrices' instead of 'ReadVelocity'. You don't need this package for the rest.
read.loom.matrices <- function(file, engine='hdf5r') { if (engine == 'h5'){ cat('reading loom file via h5...\n') f <- h5::h5file(file,mode='r'); cells <- f["col_attrs/CellID"][]; genes <- f["row_attrs/Gene"][]; dl <- c(spliced="/layers/spliced",unspliced="/layers/unspliced",ambiguous="/layers/ambiguous"); if("/layers/spanning" %in% h5::list.datasets(f)) { dl <- c(dl,c(spanning="/layers/spanning")) } dlist <- lapply(dl,function(path) { m <- as(f[path][],'dgCMatrix'); rownames(m) <- genes; colnames(m) <- cells; return(m) }) h5::h5close(f) return(dlist) } else if (engine == 'hdf5r') { cat('reading loom file via hdf5r...\n') f <- hdf5r::H5File$new(file, mode='r') cells <- f[["col_attrs/CellID"]][] genes <- f[["row_attrs/Gene"]][] dl <- c(spliced="layers/spliced", unspliced="layers/unspliced", ambiguous="layers/ambiguous") if("layers/spanning" %in% hdf5r::list.datasets(f)) { dl <- c(dl, c(spanning="layers/spanning")) } dlist <- lapply(dl, function(path) { m <- as(t(f[[path]][,]),'dgCMatrix') rownames(m) <- genes; colnames(m) <- cells; return(m) }) f$close_all() return(dlist) } else { warning('Unknown engine. Use hdf5r or h5 to import loom file.') return(list()) } }
Hello. I'm also using the M1 MacBook, and I had spent hours struggling with exactly the same error message with you. I've just solved this problem. I'm not sure if my solution could help you, but give it a try!
- Install
boost
packages using homebrew (Perhaps the problem with-lboost-filesystem
arises because thisboost
package is not installed. )brew install boost
My boost package was installed in this path :
/opt/homebrew/Cellar/boost/
and the version is 1.76.0.
- Now, you should directly modify the
Makevars
file in this github. Fork this github to your repository.- In your repo, go to the
src
folder, and open theMakevars
file. At the end of thePKG_LIBS
statement, you should add a path to thelib
directory that exists within the boost package you just installed. So, change theMakevars
file like this.CXX_STD = CXX11 PKG_CXXFLAGS= $(SHLIB_OPENMP_CXXFLAGS) PKG_CFLAGS=$(SHLIB_OPENMP_CFLAGS) PKG_LIBS=-lboost_filesystem -lboost_system -lstdc++ $(LAPACK_LIBS) $(BLAS_LIBS) $(SHLIB_OPENMP_CFLAGS) $(FLIBS) -L /opt/homebrew/Cellar/boost/1.76.0/lib/
- Try again to install the
velocyto.R
using your github repo in the Rstudio.install_github("ssun1116/velocyto.R")
This is all! Hope this instructions work well 🙏
Thank you! This solution is good and it works