R包安装大全-番外篇一

时间:2022-05-03
本文章向大家介绍R包安装大全-番外篇一,主要内容包括首先是无法安装包、但是在包被载入的时候报错:、包使用的时候报错、基本概念、基础应用、原理机制和需要注意的事项等,并结合实例形式分析了其使用技巧,希望通过本文能帮助到大家理解应用这部分内容。

SingleCellExperiment是单细胞转录组数据的基础包,大部分其它单细胞转录组数据处理的包都依赖于它,就跟芯片数据里面的ExpressionSet对象一样,需要拼了命的理解透,才有可能做好数据分析。

首先是无法安装包

最近MAC升级就死机,好不容易通过谷歌救活了,但是R里面安装SingleCellExperiment包却开始报错,

## try http:// if https:// URLs are not supported
source("https://bioconductor.org/biocLite.R")
biocLite("SingleCellExperiment")
Bioconductor version 3.5 (BiocInstaller 1.26.1), ?biocLite for help
A newer version of Bioconductor is available for this version of R, ?BiocUpgrade
  for help
BioC_mirror: https://bioconductor.org
Using Bioconductor 3.5 (BiocInstaller 1.26.1), R 3.4.3 (2017-11-30).
Installing package(s) 'SingleCellExperiment'
Warning message:
package 'SingleCellExperiment' is not available (for R version 3.4.3)

按照我当初总结好的R包安装大全,R包终极解决方案 (请务必点击仔细阅读!!!)

下载它的macos版本压缩文件,直接解压到R的库目录,最后成功的安装了这个包

但是在包被载入的时候报错:

suppressPackageStartupMessages(library(scater))
# Error: This is R 3.4.3, package 'SingleCellExperiment' needs >= 3.5

很诡异的,当时硬是想不通为啥子,就去上海聚会了,放松了五天,回来检查了我的浏览器记录,发现这个SingleCellExperiment居然是有两个url,如下:

https://bioconductor.org/packages/release/bioc/html/SingleCellExperiment.html
https://bioconductor.org/packages/3.7/bioc/html/SingleCellExperiment.html

我有点诧异,一般来说,用最新版的即可。我进入仔细对比,发现依赖于3.7版本的bioconductor的那个包介绍页面里面写着依赖于 R (>= 3.5) 顿时尴尬了,现在是 2018年01月15日21:51:39 ,最新版的R还是3.4呀~!!

原来是当初我下载的SingleCellExperiment版本太超前了,尽管我把它挪到了library的目录,我的R也无法使用它,我删除了该目录,重新下载了一个!

wget https://bioconductor.org/packages/release/bioc/bin/macosx/el-capitan/contrib/3.4/SingleCellExperiment_1.0.0.tgz

这个时候这个包可以被载入,但是仍然报错

包使用的时候报错

本以为安装成功了,也可以载入,就万事大吉了,事实证明我还是太年轻

suppressPackageStartupMessages(library(scater))
data("sc_example_counts")
data("sc_example_cell_info") 

example_sce <- SingleCellExperiment(
    assays = list(counts = sc_example_counts), colData = sc_example_cell_info)

#Error in checkSlotAssignment(object, name, value) : 
#  assignment of an object of class "GRangesList" is not valid for slot 'rowRanges' in an object of class "SingleCellExperiment"; is(value, "GenomicRanges_OR_GRangesList") is not TRUE

很明显仍然是包不兼容的问题。

我又回过头想了想,为什么不能自然而然的安装包呢?看到了升级选项:

biocLite("BiocUpgrade")
> source("https://bioconductor.org/biocLite.R")
Bioconductor version 3.6 (BiocInstaller 1.28.0), ?biocLite for help
> biocLite("SingleCellExperiment")
BioC_mirror: https://bioconductor.org
Using Bioconductor 3.6 (BiocInstaller 1.28.0), R 3.4.3 (2017-11-30).
Installing package(s) 'SingleCellExperiment'
trying URL 'https://bioconductor.org/packages/3.6/bioc/bin/macosx/el-capitan/contrib/3.4/SingleCellExperiment_1.0.0.tgz'
Content type 'application/x-gzip' length 857294 bytes (837 KB)
==================================================
downloaded 837 KB

学习之路,任重而道远!

切勿纠结,放松两天,也许思路就慢慢理顺了!