R包clusterProfiler如何安装成功(新手必看!)

前言

里面有些坑,写篇博客介绍一下。

R包clusterProfiler是生物信息分析汇总,基因富集分析可视化经常用到的R包,但是安装时,新手经常会遇到一些问题,这里简单总结一下。

看重点:正确的安装方式

官网:https://bioconductor.org/packages/release/bioc/html/clusterProfiler.html

在R中运行下面命令,安装即可:

if (!require("BiocManager", quietly = TRUE))
 install.packages("BiocManager")

BiocManager::install("clusterProfiler")

1. 在CRAN中用install.packages()安装

install.packages("clusterProfile")

安装报错:

> install.packages("clusterProfile")
(因为‘lib'没有被指定)
Warning in install.packages :
 package ‘clusterProfile' is not available for this version of R

A version of this package for your version of R might be available elsewhere,
see the ideas at
https://cran.r-project.org/doc/manuals/r-patched/R-admin.html#Installing-packages
>

报错原因,因为clusterProfile不在CRAN中,所以不能通过install.packages进行安装。

2. 安装bioconductor报错

有时候,知道在bioconductor中,于是还是安装:

install.packages("bioconductor")

报错如下:

> install.packages("bioconductor")

(因为‘lib'没有被指定)
Warning in install.packages :
 package ‘bioconductor' is not available for this version of R

A version of this package for your version of R might be available elsewhere,
see the ideas at
https://cran.r-project.org/doc/manuals/r-patched/R-admin.html#Installing-packages

3. 正确而顺利的安装方法

3.1 安装最新版R

目前是4.2.1,因为R4.2之前的clusterProfiler有bug,kegg联网会报错,新版本没有问题了。

3.2 安装Rtools4.2

这是单机软件,地址:https://cran.r-project.org/bin/windows/Rtools/rtools42/rtools.html

3.3 配置镜像

在Rstudio中,将下载镜像变为中国的,下载速度会快很多。

3.4 正式安装

在Rstudio中运行安装代码:

if (!require("BiocManager", quietly = TRUE))
 install.packages("BiocManager")

BiocManager::install("clusterProfiler")

这中间会安装许多依赖包,如果有某个包安装报错了,就单独安装那个包,安装成功后,在运行安装clusterProfiler的代码。

4. 配置建议

  • R最新版的R4.2.1
  • 安装Rtools(windows系统建议)
  • 安装路径不要有中文路径
  • 如果电脑用户名是中文的,建议新建一个英文用户名,然后登录安装
  • 配置镜像,提升安装速度

总结

作者:育种数据分析之放飞自我原文地址:https://blog.csdn.net/yijiaobani/article/details/127528407

%s 个评论

要回复文章请先登录注册