[Bioc-devel] Propose to pass `...` to as.data.frame, GenomicRanges

Hervé Pagès hpages at fhcrc.org
Mon Apr 30 20:33:19 CEST 2012


On 04/26/2012 05:50 PM, Michael Lawrence wrote:
> Seems reasonable to me...
>

Yep. Steve, do you want to go ahead and commit that? (Note that
man/GRanges-class.Rd would also need to be adjusted.)

Thanks,
H.

> On Thu, Apr 26, 2012 at 5:17 PM, Steve Lianoglou<
> mailinglist.honeypot at gmail.com>  wrote:
>
>> Howdy,
>>
>> I was chasing some weird bug for a while which was due to a library I
>> use working differently w/ factors and the fact that a call to
>> as.data.frame(GRanges)  doesn't let you specify how you want to handle
>> stringsAsFactors for the character columns of the
>> GRanges at elementMetadata.
>>
>> What do you say to a change that passes `...` down to the
>> `as.data.frame(elementMetadata(x))` call in the following method def
>> (GenomicRanges-class.R#Line245) here so it becomes
>> `as.data.frame(elementMetadata(x), ...)` allowing us to control this
>> behavior:
>>
>> setMethod("as.data.frame", "GenomicRanges",
>>     function(x, row.names=NULL, optional=FALSE, ...)
>>     {
>>         ranges<- ranges(x)
>>         if (missing(row.names))
>>             row.names<- names(x)
>>         if (!is.null(names(x)))
>>             names(x)<- NULL
>>         data.frame(seqnames=as.factor(seqnames(x)),
>>                    start=start(x),
>>                    end=end(x),
>>                    width=width(x),
>>                    strand=as.factor(strand(x)),
>>                    as.data.frame(elementMetadata(x)), ##<-- here
>>                    row.names=row.names,
>>                    stringsAsFactors=FALSE)
>>     }
>> )
>>
>> -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 at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/bioc-devel
>>
>
> 	[[alternative HTML version deleted]]
>
> _______________________________________________
> Bioc-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/bioc-devel


-- 
Hervé Pagès

Program in Computational Biology
Division of Public Health Sciences
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N, M1-B514
P.O. Box 19024
Seattle, WA 98109-1024

E-mail: hpages at fhcrc.org
Phone:  (206) 667-5791
Fax:    (206) 667-1319



More information about the Bioc-devel mailing list