首先按照官网上的代码进行安装
devtools::install_github('cole-trapnell-lab/leidenbase')
devtools::install_github('cole-trapnell-lab/monocle3')
在最后一步安装运行以上两行代码时出现了问题:
checking udunits2.h usability... no
checking udunits2.h presence... no
checking for udunits2.h... no
checking udunits2/udunits2.h usability... no
checking udunits2/udunits2.h presence... no
checking for udunits2/udunits2.h... no
checking for ut_read_xml in -ludunits2... no
configure: error: in `/tmp/RtmphiMa1k/R.INSTALL23ef48d1156/units':
configure: error:
使用yum在CentOS7上运行:
sudo yum install udunits2-devel
仍然报错:
没有可用软件包 udunits2-devel。
yum没有找到对应依赖包,更新epel第三方软件库,运行命令:
yum install -y epel-release
然后再在terminal和R中分别执行以下两行代码就可以了:
sudo yum install udunits2-devel
install.packages(units)
继续安装monocle3,又报错:
* installing *source* package ‘sf’ ...
** package ‘sf’ successfully unpacked and MD5 sums checked
** using staged installation
configure: CC: gcc -std=gnu99
configure: CXX: g++ -std=gnu++11
checking for gdal-config... no
no
configure: error: gdal-config not found or not executable.
ERROR: configuration failed for package ‘sf’
* removing ‘/local/txm/R/x86_64-pc-linux-gnu-library/4.0/sf’
Warning in install.packages :
installation of package ‘sf’ had non-zero exit status
提示sf包安装失败,原因是gdal没有安装,在terminal里面执行
sudo yum install gdal gdal-devel
发现yum最高只能安装1.11.4的gdal,于是尝试手动安装,参考以下博客:https://www.jianshu.com/p/3173513d16a5
geos,proj等包的安装都比较顺利,唯独gdal要么是装不上,要么是装上之后sf还是无法安装,折腾这玩意儿花了劳资3天的时间,参考了无数博客,最后成功的代码如下:
# 在terminal里安装gdal2.4.4
tar -zxvf gdal-2.4.4.tar.gz
cd gdal-2.4.4
./configure --with-gdal-ver=T --prefix=/usr/local --with-geos=/usr/local/bin # 将软件安装在/usr/local
make
sudo make install
ldconfig
/usr/local/bin/gdalinfo --version # GDAL 2.4.4, released 2020/01/08 表明安装成功
# 设置环境变量PKG_CONFIG_PATH
vi ~/.bash_profile
# 在末尾添加下面两行:
PKG_CONFIG_PATH=/usr/lib/pkgconfig:/usr/local/lib/pkgconfig
export PKG_CONFIG_PATH
# 最后重启bash,让环境变量生效:
source ~/.bash_profile
最后,在R中安装sf包和monocle3
install.packages("sf", configure.args = "--with-gdal-config=/usr/local/bin/gdal-config --with-proj-include=/usr/local/include/ --with-proj-lib=/usr/local/lib/")
library(devtools)
devtools::install_github('cole-trapnell-lab/monocle3')
参考
https://stackoverflow.com/questions/50362201/udunits2-r-install-udunits2-h-not-found
https://blog.csdn.net/qq_46480020/article/details/111940512
https://www.omicsclass.com/article/1349
https://github.com/r-spatial/sf/issues/1158