Answers.Body: <p>As suggested, here’s an example showing the relevant lines <a href="https://github.com/HannahVMeyer/PhenotypeSimulator/blob/6ba850c74d641278f75e30c4750cb2d545522689/DESCRIPTION#L28" rel="noreferrer">from a <code>DESCRIPTION</code> file</a> from a <a href="https://github.com/HannahVMeyer/PhenotypeSimulator" rel="noreferrer">CRAN/GitHub hosted project</a> that has Bioconductor dependencies (truncated):</p>
  
  <pre><code>Depends:
      R (&gt;= 3.3.0)
  biocViews:
  Imports:
      methods,
      snpStats,
      dplyr
  </code></pre>
  
  <p>The relevant bit is the empty <code>biocViews:</code> declaration, which allows the Bioconductor dependency {snpStats} to be automatically installed.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-01-23T09:20:23.670Z
Answers.Text: r Check() would still fail for me with "Packages required but not available"
Answers.UserDisplayName: Edmondo
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-01-23T17:02:56.240Z
Answers.Text: @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.
Answers.UserDisplayName: Konrad Rudolph
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-01-23T17:30:01.810Z
Answers.Text: 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()?
Answers.UserDisplayName: Edmondo
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-01-23T21:54:06.243Z
Answers.Text: @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.
Answers.UserDisplayName: Konrad Rudolph
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-01-23T22:24:22.997Z
Answers.Text: Thanks, what is the right way to install the package and its dependencies?
Answers.UserDisplayName: Edmondo
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-01-24T10:46:11.757Z
Answers.Text: @Edmondo1984 The easiest way is probably via `remotes::install_deps(dependencies = TRUE)`. Check out [`r-lib/actions`](https://github.com/r-lib/actions), it’s a comprehensive repository of CI/CD actions for R on GitHub. Even if you’re not using GitHub Actions, these can serve as a template for you.
Answers.UserDisplayName: Konrad Rudolph
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-08-10T09:12:32.853Z
Answers.Text: I now recommend using `pak::pak()` instead of `remotes::install_deps()`.
Answers.UserDisplayName: Konrad Rudolph
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-04-03T16:17:10.790Z
Answers.Text: This appears to only work for `remotes::install_github()`. If I try `install.packages('PhenotypeSimulator')` there will be a warning: `Warning in install.packages: dependency ‘snpStats’ is not available`.
Answers.UserDisplayName: Axeman
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-04-04T06:49:29.310Z
Answers.Text: @Axeman Yes. But as mentioned in my previous comment, the recommended solution now is `pak::pak()`. The ‘remotes’ package is for all intents and purposes obsolete and superseded by ‘pak’.
Answers.UserDisplayName: Konrad Rudolph
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-01-23T13:57:17.857Z
Answers.LastActivityDate: 2018-01-23T13:57:17.857Z
Answers.UserDisplayName: Konrad Rudolph
Answers.Body: <p>I have a counter example to other answers. BiocViews is not needed to install Bioconductor dependencies on CRAN. I have a <a href="https://cran.r-project.org/package=BaseSet" rel="nofollow noreferrer">package on CRAN</a> that suggests Bioconductor packages and they are found without using BiocViews.</p>
  <p>If you are installing a package from github and it has dependencies on Bioconductor you can use directly <code>BiocManager::install(&quot;user/package&quot;)</code> and it will use <code>remotes::install_github</code> internally and pull also packages from Bioconductor (from the right release).</p>
  <p>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 <code>Repository: Bioconductor</code> on the provided DESCRIPTION field of the packages, while CRAN adds <code>Repository: CRAN</code>.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-01-21T10:21:49.897Z
Answers.LastActivityDate: 2022-01-21T10:21:49.897Z
Answers.UserDisplayName: llrs
Answers.Body: <p>Alternatively you also can set <code>options(repos=BiocManager::repositories())</code> (e.g. in your <code>.Rprofile</code> which will make Bioconductor behave like a CRAN repository (there actually are multiple CRAN-style repositories in Bioconductor) after which you can simply run <code>install.packages()</code> for all packages irrespective if it is hosted on CRAN or Bioconductor.</p>
  <p>As a consequence, packages with bioconductor dependencies will automatically resolve those dependencies without any of the aforementioned additions.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-09-03T09:40:02.297Z
Answers.LastActivityDate: 2024-09-03T09:40:02.297Z
Answers.UserDisplayName: Michael Mayer
Answers.Body: <p>There's a trick to this where <a href="https://github.com/hadley/devtools/issues/700" rel="noreferrer">one needs to add <code>biocViews:</code> to the package Description</a>. 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.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-01-22T19:32:48.860Z
Answers.Text: 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`
Answers.UserDisplayName: ShanZhengYang
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-01-22T19:57:48.840Z
Answers.Text: Maybe we should post an example DESCRIPTION so it's *absolutely* clear to future biohackers how this is done...this news needs to spread!
Answers.UserDisplayName: ShanZhengYang
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-01-22T20:14:17.913Z
Answers.Text: You don't need anything after `biocViews:`, that alone suffices (see `?devtools::package_deps`).
Answers.UserDisplayName: Devon Ryan
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-01-22T19:04:53.820Z
Answers.LastActivityDate: 2018-01-22T19:04:53.820Z
Answers.UserDisplayName: Devon Ryan
Body: <p>I have an R package on github which uses multiple Bioconductor dependencies, 'myPackage'</p>
  
  <p>If I include CRAN packages in the DESCRIPTION via <code>Depends:</code>, the packages will automatically install upon installation via devtools, i.e. </p>
  
  <pre><code>devtools::install_github('repoName/myPackage')
  </code></pre>
  
  <p>This is discussed in Section 1.1.3 Package Dependencies, in <a href="https://cran.r-project.org/doc/manuals/r-release/R-exts.html" rel="noreferrer">Writing R Extensions</a></p>
  
  <p>Is there a way to streamline this such that packages from Bioconductor are automatically installed as well?</p>
  
  <p>Normally, users install Bioconductor packages via BiocLite, e.g. </p>
  
  <pre><code>source("http://www.bioconductor.org/biocLite.R")
  biocLite("edgeR")
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-04-19T15:05:31.547Z
Comments.Text: Note that as of Bioconductor release 3.8 onwards, bioconductor packages are installed with `BiocManager::install()` which can be installed from CRAN
Comments.UserDisplayName: Tom Kelly ケリー・トム
Tags: <r><bioconductor>
Title: R package development: How does one automatically install Bioconductor packages upon package installation?
ThreadText: # R package development: How does one automatically install Bioconductor packages upon package installation?
  
  (Asked by: username_0 on 2018-01-22)
  
  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](https://cran.r-project.org/doc/manuals/r-release/R-exts.html)
  
  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")
  
  ```
  
  **Tags:** r, bioconductor
  
  > **Comments:**
  > **username_1**: Note that as of Bioconductor release 3.8 onwards, bioconductor packages are installed with `BiocManager::install()` which can be installed from CRAN  
  
  ---
  
  ## 4 answers
  
  ### Answer by username_7 on 2018-01-22. Score: 11 | Accepted answer
  
  There's a trick to this where [one needs to add `biocViews:` to the package Description](https://github.com/hadley/devtools/issues/700). 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.
  
  > **Comments:**
  > **username_0**: 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`  
  > **username_0**: Maybe we should post an example DESCRIPTION so it's *absolutely* clear to future biohackers how this is done...this news needs to spread!  
  > **username_7**: You don't need anything after `biocViews:`, that alone suffices (see `?devtools::package_deps`).  
  
  ---
  
  ### Answer by username_2 on 2018-01-23. Score: 18
  
  As suggested, here’s an example showing the relevant lines [from a `DESCRIPTION` file](https://github.com/HannahVMeyer/PhenotypeSimulator/blob/6ba850c74d641278f75e30c4750cb2d545522689/DESCRIPTION#L28) from a [CRAN/GitHub hosted project](https://github.com/HannahVMeyer/PhenotypeSimulator) 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.
  
  > **Comments:**
  > **username_3**: r Check() would still fail for me with "Packages required but not available"  
  > **username_2**: @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.  
  > **username_3**: 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()?  
  > **username_2**: @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.  
  > **username_3**: Thanks, what is the right way to install the package and its dependencies?  
  > **username_2**: @Edmondo1984 The easiest way is probably via `remotes::install_deps(dependencies = TRUE)`. Check out [`r-lib/actions`](https://github.com/r-lib/actions), it’s a comprehensive repository of CI/CD actions for R on GitHub. Even if you’re not using GitHub Actions, these can serve as a template for you.  
  > **username_2**: I now recommend using `pak::pak()` instead of `remotes::install_deps()`.  
  > **username_4**: This appears to only work for `remotes::install_github()`. If I try `install.packages('PhenotypeSimulator')` there will be a warning: `Warning in install.packages: dependency ‘snpStats’ is not available`.  
  > **username_2**: @username_4 Yes. But as mentioned in my previous comment, the recommended solution now is `pak::pak()`. The ‘remotes’ package is for all intents and purposes obsolete and superseded by ‘pak’.  
  
  ---
  
  ### Answer by username_5 on 2022-01-21. Score: 2
  
  I have a counter example to other answers. BiocViews is not needed to install Bioconductor dependencies on CRAN. I have a [package on CRAN](https://cran.r-project.org/package=BaseSet) 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`.
  
  
  ---
  
  ### Answer by username_6 on 2024-09-03. Score: 2
  
  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.
  
  
  ---
  
  