monocle2版本已经弃用,决定安装monocle3,但按照官网流程安装很困难。博主花了一晚上时间终于在两个服务器中安装成功。
基础安装代码(copy自官网 Monocle 3)
conda create -n monocle3
conda activate monocle3
conda install -c conda-forge r-base=4.3.3
which R
进入R环境:
if (!requireNamespace("BiocManager", quietly = TRUE))
install.packages("BiocManager")
BiocManager::install(version = "3.14")
BiocManager::install(c('BiocGenerics', 'DelayedArray', 'DelayedMatrixStats',
'limma', 'lme4', 'S4Vectors', 'SingleCellExperiment',
'SummarizedExperiment', 'batchelor', 'HDF5Array',
'terra', 'ggrastr'))
install.packages("devtools")
devtools::install_github('cole-trapnell-lab/monocle3')
无法用install.packages()安装的包tips:
# 使用conda-forge自动解决依赖问题
conda install -c conda-forge r-<包名>
# 下载包到本地安装
install.packages("./ggrastr_1.0.2.tar.gz", repos = NULL, type = "source")
常见bug:
1. ERROR: dependency ‘Matrix’ is not available for package ‘BiocNeighbors’
解决方法:CRAN下载低版本并本地安装
install.packages("./Matrix_1.5-3.tar.gz", repos = NULL, type = "source")
2. 编译 systemfonts
包时缺少 fontconfig
和 freetype2
依赖库
Package fontconfig was not found in the pkg-config search path. Perhaps you should add the directory containing fontconfig.pc'
to the PKG_CONFIG_PATH environment variable No package 'fontconfig' found Package freetype2 was not found in the pkg-config search path. Perhaps you should add the directory containing freetype2.pc'
to the PKG_CONFIG_PATH environment variable No package 'freetype2' found Using PKG_CFLAGS= Using PKG_LIBS=-lfontconfig -lfreetype
conda install -c conda-forge fontconfig freetype
find $CONDA_PREFIX -name "fontconfig.pc"
find $CONDA_PREFIX -name "freetype2.pc"
export PKG_CONFIG_PATH=$CONDA_PREFIX/lib/pkgconfig:$PKG_CONFIG_PATH
进入R环境设置
Sys.setenv(PKG_CONFIG_PATH = paste0(Sys.getenv("CONDA_PREFIX"), "/lib/pkgconfig:", Sys.getenv("PKG_CONFIG_PATH")))
install.packages("systemfonts")
3. 系统中缺少 libxml2
库导致的,它是 xml2
包安装的必要依赖
Package libxml-2.0 was not found in the pkg-config search path. Perhaps you should add the directory containing libxml-2.0.pc'
to the PKG_CONFIG_PATH environment variable No package 'libxml-2.0' found Package libxml-2.0 was not found in the pkg-config search path. Perhaps you should add the directory containing libxml-2.0.pc'
to the PKG_CONFIG_PATH environment variable No package 'libxml-2.0' found Using PKG_CFLAGS= Using PKG_LIBS=-lxml2
conda install -c conda-forge libxml2
export PKG_CONFIG_PATH="$CONDA_PREFIX/lib/pkgconfig:$PKG_CONFIG_PATH"
install.packages("xml2")
4. 其他小问题,大部分用conda-forge 就能解决
conda install -c conda-forge r-devtools
conda install -c conda-forge r-lme4 r-sf r-spdep
conda install -c conda-forge cmake
conda install -c conda-forge r-nloptr
conda install -c conda-forge udunits2
见招拆招即可。