also, S3 generics are oo-oo-bad

Personally, given the infrastructure that is developing around
SummarizedExperiment and GRanges (for visualization etc.), I think it is a
good idea.

setAs("GRanges", "SummarizedExperiment",  # elementMetadata becomes
assays[[1]]
  function(from) { # {{{
    asy.dat = elementMetadata(from)
    elementMetadata(from) <- NULL
    rowData = from
    return(SummarizedExperiment(assays=asy.dat, rowData=rowData))
  }) # }}}

setAs("SummarizedExperiment", "GRanges",   # just use the first assay
element
  function(from) { # {{{
    warning('GRanges to SummarizedExperiment retains ONLY the first
assay...')
    GR = rowData(from)
    elementMetadata(GR) = as(assays(from)[[1]], 'DataFrame')
    an = names(assays(from, withDimnames=FALSE))[1]
    names(elementMetadata(GR)) = paste(names(elementMetadata(GR)), an,
sep='.')
    return(GR)
}) # }}}


I told Aedin I'd start writing things that go from FooSets to SummarizedBar
to BazRanges so I did...  SummarizedExperiment is the logical choke-point
for all of the above, given that it is coordinate-based but rectangular.
 It's not a perfect fit but nothing in this life is.

At some point I'd like to discuss the pros and cons of data.table vs.
data.frame for applications that talk to databases and emit SEs and/or
Ranges.



On Mon, Mar 19, 2012 at 5:50 AM, Steve Lianoglou <
mailinglist.honeypot@gmail.com> wrote:

> Hi Tim,
>
> On Mon, Mar 19, 2012 at 8:02 AM, Tim Yates <TYates@picr.man.ac.uk> wrote:
> [snip]
>
> > `$.GRanges`   = function( x, name )        {
> >  elementMetadata( x )[[ name ]]
> > }
> > `$<-.GRanges` = function( x, name, value ) {
> >  elementMetadata( x )[[ name ]] = value
> >  x
> > }
> >
> > Then all the above functions behave in a similar fashion, however I
> don't want to do this in my package, as I believe it will be a gateway to
> namespace hell…
> >
> > Is there any plan to add this accessor operator to Granges so that
> access is normalised across all three of these types?
>
> This does seem to come up every now and again. Most recently (I think)
> in this post:
>
>
> http://thread.gmane.org/gmane.science.biology.informatics.conductor/39169/focus=39189
>
> There is a *technically* correct reason as to why there's no `$`
> accessor on GRanges that is explained there by Martin (it has to do w/
> GRanges extending the Vector class), but still ... it seems that some
> of us feel like we still want it, even if it's bad for us. :-)
>
> -steve
>
> --
> Steve Lianoglou
> Graduate Student: Computational Systems Biology
>  | Memorial Sloan-Kettering Cancer Center
>  | Weill Medical College of Cornell University
> Contact Info: http://cbio.mskcc.org/~lianos/contact
>
> _______________________________________________
> Bioc-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/bioc-devel
>



-- 
*A model is a lie that helps you see the truth.*
*
*
Howard Skipper<http://cancerres.aacrjournals.org/content/31/9/1173.full.pdf>

	[[alternative HTML version deleted]]

