Bioconductor / SummarizedExperiment

SummarizedExperiment container
https://bioconductor.org/packages/SummarizedExperiment
29 stars 9 forks source link

colData assignment should fail but does not #36

Open vjcitn opened 4 years ago

vjcitn commented 4 years ago
library(SummarizedExperiment)
mymat = matrix((1:6)*1.0, nc=3)
dimnames(mymat) = list(c("A", "B"), letters[1:3])
se1 = SummarizedExperiment(mymat)
validObject(se1)
library(S4Vectors)
ndf = DataFrame(v1=10:12)
rownames(ndf) = letters[3:1]
ndf
colData(se1) = ndf 
newAa = assay(se1["A", "a"])
newAa
newAa == oldAa 

The content of the sample denoted a in the assay has changed through colData assignment. This seems incompatible with

297     \item{\code{colData(x)}, \code{colData(x) <- value}:}{Get or set the
298       column data. \code{value} is a \link{DataFrame} object. Row
299       names of \code{value} must be NULL or consistent with the existing
300       column names of \code{x}.}

in SummarizedExperiment-class.Rd. I propose that we tighten the "or consistent with" with "identical to" and throw an error in the code if that condition does not hold.

hpages commented 4 years ago

Sounds reasonable. So to be precise, colData(se) <- DF:

The only worry is backward compatibility. This change together with the change discussed in issue #35 are likely to break existing code in various places. Hopefully it won't be too bad.