[Bioc-devel] mcols<-() behaviour inheriting from Vector vs GRanges

Malcolm Perry mgperry32 at gmail.com
Tue Jan 5 15:30:36 CET 2016


Fantastic, thanks Herve.

On Tue, Jan 5, 2016 at 1:32 AM, Hervé Pagès <hpages at fredhutch.org> wrote:

> This is fixed in S4Vectors release (0.8.6) and devel (0.9.16).
>
> Cheers,
> H.
>
>
> On 01/04/2016 11:52 AM, Hervé Pagès wrote:
>
>> Hi Malcolm,
>>
>> Thanks for reporting this. Will fix.
>>
>> H.
>>
>> On 01/04/2016 10:53 AM, Malcolm Perry wrote:
>>
>>> Hello,
>>>
>>> A recent question on the support site (
>>> https://support.bioconductor.org/p/76430/#76460) shows that the mcols
>>> assignment in GRanges (and perhaps others) is subtly different from
>>> classes
>>> that purely inherit from Vector (such as GenomicInteractions in the
>>> example), as the GRanges method will implicitly convert a data.frame
>>> object
>>> to a "DataFrame".
>>>
>>> Is it possible for Vector to have the same behaviour? From the users'
>>> perspective it looks like a bug in the downstream package, and I guess
>>> many
>>> people will not spot the obvious fix.
>>>
>>> Thanks,
>>>
>>> Malcolm
>>>
>>> PS Here is a self-contained example just using the core packages and no
>>> external data:
>>>
>>> library(S4Vectors)
>>>
>>> setClass("CharacterVector",
>>>      representation(char_data = "character"),
>>>      contains="Vector"
>>> )
>>>
>>> setMethod(length, "CharacterVector", function(x) length(x at char_data))
>>>
>>> char = new("CharacterVector", char_data=c("one", "two", "three"))
>>>
>>> mcols(char) = data.frame(number=1:3) # will fail
>>>
>>> mcols(char) = DataFrame(number=1:3) # fine
>>>
>>> library(GenomicRanges)
>>>
>>> gr = GRanges("chr", IRanges(1, 5))
>>>
>>> mcols(gr) = data.frame(name="range1")
>>>
>>>     [[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 fredhutch.org
> Phone:  (206) 667-5791
> Fax:    (206) 667-1319
>

	[[alternative HTML version deleted]]



More information about the Bioc-devel mailing list