[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
Wed May 3 14:00:51 CEST 2023


I implemented teh limma Bioconductor dependency into the Suggests file and made it conditionally


Meaning I provided the Description File with


Suggests:
    BiocManager,
    limma


and created a short function which checks if limma is available


#' Check for package dependency
#'
#' @title Check for 'limma' availability
#' @description checks if the 'limma' package is installed. If not already installed,
#' limma will be installed automatically.
#' @author Sergej Ruff
#' @importFrom utils install.packages menu
#' @export
#' @keywords internal
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 example field which uses the limma functions I then implemented the check-function:


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

### Calculation of confidence intervals
CI = fc_ci(fit=fit, alpha=0.05, method="raw")
head(CI)
CI = fc_ci(fit=fit, alpha=0.05, method="BH")
head(CI)
CI = fc_ci(fit=fit, alpha=0.05, method="BY")
head(CI)

fc_plot(CI, xlim=c(-0.5, 3), ylim=-log10(c(1, 0.0001)), updown="up")
fc_plot(CI, xlim=c(-3, 0.5), ylim=-log10(c(1, 0.0001)), updown="down")
fc_plot(CI, xlim=c(-3, 3), ylim=-log10(c(1, 0.0001)), updown="all")
}



I don�t get any Errors. Thank you R mailing list for providing the tips.


I just wanted to ask, if theres any other way to implement it, since I have never seen an example field

which has a check-if dependency is available function.


Is there any Improvments i could make or better methods.


Also for the future - how Do i provide Bioconductor dependencies as "Imports" for a package that I want to submit to CRAN?

Do I need to make that also conditional? I know I should provide Installation description in a readme fiel but how do I make sure

that the Bioconductor dependencies dont cause a rejection from CRAN?


Best Regards,

Sergej

________________________________
Von: Ivan Krylov <krylov.r00t using gmail.com>
Gesendet: Montag, 20. M�rz 2023 21:08:38
An: Ruff, Sergej
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

On Mon, 20 Mar 2023 19:32:03 +0000
"Ruff, Sergej" <Sergej.Ruff using tiho-hannover.de> wrote:

> but I thought Notes will also cause rejection when submitting a
> package to CRAN. Won�t that be a problem?

True, a NOTE during an automatic check may cause a rejection, but you
won't get this NOTE there. Automatic CRAN pre-tests are done with a
full package set: anything from CRAN and BioConductor that runs on a
given operating system can be loaded.

(This differentiates CRAN from, say, PyPI or NPM: the two latter
ecosystems are much larger and are expected to handle conflicting
dependency requirements. CRAN is small enough to be able to enforce the
rule that every package must play well with the latest version of
everything else.)

There's an additional CRAN check called noSuggests
<https://www.stats.ox.ac.uk/pub/bdr/noSuggests/README.txt>. You will
get a NOTE there, but it's expected and won't count against you. The
only way avoid this NOTE there is to not have any packages in Suggests:
(or Enhances:).

--
Best regards,
Ivan

	[[alternative HTML version deleted]]



More information about the R-package-devel mailing list