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

Malcolm Perry mgperry32 at gmail.com
Mon Jan 4 19:53:31 CET 2016


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.



PS Here is a self-contained example just using the core packages and no
external data:


    representation(char_data = "character"),

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


gr = GRanges("chr", IRanges(1, 5))

mcols(gr) = data.frame(name="range1")

	[[alternative HTML version deleted]]

More information about the Bioc-devel mailing list