Sunday, May 21, 2017

Developing R package: library specific functions

Recently started developing an R package with focus on Bioconductor. Had a lot of experience in using R, but package development in this language is a novel area for me. Got into very strange problem: testing code of function out of package works well, but activating this function from prebuilt package leads to error. The problem was with usage of "intersect" base operation. By default it was loaded from sets library, while was required from GRanges in my case.

Spend some time to figure this out, but thanks to this post fixed it. Issue was related to additional marking of function origin in DESCRIPTION. Basically, additional mark was required in Roxygen function annotation:

#' @importMethodsFrom GenomicRanges intersect

Also, one thing that I had to control - frequent reload of library to run testing. The following command works well:

detach("package:InTAD", unload = TRUE)

Of course, easier testing can be organized using testthat, but initial coding requires simple reload.

These are only minor issues, but closer to Bioconductor submission attempt I will try to give more overview.