[BioC] rtracklayer issues with other packages?

Martin Morgan mtmorgan at fhcrc.org
Sun Dec 5 06:27:45 CET 2010


On 12/04/2010 08:58 AM, Michael Lawrence wrote:
> I looked into this.
> 
> Just loading rtracklayer, we have:
> 
>> library(rtracklayer)
>> selectMethod("export.ucsc", c(object="UCSCData", con="file"))@defined
>                  object                     con
>              "UCSCData" "characterORconnection"
> attr(,"class")
> [1] "signature"
> attr(,"class")attr(,"package")
> [1] "methods"
> 
> Loading graph, then rtracklayer:
> 
>> library(graph)
>> library(rtracklayer)
>> selectMethod("export.ucsc", c(object="UCSCData", con="file"))@defined
> An object of class "signature"
>       object          con
> "RangedData"        "ANY"

Lots of weird things seem to be going on.

At the command line and at this particular point I think you see the
graph definition of 'file'

> getClass('file')
Virtual Class "file" [package "Biostrings"]

Slots:

Name:   .S3Class
Class: character

Extends:
Class "connection", directly
Class "oldClass", by class "connection", distance 2

so there's no way to match USCSData,characterORconnection and the
selected method is elsewhere.

(1) I would have expected the search path to be like that for functions,
and that you'd find the IRanges definition before graph, since IRanges
is in front of graph on the search path (I don't think it should matter
that the definition is originally coming from Biostrings, and that
Biostrings is loaded but not attached).

> search()
 [1] ".GlobalEnv"          "package:rtracklayer" "package:RCurl"
 [4] "package:bitops"      "package:graph"       "package:stats"
 [7] "package:graphics"    "package:grDevices"   "package:utils"
[10] "package:datasets"    "package:methods"     "Autoloads"
[13] "package:base"

(2) within rtracklayer, the definition of 'file' reflects that in graph,
which is also funky, and which also 'explains' why dispatch fails.

> getClass("file", where=getNamespace("rtracklayer"))
Virtual Class "file" [package "Biostrings"]

Slots:

Name:   .S3Class
Class: character

Extends:
Class "connection", directly
Class "oldClass", by class "connection", distance 2

I constructed a simpler illustration, with 'pkgA' having a NAMESPACE

export(foo)

and a single file

setOldClass(c("file", "connection"))
setClassUnion("characterORconnection", c("character", "connection"))

setGeneric("fun", function(x) standardGeneric("fun"))
setMethod(fun, "characterORconnection", function(x) "OK")

foo <- function () fun(file())

Then if I

mtmorgan at linux-ibmc:/tmp> R
> library(pkgA)
> foo()
[1] "OK"

> setOldClass(c("file", "connection"))
> library(pkgA)
> foo()
Error in function (classes, fdef, mtable)  :
  unable to find an inherited method for function "fun", for signature
"file"

In this case, though, the package class definition still seems to be intact

> getClass("file", where=getNamespace("pkgA"))
Virtual Class "file" [package "pkgA"]

Slots:

Name:   .S3Class
Class: character

Extends:
Class "connection", directly
Class "oldClass", by class "connection", distance 2
Class "characterORconnection", by class "connection", distance 2

I forwarded an example to John Chambers, and will report back ...

Martin


