[Bioc-devel] Gviz AnnotationTrack fails when "["-operator is defined

Sebastian Gibb sgibb.debian at gmail.com
Mon May 5 19:56:38 CEST 2014


Dear Florian,

On 2014-05-05 16:17:41, florian.hahne at novartis.com wrote:
> Hm, this looks odd indeed. I am wondering whether this is some sort of
> name space problem. Does the same happen when you create your ³A² dummy
> class and the ³[³ method in a little dummy package with its own name
> space?
Your guess was right! I created a small dummy package
( https://github.com/sgibb/dummyA ). And after loading it with `library`
everything works like expected.
But if I load it with devtools' `load_all` it crashes with the same error:

Error in callNextMethod(x, i) :
  bad object found as method (class "function")

Kind regards,

Sebastian

On 2014-05-05 16:17:41, florian.hahne at novartis.com wrote:
> Something seems to be messing up the methods table when you define
> the ³[³ method from the global environment.
> Any advice from the name space gurus on the list?
> Florian
>
> On 04/05/14 13:48, "Sebastian Gibb" <sgibb.debian at gmail.com> wrote:
>
> >Dear Florian, dear all,
> >
> >I want to use Gviz::AnnotationTrack to visualize my own class. This class
> >overloads the "[" operator. It seems that just the definition of my own
> >"["
> >results in a method dispatching error:
> >
> >Error in callNextMethod(x, i) :
> >  bad object found as method (class ³function²)
> >
> >After defining "[" even AnnotationTrack instances that are not using my
> >class
> >throw this error.
> >
> >I do not understand the error. Did I something wrong? Can somebody
> >enlighten me?
> >
> >Please find a minimal reproducible example below.
> >
> >Kind regards,
> >
> >Sebastian
> >
> >###
> >library("Gviz")
> >
> >## create dummy class
> >setClass("A",
> >         slots = list(start = "numeric", end = "numeric"),
> >         prototype = prototype(
> >          start = integer(),
> >          end = integer()))
> >
> >## define a plotting function for A
> >plotGVizA <- function(obj) {
> >  aTrack <- AnnotationTrack(start=obj at start, end=obj at end, name = "a",
> >                            chromosome = "chr0", genome = "all")
> >  plotTracks(aTrack, from = min(obj at start), to = max(obj at end))
> >}
> >
> >## define a plotting function without any A
> >plotGViz <- function() {
> >  aTrack <- AnnotationTrack(start=c(1, 5), end=c(3, 10), name = "a",
> >                            chromosome = "chr0", genome = "all")
> >  plotTracks(aTrack, from = 1, to = 10)
> >}
> >
> >## create an object of class A
> >a <- new("A", start=c(1, 5), end=c(3, 10))
> >
> >## works
> >plotGViz()
> >plotGVizA(a)
> >
> >## define the "[" operator for A
> >setMethod("[", "A", function(x, i, j, ...) { return(c(x at start[i],
> >x at end[i])) })
> >
> >## crashes with the following error message:
> >## Error in callNextMethod(x, i) :
> >##  bad object found as method (class ³function²)
> >plotGVizA(a)
> >plotGViz()
> >
> >traceback()
> >#12: stop(gettextf("bad object found as method (class %s)",
> ># dQuote(class(method))), domain = NA)
> >#11: callNextMethod(x, i)
> >#10: .local(x, i, ...)
> >#9: GdObject[seqnames(GdObject) == chromosome(GdObject)]
> >#8: .computeGroupRange(GdObject, hasAxis = hasAxis, hasTitle = hasTitle,
> >#       title.width = title.width)
> >#7: .local(GdObject, ...)
> >#6: FUN(X[[1L]], ...)
> >#5: FUN(X[[1L]], ...)
> >#4: lapply(trackList, consolidateTrack, chromosome = chromosome,
> >#       any(.needsAxis(trackList)), any(.needsTitle(trackList)),
> >#       title.width, alpha = hasAlpha, ...)
> >#3: lapply(trackList, consolidateTrack, chromosome = chromosome,
> >#       any(.needsAxis(trackList)), any(.needsTitle(trackList)),
> >#       title.width, alpha = hasAlpha, ...)
> >#2: plotTracks(aTrack, from = 1, to = 10) at #4
> >#1: plotGViz()
> >
> >sessionInfo()
> >#R version 3.1.0 (2014-04-10)
> >#Platform: x86_64-pc-linux-gnu (64-bit)
> >#
> >#locale:
> ># [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
> ># [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8
> ># [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8
> ># [7] LC_PAPER=en_US.UTF-8       LC_NAME=C
> ># [9] LC_ADDRESS=C               LC_TELEPHONE=C
> >#[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
> >#
> >#attached base packages:
> >#[1] parallel  grid      stats     graphics  grDevices utils     datasets
> >#[8] methods   base
> >#
> >#other attached packages:
> >#[1] XVector_0.4.0       IRanges_1.22.6      Gviz_1.8.0
> >#[4] BiocGenerics_0.10.0 devtools_1.5        vimcom.plus_0.9-93
> >#[7] setwidth_1.0-3      colorout_1.0-2
> >#
> >#loaded via a namespace (and not attached):
> ># [1] AnnotationDbi_1.26.0     BatchJobs_1.2
> ># [3] BBmisc_1.6               Biobase_2.24.0
> ># [5] BiocParallel_0.6.0       biomaRt_2.20.0
> ># [7] Biostrings_2.32.0        biovizBase_1.12.1
> ># [9] bitops_1.0-6             brew_1.0-6
> >#[11] BSgenome_1.32.0          cluster_1.15.2
> >#[13] codetools_0.2-8          colorspace_1.2-4
> >#[15] DBI_0.2-7                dichromat_2.0-0
> >#[17] digest_0.6.4             evaluate_0.5.5
> >#[19] fail_1.2                 foreach_1.4.2
> >#[21] Formula_1.1-1            GenomeInfoDb_1.0.2
> >#[23] GenomicAlignments_1.0.1  GenomicFeatures_1.16.0
> >#[25] GenomicRanges_1.16.3     Hmisc_3.14-4
> >#[27] httr_0.3                 iterators_1.0.7
> >#[29] lattice_0.20-29          latticeExtra_0.6-26
> >#[31] matrixStats_0.8.14       memoise_0.2.1
> >#[33] munsell_0.4.2            plyr_1.8.1
> >#[35] RColorBrewer_1.0-5       Rcpp_0.11.1
> >#[37] RCurl_1.95-4.1           R.methodsS3_1.6.1
> >#[39] Rsamtools_1.16.0         RSQLite_0.11.4
> >#[41] rtracklayer_1.24.0       scales_0.2.4
> >#[43] sendmailR_1.1-2          splines_3.1.0
> >#[45] stats4_3.1.0             stringr_0.6.2
> >#[47] survival_2.37-7          tools_3.1.0
> >#[49] VariantAnnotation_1.10.1 whisker_0.3-2
> >#[51] XML_3.98-1.1             zlibbioc_1.10.0
>



More information about the Bioc-devel mailing list