infercnv 包的安裝依賴于rjags,rjags包依賴于JAGS庫文件朱庆,因此榨惠,首先需要安裝JAGS。
windows 安裝
1憾赁、下載應(yīng)用程序 JAGS-4.3.0.exe, 直接安裝就行
2污朽、安裝rjags以及infercnv,注意一下R版本安裝沒什么問題
BiocManager::install("rjags")
BiocManager::install("infercnv")
linux 安裝
1龙考、首先安裝依賴的 JAGS
通過 conda 安裝
$ conda install pkg-configure jags # 如果conda連接不了試著改一下鏡像源
$ pkg-config --modversion jags # 測試jags安裝
4.3.0
$ll /home/usrname/miniconda3/lib/JAGS/modules-4/ #查看JAGS庫
total 1856
-rwxrwxr-x 2 181320 Oct 18 15:24 basemod.so
-rwxrwxr-x 2 559312 Oct 18 15:24 bugs.so
-rwxrwxr-x 2 74656 Oct 18 15:24 dic.so
-rwxrwxr-x 2 870784 Oct 18 15:24 glm.so
-rwxrwxr-x 2 33504 Oct 18 15:24 lecuyer.so
-rwxrwxr-x 2 127072 Oct 18 15:24 mix.so
-rwxrwxr-x 2 35008 Oct 18 15:24 msm.so
或者使用源碼安裝
$ mkdir /share/nas1/usrname/Softwares/JAGS-4.3.0
$ tar -zxf ./jags_4.3.0.orig.tar.gz
$ cd ./JAGS-4.3.0
$ ./configure --prefix=/share/nas1/usrname/Softwares/JAGS-4.3.0/ --libdir=/share/nas1/usrname/Softwares/JAGS-4.3.0/lib64
$ make
$ make install
$ ll /share/nas1/usrname/Softwares/JAGS-4.3.0
total 160
drwxr-xr-x 2 22 Jan 8 16:18 bin
drwxr-xr-x 3 22 Jan 8 16:18 include
drwxr-xr-x 4 297 Jan 8 16:18 lib64
drwxr-xr-x 2 31 Jan 8 16:18 libexec
drwxr-xr-x 3 21 Jan 8 16:18 share
2蟆肆、安裝 rjags 包
需要配置環(huán)境矾睦,否則安裝 rjags 是會提示報錯。
# 配置環(huán)境變量
$ export PKG_CONFIG_PATH=/home/usrname/miniconda3/bin/pkg-config
$ export LD_LIBRARY_PATH=/home/usrname/miniconda3/lib/JAGS:$LD_LIBRARY_PATH
$ export LD_LIBRARY_PATH=/home/usrname/miniconda3/lib:$LD_LIBRARY_PATH
$ source ~/.bashrc
啟動R窗口炎功,檢查環(huán)境
> Sys.getenv("LD_LIBRARY_PATH") # 存在JAGS庫路徑
[1] "/share/nas2/genome/biosoft/R/3.6.1/lib64/R/lib:/usr/local/lib64:/usr/java/latest/jre/lib/amd64/server:/home/usrname/miniconda3/lib:/home/usrname/miniconda3/lib/JAGS:/home/usrname/mysql:/share/nas2/genome/biosoft/hdf5/current/lib/:....(省略)"
安裝 rjags 包
# R窗口安裝
install.packages('rjags', configure.args='--with-jags-include=/share/nas1/usrname/Softwares/JAGS-4.3.0/include/JAGS --with-jags-lib=/share/nas1/usrname/Softwares/JAGS-4.3.0/lib64/JAGS --with-jags-modules=/share/nas1/usrname/Softwares/JAGS-4.3.0//lib64/JAGS/modules-4 --with-jags-bin=/share/nas1/usrname/Softwares/JAGS-4.3.0//bin')
# 命令行安裝
$ R CMD INSTALL --configure-args='--enable-rpath' /share/nas1/usrname/rjags_4-4.tar.gz
哭死枚冗,到這里還是發(fā)生error (https://sourceforge.net/p/mcmc-jags/discussion/610037/thread/cb37075f/) ,懷疑是環(huán)境配置問題蛇损,但是不清楚怎么解決(暴風(fēng)式哭泣(灬? ?灬))
gcc -std=gnu99 -I"/share/nas2/genome/biosoft/R/3.6.1/lib64/R/include" -DNDEBUG -I/home/usrname/miniconda3/include/JAGS -I/usr/local/include -fpic -g -O2 -c init.c -o init.o
g++ -std=gnu++11 -I"/share/nas2/genome/biosoft/R/3.6.1/lib64/R/include" -DNDEBUG -I/home/usrname/miniconda3/include/JAGS -I/usr/local/include -fpic -g -O2 -c jags.cc -o jags.o
g++ -std=gnu++11 -I"/share/nas2/genome/biosoft/R/3.6.1/lib64/R/include" -DNDEBUG -I/home/usrname/miniconda3/include/JAGS -I/usr/local/include -fpic -g -O2 -c parallel.cc -o parallel.o
g++ -std=gnu++11 -shared -L/share/nas2/genome/biosoft/R/3.6.1/lib64/R/lib -L/usr/local/lib64 -o rjags.so init.o jags.o parallel.o -L/home/usrname/miniconda3/lib -ljags -L/share/nas2/genome/biosoft/R/3.6.1/lib64/R/lib -lR
installing to /home/usrname/R/x86_64-pc-linux-gnu-library/3.6/00LOCK-rjags/00new/rjags/libs
** R
** data
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded from temporary location
Error: package or namespace load failed for ‘rjags’:
.onLoad failed in loadNamespace() for 'rjags', details:
call: dyn.load(file, DLLpath = DLLpath, ...)
error: unable to load shared object '/home/usrname/R/x86_64-pc-linux-gnu-library/3.6/00LOCK-rjags/00new/rjags/libs/rjags.so':
/home/usrname/R/x86_64-pc-linux-gnu-library/3.6/00LOCK-rjags/00new/rjags/libs/rjags.so: undefined symbol: _ZN4jags7Console12unloadModuleERKSs
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/home/usrname/R/x86_64-pc-linux-gnu-library/3.6/rjags’
# 報錯
> library(rjags)
Error: package or namespace load failed for ‘rjags’:
.onLoad failed in loadNamespace() for 'rjags', details:
call: load.module("basemod", quiet = TRUE)
error: File not found: /share/nas2/genome/biosoft/R/3.6.1/lib64/R/../JAGS/modules-4/basemod.so
當(dāng)修改 export LD_LIBRARY_PATH=/share/nas1/usrname/Softwares/JAGS-4.3.0/lib64 后赁温,又出現(xiàn)下面的錯誤:
> library(rjags)
Loading required package: coda
Error: package or namespace load failed for ‘rjags’:
.onLoad failed in loadNamespace() for 'rjags', details:
call: dyn.load(file, DLLpath = DLLpath, ...)
error: unable to load shared object '/share/nas1/usrname/packages/3.6/rjags/libs/rjags.so':
/share/nas1/usrname/packages/3.6/rjags/libs/rjags.so: undefined symbol: _ZN4jags7Console10setRNGnameERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEj
發(fā)現(xiàn)確實是 JAGS 跟R 的運行環(huán)境問題,如果是root權(quán)限用戶安裝會輕松很多淤齐,最后還是成功安裝上了股囊。
> library(rjags)
Linked to JAGS 4.3.0
Loaded modules: basemod,bugs
3、加載infercnv
> BiocManager::install("infercnv")
> library(infercnv)