1、下载Seurat包:
https://cran.r-project.org/web/packages/Seurat/index.html
https://cran.r-project.org/src/contrib/Seurat_4.4.0.tar.gz
2、
install.packages("Seurat_4.4.0.tar.gz",lib="/Rlibrary",repo=NULL,type="source")
提示报错
ERROR: dependencies ‘leiden’, ‘png’, ‘reticulate’ are not available for package ‘Seurat’
- removing ‘/mnt/lipeiting/Rlibrary/Seurat’
Warning message:
In install.packages("Seurat_4.4.0.tar.gz", lib = "/mnt/lipeiting/Rlibrary", :
根据报错,我们知道‘leiden’, ‘png’, ‘reticulate’三个依赖包需要被安装
install.packages("leiden",lib="/Rlibrary",repo=NULL,type="source")
install.packages("png",lib="/Rlibrary",repo=NULL,type="source")
install.packages("reticulate",lib="/Rlibrary",repo=NULL,type="source")
之后再次安装
install.packages("Seurat_4.4.0.tar.gz",lib="/Rlibrary",repo=NULL,type="source")
提示报错:Error: C++17 standard requested but CXX17 is not defined
退出R,在终端操作
$ mkdir -p ~/.R
$ echo 'CXX17 = g++ -std=c++17 -fPIC' > ~/.R/Makevars
再转到,再次尝试安装
install.packages("Seurat_4.4.0.tar.gz",lib="/Rlibrary",repo=NULL,type="source")R
subset.AnchorSet html
** building package indices
** testing if installed package can be loaded from temporary location
** checking absolute paths in shared objects and dynamic libraries
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
- DONE (Seurat)
安装成功
library(Seurat)
提示报错,找不到这个R包
将我的安装路径添加到R的.Rprofile中即可
在R下操作
.libPaths() #查看已有的路径
file.edit(file.path("~", ".Rprofile")) #打开.Rprofile
添加一行:.libPaths(c(.libPaths(), "/your/new/path")) (文件编辑方法:按i,输入内容,按ESC键,输入:wq)
退出R,然后再次进入,重新查看.libPaths(),然后再次载入library(Seurat) 成功