[Bioc-devel] Recent issue with plot method dispatch

Martin Morgan mtmorgan at fhcrc.org
Wed Mar 13 20:32:57 CET 2013


On 03/13/2013 04:02 AM, Joern Toedling wrote:
> Hello,
>
> I have encountered a strange issue with the plotting function in my package
> "girafe" that I need some help with. I haven't changed anything in the plot
> methods or the NAMESPACE of the package recently, and it worked before, yet I
> observe the following error now.
>
> When calling the "plot" method for objects of the class
> "AlignedGenomeIntervals", rather than using the appropriate S4 method and
> calling another function (plotAligned), R falls back to the S3 method
> "plot.Intervals_full" (Intervals_full is the class that AlignedGenomeIntervals
> indirectly inherits from). Please see below for the sessionInfo() output.
>
> Has anybody encountered the same behaviour or any insights what might be going
> on? I'm grateful for any suggestions what I could fix in the method definition
> and/or the NAMESPACE. I guess as a workaround I could add an S3 plot method for
> the "AlignedGenomeIntervals" calls but that would be rather ugly.

I think this is a bug in S4, triggered by complex relations between the 
intervals and girafe package. I'll pursue this on R-devel.

I can reproduce this with a PkgA that has DESCRIPTION with

Depends: intervals
Imports: graphics

NAMESPACE:

importFrom(graphics, "plot")
export("plot")
exportMethods("plot")

R/tmp.R

setClass("A")
setMethod("plot", "A", function(x, y, ...) {})


and then

 > library(PkgA)
Loading required package: intervals
 > plot
function (x, y, ...)
UseMethod("plot")
<environment: namespace:graphics>

notice that 'plot' is reported as an S3 generic, but should be an S4 generic.

Removing Depends: intervals or changing to importsFrom(intervals, "plot") 
recovers S4 export

 > library(PkgA)
Loading required package: intervals
 > plot
standardGeneric for "plot" defined from package "graphics"

function (x, y, ...)
standardGeneric("plot")
<environment: 0x60aea90>
Methods may be defined for arguments: x, y
Use  showMethods("plot")  for currently available ones.


The 'intervals' package Depends: on methods but nothing else. It defines S3 and 
S4 methods on plot, creating an implicit S4 generic in the process. It's 
NAMESPACE has

S3method( "plot", "Intervals" )
S3method( "plot", "Intervals_full" )
exportMethods("plot")

and we have

 > library(intervals)
 > plot
standardGeneric for "plot" defined from package "graphics"

function (x, y, ...)
standardGeneric("plot")
<environment: 0x68cdc78>
Methods may be defined for arguments: x, y
Use  showMethods("plot")  for currently available ones.



>
> Thanks in advance,
> Joern
>
>
>  > sessionInfo()
> R Under development (unstable) (2013-03-12 r62224)
> Platform: x86_64-unknown-linux-gnu (64-bit)
> ...
> other attached packages:
>   [1] org.Mm.eg.db_2.9.0     RSQLite_0.11.2 DBI_0.2-5
>   [4] AnnotationDbi_1.21.13  Biobase_2.19.3 girafe_1.11.2
>   [7] genomeIntervals_1.15.1 intervals_0.14.0 ShortRead_1.17.10
> [10] latticeExtra_0.6-24    RColorBrewer_1.0-5 lattice_0.20-13
> [13] Rsamtools_1.11.21      Biostrings_2.27.11 GenomicRanges_1.11.36
> [16] IRanges_1.17.37        BiocGenerics_0.5.6 BiocInstaller_1.9.7
>
> loaded via a namespace (and not attached):
> [1] bitops_1.0-5    BSgenome_1.27.1 hwriter_1.3     stats4_3.1.0
> [5] tcltk_3.1.0     tools_3.1.0     zlibbioc_1.5.0
>
>
> Example producing the error:
>
> library("girafe")
> example("plotAligned")
>
>
>
>


-- 
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



More information about the Bioc-devel mailing list