16
$\begingroup$

I have an R package on github which uses multiple Bioconductor dependencies, 'myPackage'

If I include CRAN packages in the DESCRIPTION via Depends:, the packages will automatically install upon installation via devtools, i.e.

devtools::install_github('repoName/myPackage')

This is discussed in Section 1.1.3 Package Dependencies, in Writing R Extensions

Is there a way to streamline this such that packages from Bioconductor are automatically installed as well?

Normally, users install Bioconductor packages via BiocLite, e.g.

source("http://www.bioconductor.org/biocLite.R")
biocLite("edgeR")
$\endgroup$
1
  • 1
    $\begingroup$ Note that as of Bioconductor release 3.8 onwards, bioconductor packages are installed with BiocManager::install() which can be installed from CRAN $\endgroup$ Commented Apr 19, 2019 at 15:05

4 Answers 4

11
$\begingroup$

There's a trick to this where one needs to add biocViews: to the package Description. That's the only solution I've ever seen to allowing automatic installation of bioconductor dependencies. If you need a couple of examples, then click through the link I posted and scroll down to pull requests referencing that issue, they will generally include the actual example.

$\endgroup$
3
  • $\begingroup$ I didn't find the examples in the pull requests you mentioned. However, I did search the github mirror on CRAN. There are DESCRIPTION files with a lone biocViews: line before Depends:. Others include tags, like biocViews: Infrastructure, RNA $\endgroup$ Commented Jan 22, 2018 at 19:32
  • $\begingroup$ Maybe we should post an example DESCRIPTION so it's absolutely clear to future biohackers how this is done...this news needs to spread! $\endgroup$ Commented Jan 22, 2018 at 19:57
  • 2
    $\begingroup$ You don't need anything after biocViews:, that alone suffices (see ?devtools::package_deps). $\endgroup$
    – Devon Ryan
    Commented Jan 22, 2018 at 20:14
18
$\begingroup$

As suggested, here’s an example showing the relevant lines from a DESCRIPTION file from a CRAN/GitHub hosted project that has Bioconductor dependencies (truncated):

Depends:
    R (>= 3.3.0)
biocViews:
Imports:
    methods,
    snpStats,
    dplyr

The relevant bit is the empty biocViews: declaration, which allows the Bioconductor dependency {snpStats} to be automatically installed.

$\endgroup$
9
  • $\begingroup$ r Check() would still fail for me with "Packages required but not available" $\endgroup$
    – Edmondo
    Commented Jan 23, 2022 at 9:20
  • $\begingroup$ @Edmondo1984 Hard to know what you’re doing wrong without seeing your code. As evidenced by the linked package (which can run R CMD check without failure), this works just fine. $\endgroup$ Commented Jan 23, 2022 at 17:02
  • $\begingroup$ I have a clear repro. I have a DESCRIPTION containing biocViews: and an Import on a bioconductor package. I do a check() it fails, I install the package manually and do a check, it works. The problem is, how is this supposed to work on a CI/CD server? Shouldn't R download the packages itself on a check()? $\endgroup$
    – Edmondo
    Commented Jan 23, 2022 at 17:30
  • $\begingroup$ @Edmondo1984 No, R CMD check doesn’t install packages. The same is true for CRAN packages. If you want to run check on CI, the conventional way is to first install the package and its dependencies, and then run check on it. $\endgroup$ Commented Jan 23, 2022 at 21:54
  • $\begingroup$ Thanks, what is the right way to install the package and its dependencies? $\endgroup$
    – Edmondo
    Commented Jan 23, 2022 at 22:24
2
$\begingroup$

I have a counter example to other answers. BiocViews is not needed to install Bioconductor dependencies on CRAN. I have a package on CRAN that suggests Bioconductor packages and they are found without using BiocViews.

If you are installing a package from github and it has dependencies on Bioconductor you can use directly BiocManager::install("user/package") and it will use remotes::install_github internally and pull also packages from Bioconductor (from the right release).

BiocViews is/was used to detect that a package is for Bioconductor by remotes, devtools and sessioninfo among other packages that help the development and testing of packages. In addition Bioconductor doesn't add a Repository: Bioconductor on the provided DESCRIPTION field of the packages, while CRAN adds Repository: CRAN.

$\endgroup$
2
$\begingroup$

Alternatively you also can set options(repos=BiocManager::repositories()) (e.g. in your .Rprofile which will make Bioconductor behave like a CRAN repository (there actually are multiple CRAN-style repositories in Bioconductor) after which you can simply run install.packages() for all packages irrespective if it is hosted on CRAN or Bioconductor.

As a consequence, packages with bioconductor dependencies will automatically resolve those dependencies without any of the aforementioned additions.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.