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

Steve Lianoglou mailinglist.honeypot at gmail.com
Fri Apr 27 02:17:01 CEST 2012


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



More information about the Bioc-devel mailing list