> I have no idea why the object prints differently, but anyway, the main
> difference is that the dispatch changes.
> 
> It turns out that the graph package defines a file class, via
> setOldClass, inheriting from connection, which it also defines.
> Biostrings does this, too, and rtracklayer imports the ones from
> Biostrings. rtracklayer defines the characterORconnection class as a
> union of "character" and "connection".
> 
> Somewhere, the methods package must be using two different versions of
> "connection", etc, and get the inheritance wrong, messing up dispatch.
> One might ask, which version does "file" refer to in the selectMethod
> call. As far as I can tell, it should be the Biostrings one:
>> getClass("connection")@package
> [1] "Biostrings"
> 
> But that is weird, since Biostrings is not attached, while graph is.
> Must go by namespace load order. Anyway, at least within the rtracklayer
> namespace, the graph package should have no effect.
> 
> Any ideas Martin? Does John need to be involved?
> 
> Michael
> 
> On Fri, Dec 3, 2010 at 11:22 AM, mattia pelizzola
> <mattia.pelizzola at gmail.com <mailto:mattia.pelizzola at gmail.com>> wrote:
> 
>     Hi Martin,
> 
>     I am back on this rtracklayer issue after a while. There is a bug
>     specifically when the package graph is loaded too (before or after
>     rtracklayer). The code (apart from library(graph)) is from the
>     rtracklayer
>     vignette:
> 
>     > library(graph)
>     > library(rtracklayer)
>     Loading required package: RCurl
>     Loading required package: bitops
> 
>     > data(targets)
>     > targetRanges <- IRanges(targets$start, targets$end)
>     > targetTrack <- GenomicData(targetRanges, targets[, c("strand","name",
>     "target")], chrom = paste("chr", targets$chrom,sep = ""), genome =
>     "hg19")
>     > session <- browserSession("UCSC")
>     > track(session, "targets") <- targetTrack
>     Error: evaluation nested too deeply: infinite recursion /
>     options(expressions=)?
>     > traceback()
>     3313: mode(expr)
>     3312: match(x, table, nomatch = 0L)
>     3311: mode(expr) %in% c("call", "expression", "(", "function")
>     3310: deparse(substitute(arg))
>     3309: eval(formal.args[[deparse(substitute(arg))]])
>     3308: match.arg(subformat)
>     3307: export.ucsc(object, con, subformat, append, ...)
>     3306: export.ucsc(object, con, subformat, append, ...)
>     3305: export.ucsc(object, con, subformat, append, ...)
>     3304: export.ucsc(object, con, subformat, append, ...)
>     .............
>     26: export.ucsc(object, con, subformat, append, ...)
>     25: export.ucsc(object, con, subformat, append, ...)
>     24: export.ucsc(object, con, subformat, append, ...)
>     23: export.ucsc(object, con, subformat, append, ...)
>     22: export.ucsc(object, con, subformat, append, ...)
>     21: export.ucsc(object[[i]], con, subformat, name = trackNames[i],
>            append = append, ...)
>     20: export.ucsc(object[[i]], con, subformat, name = trackNames[i],
>            append = append, ...)
>     19: .local(object, con, subformat, append, ...)
>     18: fun(object, con, ...)
>     17: fun(object, con, ...)
>     16: export(object, con, format, ...)
>     15: export(object, con, format, ...)
>     14: export(object, format = "ucsc", subformat = format, ...)
>     13: export(object, format = "ucsc", subformat = format, ...)
>     12: .local(object, ...)
>     11: ucscForm(tracks, format, ...)
>     10: ucscForm(tracks, format, ...)
>     9: FUN(X[[1L]], ...)
>     8: lapply(split(X, group), FUN, ...)
>     7: tapply(value, unlist(genomes), function(tracks) {
>           form <- ucscForm(tracks, format, ...)
>           response <- ucscPost(object, "custom", form)
>       })
>     6: .local(object, ..., value = value)
>     5: `track<-`(`*tmp*`, name, ..., value = <S4 object of class
>     "RangedDataList">)
>     4: `track<-`(`*tmp*`, name, ..., value = <S4 object of class
>     "RangedDataList">)
>     3: .local(object, ..., value = value)
>     2: `track<-`(`*tmp*`, "targets", value = <S4 object of class
>     "RangedData">)
>     1: `track<-`(`*tmp*`, "targets", value = <S4 object of class
>     "RangedData">)
> 
>     > sessionInfo()
>     R version 2.12.0 (2010-10-15)
>     Platform: x86_64-unknown-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=C              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] stats     graphics  grDevices utils     datasets  methods   base
> 
>     other attached packages:
>     [1] rtracklayer_1.10.5 RCurl_1.5-0        bitops_1.0-4.1
>     graph_1.28.0
> 
>     loaded via a namespace (and not attached):
>     [1] Biobase_2.10.0      Biostrings_2.18.2   BSgenome_1.18.2
>     [4] GenomicRanges_1.2.1 IRanges_1.8.5       tools_2.12.0
>     [7] XML_3.2-0
> 
> 
>     I can't avoid having graph loaded since it is needed by GOstats, which I
>     need.
>     Thanks for any hint,
> 
>     mattia
> 
> 
> 
> 
> 
> 
> 
> 
>     On Fri, Jul 23, 2010 at 8:03 PM, Martin Morgan <mtmorgan at fhcrc.org
>     <mailto:mtmorgan at fhcrc.org>> wrote:
> 
>     > mattia pelizzola <mattia.pelizzola at gmail.com
>     <mailto:mattia.pelizzola at gmail.com>> writes:
>     >
>     > > Hi,
>     > >
>     > > I am running some code from the rtracklayer vignette. If I start
>     a new
>     > > R session and I load the rtracklayer only, the code works fine.
>     > > Unfortunately, I need many other packages at the same time. For some
>     > > reason when loading all the other packages I get this error:
>     > >
>     > >> data(targets)
>     > >> targetRanges <- IRanges(targets$start, targets$end)
>     > >> targetTrack <- GenomicData(targetRanges, targets[,
>     c("strand","name",
>     > "target")], chrom = paste("chr", targets$chrom,sep = ""), genome =
>     "hg19")
>     > >> session <- browserSession("UCSC")
>     > >> track(session, "targets") <- targetTracktrack(session,
>     "targets") <-
>     > targetTrack
>     > > Error: evaluation nested too deeply: infinite recursion /
>     > options(expressions=)?
>     > >
>     > >
>     > > I guess there is some issue with other packages. I already had
>     similar
>     > > problems with other function, like the complement function of
>     > > Biostrings, that was replaced by the complement function in the
>     graph
>     > > package .. so I found that the order the packages are loaded can be
>     > > critical. Not sure it is the same issue with rtracklayer though,
>     as I
>     > > have no clue on which package, if any, is interfering.
>     > > Any suggestion?
>     >
>     > Hi Mattia --
>     >
>     > traceback() after the error should be informative. This can be
>     fixed in
>     > the code that causes the problem, so let us know...
>     >
>     > Martin
>     >
>     > > thanks!
>     > > mattia
>     > >
>     > >> sessionInfo()
>     > > R version 2.11.0 (2010-04-22)
>     > > x86_64-unknown-linux-gnu
>     > >
>     > > 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=C              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] grid      stats     graphics  grDevices utils     datasets
>      methods
>     > > [8] base
>     > >
>     > > other attached packages:
>     > >  [1] rtracklayer_1.8.1
>     > >  [2] RCurl_1.4-2
>     > >  [3] RMySQL_0.7-4
>     > >  [4] BSgenome.Athaliana.TAIR.04232008_1.3.16
>     > >  [5] BSgenome.Mmusculus.UCSC.mm9_1.3.16
>     > >  [6] BSgenome.Hsapiens.UCSC.hg18_1.3.16
>     > >  [7] BSgenome_1.16.1
>     > >  [8] Biostrings_2.16.0
>     > >  [9] GenomicRanges_1.0.1
>     > > [10] GOstats_2.14.0
>     > > [11] graph_1.26.0
>     > > [12] Category_2.14.0
>     > > [13] org.Hs.eg.db_2.4.1
>     > > [14] RSQLite_0.9-0
>     > > [15] DBI_0.2-5
>     > > [16] AnnotationDbi_1.10.1
>     > > [17] Biobase_2.8.0
>     > > [18] marray_1.26.0
>     > > [19] limma_3.4.0
>     > > [20] gplots_2.7.4
>     > > [21] caTools_1.10
>     > > [22] bitops_1.0-4.1
>     > > [23] gdata_2.8.0
>     > > [24] gtools_2.6.2
>     > > [25] nlme_3.1-96
>     > > [26] snow_0.3-3
>     > > [27] IRanges_1.6.1
>     > >
>     > > loaded via a namespace (and not attached):
>     > >  [1] annotate_1.26.0   genefilter_1.30.0 GO.db_2.4.1
>     > GSEABase_1.10.0
>     > >  [5] lattice_0.18-5    RBGL_1.24.0       splines_2.11.0
>     >  survival_2.35-8
>     > >  [9] tools_2.11.0      XML_3.1-0         xtable_1.5-6
>     > >
>     > > _______________________________________________
>     > > Bioconductor mailing list
>     > > Bioconductor at stat.math.ethz.ch
>     <mailto:Bioconductor at stat.math.ethz.ch>
>     > > https://stat.ethz.ch/mailman/listinfo/bioconductor
>     > > Search the archives:
>     > http://news.gmane.org/gmane.science.biology.informatics.conductor
>     >
>     > --
>     > Martin Morgan
>     > 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
>     >
> 
>            [[alternative HTML version deleted]]
> 
>     _______________________________________________
>     Bioconductor mailing list
>     Bioconductor at r-project.org <mailto:Bioconductor at r-project.org>
>     https://stat.ethz.ch/mailman/listinfo/bioconductor
>     Search the archives:
>     http://news.gmane.org/gmane.science.biology.informatics.conductor
> 
> 


-- 
Computational Biology
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N. PO Box 19024 Seattle, WA 98109

Location: M1-B861
Telephone: 206 667-2793



More information about the Bioconductor mailing list