2021-03-10

R包升级与降级

			<div class="entry-meta">
		<span class="sep">Posted on </span><a href="http://www.bio-info-trainee.com/5464.html" title="上午9:31" rel="bookmark"><time class="entry-date" datetime="2020-01-17T09:31:03+00:00" pubdate="">2020年1月17日</time></a><span class="by-author"> <span class="sep"> by </span> <span class="author vcard"><a class="url fn n" href="http://www.bio-info-trainee.com/author/ulwvfje" title="View all posts by ulwvfje" rel="author">ulwvfje</a></span></span>		</div><!-- .entry-meta -->
		</header><!-- .entry-header -->

<div class="entry-content">
	<div class="markdown-here-wrapper" data-md-url="http://www.bio-info-trainee.com/wp-admin/post-new.php">

关于R语言本身的升级与降级我们多次写教程阐述了,其实在Windows和MAC都是可以多个R版本共存的,Linux那就更不用说了,一切皆文件,想存放多少就可以多少。它们只不过是把谁放在环境变量罢了的问题,优先使用哪个的问题。
很多时候,我们其实并不需要动R本身的版本,可能只是想修改某个R包版本,比如单细胞领域最火的 Seurat 包, 就有这个问题:
Seurat: Tools for Single Cell Genomics 的介绍如下:

A toolkit for quality control, analysis, and exploration of single cell RNA sequencing data. ‘Seurat’ aims to enable users to identify and interpret sources of heterogeneity from single cell transcriptomic measurements, and to integrate diverse types of single cell data. See Satija R, Farrell J, Gennert D, et al (2015) [doi:10.1038/nbt.3192](https://doi.org/10.1038/nbt.3192), Macosko E, Basu A, Satija R, et al (2015) [doi:10.1016/j.cell.2015.05.002](https://doi.org/10.1016/j.cell.2015.05.002), and Butler A and Satija R (2017) [doi:10.1101/164889](https://doi.org/10.1101/164889) for more details.
一个R包,三篇文章,可以说是很牛了,因为它跨越了单细胞最火热的十年,所以不同文章使用的是不同版本的它,这样为了重复文章的某些分析图表,就需要使用指定版本的R包了。
在R包的CRAN可以看到:https://cran.r-project.org/web/packages/Seurat/index.html
| Package source: | Seurat_3.0.2.tar.gz |
| ————————- | —————————————————————————————— |
| Windows binaries: | r-devel: Seurat_3.0.2.zip, r-release: Seurat_3.0.2.zip, r-oldrel: Seurat_3.0.2.zip |
| OS X binaries: | r-release: Seurat_3.0.2.tgz, r-oldrel: Seurat_3.0.2.tgz |
| Old sources: | Seurat archive |
其中那个旧版本点击进入:https://cran.r-project.org/src/contrib/Archive/Seurat/

首先需要卸载自己电脑的Seurat包

很简单了,就是 remove.packages 函数而已

remove.packages('Seurat')

然后安装指定版本的R包

参考我四年前在生信菜鸟团博客:http://www.bio-info-trainee.com/1556.html

packageurl <- "https://cran.r-project.org/src/contrib/Archive/Seurat/Seurat_2.3.4.tar.gz"
install.packages(packageurl, repos=NULL, type="source")

这样做的后果是,很多该包的依赖包需要自行安装;

ERROR: dependencies ‘mixtools’, ‘lars’, ‘dtw’, ‘doSNOW’, ‘hdf5r’ are not available for package ‘Seurat’

代码是:

remove.packages('Seurat')
pkgs = c( 'mixtools', 'lars', 'dtw', 'doSNOW', 'hdf5r' ) 
#pkgs=c('jackstraw','slingshot')
BiocManager::install(pkgs,ask = F,update = F)
packageurl <- "https://cran.r-project.org/src/contrib/Archive/Seurat/Seurat_2.3.4.tar.gz"
install.packages(packageurl, repos=NULL, type="source")
library(Seurat)

默认安装就是最新版

library(Seurat)
remove.packages('Seurat')
install.packages('Seurat')
library(Seurat)

因为不同R包版本的依赖也不一样,所以需要相应的升级或者降级:

如下:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值