monocle对轨迹分支进行基因差异分析时占用内存非常大,且计算时间超长,仅对8000细胞进行分析就耗费4-5h,需要在服务器进行monocle轨迹。服务器是基于Linux系统的,对于非root用户或系统版本较低来说安装R是非常麻烦的,因此可以通过安装conda,创建虚拟环境,再安装R,然后在R中安装monocle或其他R包来解决问题
1. Linux系统安装anacondaLinux中安装Anaconda和cutadapt_韩建刚(CAAS-UCD)的博客-CSDN博客_cutadapt安装
2. 配置镜像,参考下面三个文章,实测非常有效
conda配置R虚拟环境及导入R包_科研小工努力搬砖的博客-CSDN博客_r语言虚拟环境
conda 基于python3.8安装R语言4+Seurat4_运维自动化&云计算的博客-CSDN博客_conda r
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda
conda config --set show_channel_urls yes
conda config --show
######以下为输出内容######
######以下为输出内容######
add_anaconda_token: True
add_pip_as_python_dependency: True
aggressive_update_packages:
- ca-certificates
- certifi
- openssl
..............................................
channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
- defaults
...............................................
3. 创建虚拟环境
###1. 先查看已有的环境,可以看到只有一个conda的base环境
conda info --envs
# conda environments:
#
#base * /home/hanjiangang/anaconda3
###2. 创建新的虚拟环境
conda create -n R4.1.2
conda info --envs
###再查看发现添加了新的变量
##base * /home/anaconda3
##R4.1.2 /home/anaconda3/envs/R4.1.2
###3. 虚拟环境操作
###激活
conda activate R4.1.2
###退出
conda deactivate
###删除
conda env remove --name R4.1.2
4. 虚拟环境R4.1.2中安装R
###1. 先进入虚拟环境
conda activate R4.1.2
###2. 查看可用的R版本
conda search R
# Name Version Build Channel
#............
#r 4.0 r40_1004 anaconda/cloud/conda-forge
#r 4.0 r40hd8ed1ab_1004 anaconda/cloud/conda-forge
#r 4.1 r41hd8ed1ab_1004 anaconda/cloud/conda-forge
###3. 安装最新4.1.2版本,很快,无报错
conda install r-base=4.1.2
5. 将R路径添加到环境变量中,并运行R
因为之前尝试过直接在Linux系统中安装R,虽然R安装成功了,但是无法安装R包。在虚拟环境R4.1.2中运行R之前,需要先把之前安装R删除,之后把在虚拟环境(R4.1.2)中安装R的路径添加到环境变量中。
#在根目录下的.bash_profile文件中添加相应路径,并保存
export PATH=$PATH:/home/anaconda3/envs/R4.1.2/bin
#返回根目录,运行
source .bash_profile
#直接运行R,正常
R
##R version 4.1.2 (2021-11-01) -- "Bird Hippie"
##Copyright (C) 2021 The R Foundation for Statistical Computing
##Platform: x86_64-conda-linux-gnu (64-bit)
##
##R is free software and comes with ABSOLUTELY NO WARRANTY.
##You are welcome to redistribute it under certain conditions.
##Type 'license()' or 'licence()' for distribution details.
##
## Natural language support but running in an English locale
##...................
6. 运行R,安装BiocManager和monocle,参考之前的
Monocle操作笔记1-软件安装_韩建刚(CAAS-UCD)的博客-CSDN博客_monocle安装
##安装bioconductor
if (!require("BiocManager", quietly = TRUE))
install.packages("BiocManager")
BiocManager::install(version = "3.14")
##安装monocle
BiocManager::install("monocle")