[BioC] Add extra columns to GRanges Metadata

Martin Morgan mtmorgan at fhcrc.org
Tue Feb 21 01:33:53 CET 2012


On 02/20/2012 11:50 AM, Tengfei Yin wrote:
> +1 for Tim's methods.....especially the $ and $<- method, it's always in a
> wishlist for me :)
>
> well, maybe "$ " could be sometimes confusing when people trying to treat
> GRanges as a general format similar to data.frame, and do something like
> gr$seqnames<- blabla, the good part about current API is that it remind me
> the difference bettween  elementMetadata and three required fields... but

GRanges extends Vector and

 > gr = GRanges("A", IRanges(1:10, 20), X=1:10, Y=1:10)
 > length(gr)
[1] 10
 > length(values(gr))
[1] 2

shows the geometry -- one would expect gr$foo to access the range named 
'foo' rather than the column of elementMetadata named 'foo'. I think 
this is the crux of the resistance.

When Tim says

On 02/20/2012 11:45 AM, Tim Triche, Jr. wrote:
 > if these don't belong in BiocGenerics, I don't know what does :-D

I'm not sure if the reference is to "intersect" (which is already in 
BiocGenerics), "%i%" etc., or to $ and $<-. For $ and $<-, they don't 
need to be in BiocGenerics because they are already made generics by the 
methods package -- BiocGenerics is meant to provide a place to define 
generics that would otherwise be defined independently in multiple packages.

Martin

> it will be convenient if general $ method support replacement? even for
> seqnames, strand and ranges part? with default checking?
>
> other methods mentioned by Tim are also handy if default of those function
> is under assumption.
>
> On Mon, Feb 20, 2012 at 1:04 PM, Michael Lawrence<lawrence.michael at gene.com
>> wrote:
>
>> On Mon, Feb 20, 2012 at 10:36 AM, Steve Lianoglou<
>> mailinglist.honeypot at gmail.com>  wrote:
>>
>>> Hi Tim,
>>>
>>> These functions are quite handy ... definitely going to poach them.
>>>
>>
>>
>> I wonder if we should keep poaching these in the wild or if Bioc Core will
>> ever bow to popular pressure and allow their inclusion in the base
>> packages? ;-)
>>
>>
>>> Also ... you need an editor with better code folding support ;-)
>>>
>>> Pual,
>>>
>>> Aslo, to do what you want to do, namely:
>>>
>>>>
>>>
>> 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
>>>
>>> Using vanilla GenomicRanges functionality, you just do this:
>>>
>>> R>  values(a.grs)<- cbind(values(a.grs), DataFrame(extra.blank))
>>>
>>> HTH,
>>>
>>> -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
>>>
>>> _______________________________________________
>>> 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]]
>>
>> _______________________________________________
>> 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
>>
>
>
>


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