[Bioc-devel] IRanges - PartitioningByEnd not found when package method runs.

Morgan, Martin Martin.Morgan at roswellpark.org
Wed Jan 13 17:19:49 CET 2016


Hi Ben -- nice to see you over here ;)

You're using the release version of R (R-3.2.3) and presumably release versions of packages (my advice on placing sessionInfo() was a little too clever; you want your package loaded, so the versions of it's dependencies are apparent, so in a separate R maybe library(testRpkg); sessionInfo(); I'll update my support site post...).

At least for Bioconductor packages, you want to be using the 'devel' version of Bioconductor, and during the current release cycle that means the devel version of R.

Nonetheless, I started R-release, loaded the test package, ran the function, and looked at traceback()

> library(testRpkg)
> doit()
Error in end(PartitioningByEnd(x)) : 
  error in evaluating the argument 'x' in selecting a method for function 'end': Error: could not find function "PartitioningByEnd"
> traceback()
9: end(PartitioningByEnd(x))
8: .unlist_NL_subscript(i, x)
7: fast_path_FUN(x, i)
6: subset_List_by_List(x, i)
5: object[index]
4: object[index]
3: subsetSites(dna, 1:50)
2: subsetSites(dna, 1:50)
1: doit()

The suspect looks like .unlist_NL_subscript, so I went looking for it

> getAnywhere(.unlist_NL_subscript)
A single object matching '.unlist_NL_subscript' was found
It was found in the following places
  namespace:S4Vectors
with value

function (i, x) 
{
    offsets <- c(0L, end(PartitioningByEnd(x))[-length(x)])
    i <- i + offsets
    unlist(i, use.names = FALSE)
}
<environment: namespace:S4Vectors>

So S4Vectors wants to use PartitioningByEnd. I looked at it's NAMESPACE imports (actually I looked in the SVN repository...) for the packages it imports from...

> names(getNamespaceImports("S4Vectors"))
[1] "base"         "methods"      "utils"        "stats"        "stats4"      
[6] "BiocGenerics"

and find that it does not import IRanges. So the problem is a bug in S4Vectors.

I don't see the problem in bioc-devel, and to see why I had to be a bit clever -- there is no error, so no opportunity to use traceback(). Instead, I used the advanced-but-flexible 'trace' function to set a tracer on PartioningByEnd, where the tracer is the 'recover' function...

> trace(IRanges::PartitioningByEnd, tracer=recover)

So when PartioningByEnd is evalutated, R will get me the 'recover' prompt... 
> doit()
Tracing IRanges::PartitioningByEnd(x) on entry 

Enter a frame number, or 0 to exit   

 1: doit()
 2: subsetSites(dna, 1:50)
 3: subsetSites(dna, 1:50)
 4: object[index]
 5: object[index]
 6: subset_List_by_List(x, i)
 7: fast_path_FUN(x, i)
 8: .unlist_NL_subscript(i, x)
 9: end(IRanges::PartitioningByEnd(x))
10: IRanges::PartitioningByEnd(x)

Selection: 

This shows me the call stack (looks almost identical, so I could have 'guessed' that I wanted to look at .unlist_NL_subscript again) and suggests that the code has been fixed to explicitly indicate where PartitioningByEnd comes from. This is confirmed by looking at the code definition

> getAnywhere(".unlist_NL_subscript")
A single object matching '.unlist_NL_subscript' was found
It was found in the following places
  namespace:S4Vectors
with value

function (i, x) 
{
    offsets <- c(0L, end(IRanges::PartitioningByEnd(x))[-length(x)])
    i <- i + offsets
    unlist(i, use.names = FALSE)
}
<environment: namespace:S4Vectors>

So this is a bug in S4Vectors, but fixed in Bioc-devel where new package development should be occurring.

I'll leave it to Herve or others to decide whether S4Vectors in release should be patched.

Thanks for the bug report!

Martin
________________________________________
From: Bioc-devel [bioc-devel-bounces at r-project.org] on behalf of Ben Ward (TGAC) [Ben.Ward at tgac.ac.uk]
Sent: Wednesday, January 13, 2016 10:57 AM
To: bioc-devel at r-project.org
Subject: [Bioc-devel] IRanges - PartitioningByEnd not found when package        method runs.

Hi All,

I am having an issue with an un-exported method in a package I am developing, the package imports Biostrings and IRanges.

I have created a minimal, reproducible example, (many many thanks to Martin Morgan for telling me how to do this) in this repo branch: https://github.com/Ward9250/testRpkg/tree/PartByEnd

The method, as you will see from the branch, is called subsetSites, and is supposed to cut a DNAString set down to only the sites/base positions indicated by a provided vector of integers. It does this by indexing the DNAStringSet with re.int.

If I try to run this however, it seems to fail, indicating that it cannot find the PartitioningByEnd function. This puzzles me as I know the function is part of IRanges, which is imported in the package, and I would assume Biostrings would import any IRanges functionality it needed for the DNAStringSet indexing operator.

Below is an example run of what I see, and my session info.

If anyone can see what my issue is or knows how to solve this it would be a big help.

Many Thanks,
Ben W.


bward at n78620:/tmp$ git clone git at github.com:ward9250/testRpkg.git -b PartByEnd
Cloning into 'testRpkg'...
remote: Counting objects: 18, done.
remote: Compressing objects: 100% (10/10), done.
remote: Total 18 (delta 1), reused 18 (delta 1), pack-reused 0
Receiving objects: 100% (18/18), done.
Resolving deltas: 100% (1/1), done.
Checking connectivity... done.
bward at n78620:/tmp$ cd testRpkg
bward at n78620:/tmp/testRpkg$ R CMD INSTALL .
* installing to library �/usr/users/TGAC_ga002/bward/R/x86_64-pc-linux-gnu-library/3.2�
* installing *source* package �testRpkg� ...
** R
** preparing package for lazy loading
** help
No man pages found in package  �testRpkg�
*** installing help indices
** building package indices
** testing if installed package can be loaded
* DONE (testRpkg)
bward at n78620:/tmp/testRpkg$ R --vanilla -e "sessionInfo(); testRpkg::doit()"
R version 3.2.3 (2015-12-10) -- "Wooden Christmas-Tree"
Copyright (C) 2015 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> sessionInfo(); testRpkg::doit()
R version 3.2.3 (2015-12-10)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 14.04.3 LTS

locale:
 [1] LC_CTYPE=en_GB.UTF-8       LC_NUMERIC=C
 [3] LC_TIME=en_GB.UTF-8        LC_COLLATE=en_GB.UTF-8
 [5] LC_MONETARY=en_GB.UTF-8    LC_MESSAGES=en_GB.UTF-8
 [7] LC_PAPER=en_GB.UTF-8       LC_NAME=C
 [9] LC_ADDRESS=C               LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base
Error in end(PartitioningByEnd(x)) :
  error in evaluating the argument 'x' in selecting a method for function 'end': Error: could not find function "PartitioningByEnd"
Calls: <Anonymous> ... subset_List_by_List -> fast_path_FUN -> .unlist_NL_subscript -> end
Execution halted



        [[alternative HTML version deleted]]


This email message may contain legally privileged and/or confidential information.  If you are not the intended recipient(s), or the employee or agent responsible for the delivery of this message to the intended recipient(s), you are hereby notified that any disclosure, copying, distribution, or use of this email message is prohibited.  If you have received this message in error, please notify the sender immediately by e-mail and delete this email message from your computer. Thank you.


More information about the Bioc-devel mailing list