[BioC] no method for coercing S4 class to a vector

Ninni Nahm ninninahm at gmail.com
Fri Sep 12 15:39:26 CEST 2014


Thank you! That did the trick!

On Fri, Sep 12, 2014 at 2:45 PM, Andrzej Oleś <andrzej.oles at gmail.com>
wrote:

> Dear Ninni,
>
> you probably need to import the 'as.data.frame' method for GRanges
> objects in your NAMESPACE file:
>
> importMethodsFrom(GenomicRanges, as.data.frame)
>
>
> Cheers,
> Andrzej
>
> On Fri, Sep 12, 2014 at 10:27 AM, Ninni Nahm [guest]
> <guest at bioconductor.org> wrote:
> >
> > Dear all,
> >
> > I have a similar problem to this poster here:
> >
> >
> http://grokbase.com/t/r/bioc-devel/141cegqvpf/no-method-for-coercing-this-s4-class-to-a-vector
> >
> > The error message is:
> >
> > Error in as.vector(x) : no method for coercing this S4 class to a vector
> >
> >
> > In my case, however, I'm using the as.data.frame function on a GRanges
> object. When I source my function it works fine, but when I make it into a
> package and then run the function I get the S4 class error.
> >
> > The function seems to be from BiocGenerics:
> >
> >> as.data.frame
> > standardGeneric for "as.data.frame" defined from package "BiocGenerics"
> >
> > function (x, row.names = NULL, optional = FALSE, ...)
> > standardGeneric("as.data.frame")
> > <environment: 0x3801ad8>
> > Methods may be defined for arguments: x
> > Use  showMethods("as.data.frame")  for currently available ones.
> >
> >
> > So, I have included this
> > importFrom("BiocGenerics", as.data.frame)
> > in NAMESPACE
> >
> > and this
> > Depends: BiocGenerics
> > in DESCRIPTION.
> >
> > It still does not work. I must be missing something.
> >
> > Any help is highly appreciated!
> >
> > Thanks
> > Ninni
> >
> >
> >  -- output of sessionInfo():
> >
> >> sessionInfo()
> > R version 3.1.1 (2014-07-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  stats     graphics  grDevices utils     datasets  methods
> > [8] base
> >
> > other attached packages:
> > [1] rtracklayer_1.24.0   GenomicRanges_1.16.2 GenomeInfoDb_1.0.2
> > [4] IRanges_1.22.10      BiocGenerics_0.10.0
> >
> > loaded via a namespace (and not attached):
> >  [1] BatchJobs_1.2           BBmisc_1.6              BiocParallel_0.6.0
> >  [4] Biostrings_2.32.0       bitops_1.0-6            brew_1.0-6
> >  [7] BSgenome_1.32.0         codetools_0.2-9         DBI_0.2-7
> > [10] digest_0.6.4            fail_1.2                foreach_1.4.2
> > [13] GenomicAlignments_1.0.0 iterators_1.0.7         plyr_1.8.1
> > [16] Rcpp_0.11.1             RCurl_1.95-4.1          Rsamtools_1.16.0
> > [19] RSQLite_0.11.4          sendmailR_1.1-2         stats4_3.1.1
> > [22] stringr_0.6.2           tools_3.1.1             XML_3.98-1.1
> > [25] XVector_0.4.0           zlibbioc_1.10.0
> >
> > --
> > Sent via the guest posting facility at bioconductor.org.
> >
> > _______________________________________________
> > Bioconductor mailing list
> > Bioconductor at r-project.org
> > https://stat.ethz.ch/mailman/listinfo/bioconductor
> > Search the archives:
> http://news.gmane.org/gmane.science.biology.informatics.conductor
>

	[[alternative HTML version deleted]]



More information about the Bioconductor mailing list