代码之家  ›  专栏  ›  技术社区  ›  Geomicro

使用BiocConductor代替BiocLite安装封装

  •  0
  • Geomicro  · 技术社区  · 3 年前

    我不擅长解释R函数,我使用的代码来自 Callahan et al., 2017 安装Bioconductor封装。他们的脚本如下:

    .bioc_packages <- c("dada2", "phyloseq", "DECIPHER", "phangorn")
    
    .inst <- .bioc_packages %in% installed.packages()
    if(any(!.inst)) {
      source("http://bioconductor.org/biocLite.R")
      biocLite(.bioc_packages[!.inst], ask = F)
    }
    

    我有两个问题:

    1. 语法是什么 if(any(!.inst)) 完成我理解函数的结构,但我不知道这个特定部分的“含义”是什么。

    2. Bioconductor正在使用R版本大于3.5的BiocManager(我在4.1.2上),所以上面的代码给了我错误:

    对于R版本3.5或更高版本,请使用BiocManager安装Bioconductor包;看见 https://bioconductor.org/install

    如何编辑函数以解决此错误?

    非常感谢。

    1 回复  |  直到 3 年前
        1
  •  1
  •   Martin Morgan    3 年前

    也许最好在Bioconductor支持网站上问这个问题 https://support.bioconductor.org .

    我建议

    ## we need BiocManager from CRAN
    if (!"BiocManager" %in% rownames(installed.packages()))
        install.packages("BiocManager", repos = "https://cran.r-project.org")
    
    ## install or update required packages
    .bioc_packages <- c("dada2", "phyloseq", "DECIPHER", "phangorn")
    BiocManager::install(.bioc_packages)
    

    这将安装所有尚未安装的包(及其依赖项),将更新任何非最新的包(对于您正在使用的Bioconductor版本——根据Bioconducter指南,这些仅为错误修复),并表示不会重新安装已安装当前版本的包。

    请注意,使用R-4.1.2,您将无法获得的最新版本 生物导体 。您可能会更新到R-4.2.1(因为您希望使用这些软件包的当前版本,也因为您可能希望在Bioconductor中进行其他分析,这些分析涉及自R-4.1.2提供的Bioconducter版本以来引入的软件包),或者降级到您引用的论文中使用的R版本(因为您想更紧密地再现论文中的结果)。