[Bioc-devel] Gviz AnnotationTrack fails when "["-operator is defined
Thanks Martin, Btw, is there some sort of disconnect on BioC Devel right now with regards to the latest package versions? Since the release there are some rather strict requirements in my DESCRIPTION file, but some of the packages versions are not available from BiocLite: [s_itoxadm at chbslx1501:~/Rpacks/Gviz]$ svn blame DESCRIPTION 62472 m.carlson Package: Gviz 89967 fhahne Version: 1.9.3 62472 m.carlson Title: Plotting data and annotation information along genomic coordinates 80543 fhahne Author: Florian Hahne, Steffen Durinck, Robert Ivanek, Arne Mueller, Steve Lianoglou, Ge Tan <ge.tan09 at imperial.ac.uk> 62472 m.carlson Maintainer: Florian Hahne <florian.hahne at novartis.com> 89957 hpages at fhcrc.org Depends: R (>= 2.10.0), methods, grid, BiocGenerics (>= 0.11.2), S4Vectors (>= 0.0.1), IRanges (>= 1.99.1), GenomeInfoDb (>= 1.1.3), GenomicRanges (>= 1.17.11) 89957 hpages at fhcrc.org Imports: XVector (>= 0.5.3), rtracklayer (>= 1.25.5), lattice, RColorBrewer, biomaRt (>= 2.11.0), AnnotationDbi (>= 1.27.5), Biobase (>= 2.15.3), GenomicFeatures (>= 1.17.5), BSgenome (>= 1.33.1), Biostrings (>= 2.33.3), biovizBase (>= 1.13.7), Rsamtools (>= 1.17.8), latticeExtra (>= 0.6-26), matrixStats (>= 0.8.14), GenomicAlignments (>= 1.1.9) 85562 fhahne Suggests: xtable, BSgenome.Hsapiens.UCSC.hg19, BiocStyle 62472 m.carlson biocViews: Visualization, Microarray 62472 m.carlson Description: Genomic data analyses requires integrated visualization of known genomic information and new experimental data. Gviz uses the biomaRt and the rtracklayer packages to perform live annotation queries to Ensembl and UCSC and translates this to e.g. gene/transcript structures in viewports of the grid graphics package. This results in genomic information plotted together with your data. 62472 m.carlson Collate: Gviz.R AllGenerics.R AllClasses.R Gviz-methods.R 62472 m.carlson License: Artistic-2.0 62472 m.carlson LazyLoad: yes 62472 m.carlson Available rtracklayer for example is only 1.25.4 http://www.bioconductor.org/packages/devel/bioc/html/rtracklayer.html But the version in the svn is Version: 1.25.5 Any idea what went wrong there? Florian
On 06/05/14 01:09, "Martin Morgan" <mtmorgan at fhcrc.org> wrote:
On 05/05/2014 10:56 AM, Sebastian Gibb wrote:
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?
I looked a little at this, and it seems like a methods bug in
callNextMethod
when invoked inside a .local function. It can be worked around by
revising Gviz
"[" method definitions as
setMethod("[", signature(x="StackedTrack"), function(x, i, j, ...,
drop=TRUE) {
x <- callNextMethod(x,i)
x at stacks <- x at stacks[i]
return(x)})
A simple reproducible example is
.A = setClass("A", "numeric")
setMethod("[", "A", function(x, i) callNextMethod(x, i))
and then
.A()[]
Error in callNextMethod(x, i) : bad object found as method (class ?function?) Martin
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
_______________________________________________ Bioc-devel at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/bioc-devel
-- Computational Biology / Fred Hutchinson Cancer Research Center 1100 Fairview Ave. N. PO Box 19024 Seattle, WA 98109 Location: Arnold Building M1 B861 Phone: (206) 667-2793