[R-pkg-devel] How to declare Bioconductor Dependencies in the Description File of my R Package

Ruff, Sergej Sergej@Ru|| @end|ng |rom t|ho-h@nnover@de
Sat Mar 18 09:56:55 CET 2023


thank you, berry for your idea.

________________________________
Von: Berry Boessenkool <berryboessenkool using hotmail.com>
Gesendet: Samstag, 18. März 2023 09:54:45
An: Ruff, Sergej; Simon Urbanek
Cc: r-package-devel using r-project.org
Betreff: Re: [R-pkg-devel] How to declare Bioconductor Dependencies in the Description File of my R Package


I would use conditional returns to make the code more readable (see below) and then run the examples conditionally.

check_limma <- function() # Returns TRUE if available, FALSE otherwise
{
  if(requireNamespace("limma", quietly=TRUE)) return(TRUE)
  if(!interactive()) return(FALSE)
  inst <- menu(c("Yes", "No"), title="Package {limma} required but not installed.\nDo you want to install it now?")
  if(inst != 1)
    {
    message("To run this example, first install {limma} following the directions at 'https://bioconductor.org/packages/limma'")
    return(FALSE)
    }
  # the following could be wrapped in try and conditionally return TRUE / FALSE
  if(!requireNamespace("BiocManager", quietly=TRUE)) install.packages("BiocManager", quiet=TRUE)
  BiocManager::install("limma", update=FALSE, ask=FALSE, quiet=TRUE)
  return(TRUE)
}

# In the examples:
if(check_limma()){
group = gl(2, n)
design = model.matrix(~ group)
fit1 = limma::lmFit(X, design)
fit = limma::eBayes(fit1)
}

My 2 cents 🙂

Berry

-------------------------------------

________________________________
From: R-package-devel <r-package-devel-bounces using r-project.org> on behalf of Ruff, Sergej <Sergej.Ruff using tiho-hannover.de>
Sent: Friday, March 17, 2023 22:29
To: Simon Urbanek <simon.urbanek using R-project.org>
Cc: r-package-devel using r-project.org <r-package-devel using r-project.org>
Subject: Re: [R-pkg-devel] How to declare Bioconductor Dependencies in the Description File of my R Package

thank,


I was wondering if my idea regarding the implementation is correct.


I took the idea from Tiago Olivoto and wrote an additional function that checks if limma is installed.


Here is a mockup based on Tiago�s package:


check_limma<- function(){
  if(!requireNamespace("limma", quietly = TRUE)) {
    if(interactive() == TRUE){
      inst <-
        switch(menu(c("Yes", "No"), title = "Package {limma} required but not installed.\nDo you want to install it now?"),
               "yes", "no")
      if(inst == "yes"){
        if(!requireNamespace("BiocManager", quietly = TRUE)) {
          install.packages("BiocManager", quiet = TRUE)
        }
        BiocManager::install("limma",
                             update = FALSE,
                             ask = FALSE,
                             quiet = TRUE)
      } else{
        message("To run this example}, first install {limma} following the directions at 'https://bioconductor.org/packages/limma'")
      }
    }
  }
}

I would add the check in my example before limma functions are used.


### Differential expression analysis with limma

check_limma()
group = gl(2, n)
design = model.matrix(~ group)
fit1 = limma::lmFit(X, design)
fit = limma::eBayes(fit1)

I tried running the R CMD Check but I keep getting 1 error and note.
Is the implementation incorrect?

regards, Sergej


________________________________
Von: Simon Urbanek <simon.urbanek using R-project.org>
Gesendet: Freitag, 17. M�rz 2023 22:05:00
An: Ruff, Sergej
Cc: Duncan Murdoch; Martin Morgan; Ivan Krylov; r-package-devel using r-project.org
Betreff: Re: [R-pkg-devel] How to declare Bioconductor Dependencies in the Description File of my R Package

Packages can only be installed from the repositories listed and only CRAN is the default so only CRAN package are guaranteed to work. I'd like to add that the issue below is exactly why, personally, I would not recommend using Bioconductor package as strong dependency (imports/depends), because that makes the package unusable for most users, as it cannot be installed (without extra steps they don't know about) since the dependency doesn't exist on CRAN.

If your users are already Bioconductor users by the virtue of the package application then they already know so it's fine, but then you are probably better off to have your package on Bioconductor as part of the ecosystem which is much more streamlined and coordinated.

If it is only suggested (weak dependency) for some optional functionality, then your package will work even if the dependency is not installed so all is well. And if the optional Bioconductor functionality is used you can direct the user to instructions explaining that Bioconductor is required for that - but the package has to do that, it is not anything automatic in R.

Cheers,
Simon


> On Mar 18, 2023, at 1:29 AM, Ruff, Sergej <Sergej.Ruff using tiho-hannover.de> wrote:
>
> Really.Whats a problem i have when all dependencies arent prei installed. I thought the problem would be solved once my package is available on CRAN.
>
>
> Here is a recent question I had regarding the same issue:
>
>
> I am currently working on a r-package. I would like to submit my r package to CRAN, but I have a question regarding dependency installations on CRAN.
>
> I have almost finished my package, added the required dependencies to the NAMESPACE and DESCRIPTION files as Imports, and get no errors or warnings
>
> when running the check in Rstudio. The package runs on the pc, where I�ve built the package, but when I install the package on a pc, where the dependencies
>
> are not preinstalled, I get the following error:
>
> ERROR:
>
> dependencies 'depth', 'geometry' are not available for package 'packagename'
> * removing 'C:/Users/156932/AppData/Local/Programs/R/R-4.2.1/library/packagename'
> Warning in install.packages : installation of package �packagename� had non-zero exit status
>
>
> The problem is that a local installation of my package (via USB-stick for example) can�t install the dependencies from CRAN.
>
> The package works perfectly fine, if the dependencies are preinstalled.
>
> Now I don�t want to submit my package to CRAN if the end user gets the same error message when installing my package.
>
> Question: After I submit my package to CRAN, will CRAN install dependencies automatically (via "install.packages()"), resolving the issue I have right now?
>
> Or do I have to modify the R-package or the Description-file to make sure my Package can install dependencies?
>
> I provided the dependencies to the NAMESPACE-file as @ImportFrom via the devtools::document()-function. I added the dependencies to the DESCRIPTION-file via usethis::use_package("x",type="Imports"). The Description looks like this:
>
> License: GPL (>= 3)
> Encoding: UTF-8
> LazyData: true
> RoxygenNote: 7.2.3
> Imports:
>    depth,
>    geometry,
>    graphics,
>    grDevices,
>    MASS,
>    mvtnorm,
>    nlme,
>    rgl,
>    stats
>
>
>
> So I thought all dependencies would install automatically from CRAN? Is that not the case?
>


        [[alternative HTML version deleted]]


	[[alternative HTML version deleted]]



More information about the R-package-devel mailing list