[Bioc-devel] mcols<-() behaviour inheriting from Vector vs GRanges
Hervé Pagès
hpages at fredhutch.org
Mon Jan 4 20:52:34 CET 2016
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
More information about the Bioc-devel
mailing list