Skip to content
Prev 8555 / 21312 Next

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

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()
Error in end(PartitioningByEnd(x)) : 
  error in evaluating the argument 'x' in selecting a method for function 'end': Error: could not find function "PartitioningByEnd"
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
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...
[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...
So when PartioningByEnd is evalutated, R will get me the 'recover' prompt...
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
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