具有 CRAN 和 Bioconductor 依赖项的 R 包
R package with CRAN and Bioconductor dependencies
我有一个 R 包存储在本地 git 服务器上。这个包有一系列依赖项——来自 CRAN 和 Bioconductor 的包。使用 devtools
包,我可以直接从 git 安装:
library(devtools)
install_git("http://mygitserver.com/username/reponame")
我注意到此安装过程未能安装所有 Bioconductor 依赖项,但所有 CRAN 依赖项均已正确安装。
如何设置包的依赖项(在 DESCRIPTION
文件中)以便所有 Bioconductor 包依赖项也能正确安装。我注意到当包托管在 Bioconductor 镜像上并通过 biocLite()
安装时这不是问题,这表明也许我可以通过列出一组镜像供 install.packages()
搜索来解决这个问题在声明找不到包裹之前。有没有办法自动获取所有这些依赖项?
简短回答:
setRepositories(ind=1:2)
tl;博士
setRepositories
的文档告诉我们 "default list of known repositories is stored in the file 'R_Home/etc/repositories'"。我们可以通过几种方式追踪它,但为了方便起见,让我们将存储库的 table 读取到 R 中(这将切断该文件中的所有注释文档,但您可以使用 readLines
如果你有兴趣。
read.table(file.path(R.home(), "etc", "repositories"), sep = "\t")
menu_name URL default source win.binary mac.binary
CRAN CRAN @CRAN@ TRUE TRUE TRUE TRUE
BioCsoft BioC software %bm/packages/%v/bioc FALSE TRUE TRUE TRUE
BioCann BioC annotation %bm/packages/%v/data/annotation FALSE TRUE TRUE TRUE
BioCexp BioC experiment %bm/packages/%v/data/experiment FALSE TRUE TRUE TRUE
BioCextra BioC extra %bm/packages/%v/extra FALSE TRUE TRUE TRUE
CRANextra CRAN (extras) http://www.stats.ox.ac.uk/pub/RWin FALSE TRUE TRUE TRUE
Omegahat Omegahat http://www.omegahat.org/R FALSE TRUE FALSE FALSE
R-Forge R-Forge http://R-Forge.R-project.org FALSE TRUE TRUE TRUE
rforge.net rforge.net http://www.rforge.net FALSE TRUE TRUE TRUE
CRANextra[https] CRAN (extras, https) https://www.stats.ox.ac.uk/pub/RWin FALSE TRUE TRUE TRUE
R-Forge[https] R-Forge [https] https://R-Forge.R-project.org FALSE TRUE TRUE TRUE
rforge.net[https] rforge.net [https] https://www.rforge.net FALSE TRUE TRUE TRUE
假设每一行都有一个索引号。当您调用 setRepositories(ind = 1:2)
时,您是在告诉 R 查看第 1 行和第 2 行中的存储库。
github 个存储库的不同答案是使用 biocLite()
source("https://bioconductor.org/biocLite.R")
biocLite("username/reposname")
它为 github 包分派到 devtools,为其他包分派到 CRAN / Bioconductor。
source()
命令安装或更新 BiocInstaller 包,因此当您的 BiocInstaller 版本是最新版本时,变化是
BiocInstaller::biocLite("username/reposname")
为您的示例使用开发工具,但为您的 R 和 Bioconductor 版本使用正确的 Bioconductor 存储库
install_git("http://mygitserver.com/username/reponame",
repos=BiocInstaller::biocinstallRepos())
repos
参数最终传递给 install.packages()
。更具体地说,对我来说,我有
> biocinstallRepos()
BioCsoft
"https://bioconductor.org/packages/3.3/bioc"
BioCann
"https://bioconductor.org/packages/3.3/data/annotation"
BioCexp
"https://bioconductor.org/packages/3.3/data/experiment"
BioCextra
"https://bioconductor.org/packages/3.3/extra"
CRAN
"https://cran.rstudio.com"
第二个注释包,BioCann,url。
我有一个 R 包存储在本地 git 服务器上。这个包有一系列依赖项——来自 CRAN 和 Bioconductor 的包。使用 devtools
包,我可以直接从 git 安装:
library(devtools)
install_git("http://mygitserver.com/username/reponame")
我注意到此安装过程未能安装所有 Bioconductor 依赖项,但所有 CRAN 依赖项均已正确安装。
如何设置包的依赖项(在 DESCRIPTION
文件中)以便所有 Bioconductor 包依赖项也能正确安装。我注意到当包托管在 Bioconductor 镜像上并通过 biocLite()
安装时这不是问题,这表明也许我可以通过列出一组镜像供 install.packages()
搜索来解决这个问题在声明找不到包裹之前。有没有办法自动获取所有这些依赖项?
简短回答:
setRepositories(ind=1:2)
tl;博士
setRepositories
的文档告诉我们 "default list of known repositories is stored in the file 'R_Home/etc/repositories'"。我们可以通过几种方式追踪它,但为了方便起见,让我们将存储库的 table 读取到 R 中(这将切断该文件中的所有注释文档,但您可以使用 readLines
如果你有兴趣。
read.table(file.path(R.home(), "etc", "repositories"), sep = "\t")
menu_name URL default source win.binary mac.binary
CRAN CRAN @CRAN@ TRUE TRUE TRUE TRUE
BioCsoft BioC software %bm/packages/%v/bioc FALSE TRUE TRUE TRUE
BioCann BioC annotation %bm/packages/%v/data/annotation FALSE TRUE TRUE TRUE
BioCexp BioC experiment %bm/packages/%v/data/experiment FALSE TRUE TRUE TRUE
BioCextra BioC extra %bm/packages/%v/extra FALSE TRUE TRUE TRUE
CRANextra CRAN (extras) http://www.stats.ox.ac.uk/pub/RWin FALSE TRUE TRUE TRUE
Omegahat Omegahat http://www.omegahat.org/R FALSE TRUE FALSE FALSE
R-Forge R-Forge http://R-Forge.R-project.org FALSE TRUE TRUE TRUE
rforge.net rforge.net http://www.rforge.net FALSE TRUE TRUE TRUE
CRANextra[https] CRAN (extras, https) https://www.stats.ox.ac.uk/pub/RWin FALSE TRUE TRUE TRUE
R-Forge[https] R-Forge [https] https://R-Forge.R-project.org FALSE TRUE TRUE TRUE
rforge.net[https] rforge.net [https] https://www.rforge.net FALSE TRUE TRUE TRUE
假设每一行都有一个索引号。当您调用 setRepositories(ind = 1:2)
时,您是在告诉 R 查看第 1 行和第 2 行中的存储库。
github 个存储库的不同答案是使用 biocLite()
source("https://bioconductor.org/biocLite.R")
biocLite("username/reposname")
它为 github 包分派到 devtools,为其他包分派到 CRAN / Bioconductor。
source()
命令安装或更新 BiocInstaller 包,因此当您的 BiocInstaller 版本是最新版本时,变化是
BiocInstaller::biocLite("username/reposname")
为您的示例使用开发工具,但为您的 R 和 Bioconductor 版本使用正确的 Bioconductor 存储库
install_git("http://mygitserver.com/username/reponame",
repos=BiocInstaller::biocinstallRepos())
repos
参数最终传递给 install.packages()
。更具体地说,对我来说,我有
> biocinstallRepos()
BioCsoft
"https://bioconductor.org/packages/3.3/bioc"
BioCann
"https://bioconductor.org/packages/3.3/data/annotation"
BioCexp
"https://bioconductor.org/packages/3.3/data/experiment"
BioCextra
"https://bioconductor.org/packages/3.3/extra"
CRAN
"https://cran.rstudio.com"
第二个注释包,BioCann,url。