Also handy, IMHO:

# intersection
setGeneric('%i%', # {{{
  function(x, y) standardGeneric('%i%')
) # }}}
setMethod('%i%', c('ANY','ANY'), function(x, y) { # {{{
  intersect(x, y)
}) # }}}

# union
setGeneric('%u%', # {{{
  function(x, y) standardGeneric('%u%')
) # }}}
setMethod('%u%', c('ANY','ANY'), function(x, y) { # {{{
  union(x, y)
}) # }}}

# setdiff
setGeneric('%d%', # {{{
  function(x, y) standardGeneric('%d%')
) # }}}
setMethod('%d%', c('ANY','ANY'), function(x, y) { # {{{
  setdiff(x, y)
}) # }}}

# subsetByOverlaps
setGeneric('%s%', # {{{
  function(x, y) standardGeneric('%s%')
) # }}}
setMethod('%s%', c('GRanges','GRanges'), function(x, y) { # {{{
  subsetByOverlaps(x, y)
}) # }}}

Reason being that something like

( hESC.H3K4ME1 %s% hESC.P300 ) %u% ( hESC.H3K4ME3 %s% hESC.H3K27ME3)

can be very handy at times, and all of these operators are rather naturally
associative IMHO.




On Sun, Feb 19, 2012 at 11:03 PM, Tim Triche, Jr. <tim.triche@gmail.com>wrote:

> setMethod("$", "GRanges", function(x, name) { # {{{
>   elementMetadata(x)[, name]
> }) # }}}
>
> setMethod("$<-", "GRanges", function(x, name, value) { # {{{
>   elementMetadata(x)[[ name ]] <- value
>   return(x)
> }) # }}}
>
> problem solved :-)
>
> Of course you might want to play with SummarizedExperiment as well.
>
>
>
> On Sun, Feb 19, 2012 at 10:26 PM, Paul Leo <p.leo@uq.edu.au> wrote:
>
>>
>> I want to add extra column(s) to the elementMetaData of a GRanges object
>> is there a short hand way of doing that?
>>
>> Other than extracting the meta data as a data frame ... adding what I
>> want... and then reassigning:
>>
>> THAT IS  NOT:
>>
>> extra.blank<-matrix(data=NA,nrow=length(a.grs),ncol=length(missing.meta.cols))
>>  old.meta<-as.data.frame(values(a.grs))
>>  new.meta<-cbind(old.meta,extra.blank)
>>  values(a.grs)<-new.meta
>>
>>
>> I'm missing something obvious ...!
>>
>> Thanks
>> Paul
>>
>>
>> Wish LIST:
>> Other wise it would be extremely helpful to have a native
>>
>> c(..., .interesction)
>> c(..., .union)
>>
>> where you could combine GRanges with different metaData , where
>> intersection just kept the metadata in common and union just added NA
>> for missing metavalues.
>>
>> .... for use in combining vcf files for say snp, and deletion adat where
>> the meta data might have different attributes and it's not convenient to
>> use a list..
>>
>> _______________________________________________
>> Bioconductor mailing list
>> Bioconductor@r-project.org
>> https://stat.ethz.ch/mailman/listinfo/bioconductor
>> Search the archives:
>> http://news.gmane.org/gmane.science.biology.informatics.conductor
>>
>
>
>
> --
> *A model is a lie that helps you see the truth.*
> *
> *
> Howard Skipper<http://cancerres.aacrjournals.org/content/31/9/1173.full.pdf>
>
>


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

