Bioconductor / SummarizedExperiment

A container (S4 class) for matrix-like assays
https://bioconductor.org/packages/SummarizedExperiment
33 stars 9 forks source link

More informative error message for mismatching numbers of rows #46

Open LTLA opened 4 years ago

LTLA commented 4 years ago

Consider the following example:

library(SummarizedExperiment)
se <- SummarizedExperiment(assays=list(X=cbind(1:10)))
cbind(se, se[1:5,])
## Error in cbind(...) : number of rows of matrices must match (see arg 2)

Okay, that's pretty helpful. But the following is more obscure:

se <- SummarizedExperiment(rowData=DataFrame(X=1:10))
cbind(se, se[1:5,])
## Error in FUN(X[[i]], ...) :
##   column(s) 'X' in ‘mcols’ are duplicated and the data do not match

Of course, I know why this happens, but it would be a lot nicer if it could just say "number of rows don't match". This is especially important because I use SE's cbind internally in some SCE methods; currently, the user ends up with a message about some column they never actually created themselves, while the real error has to do with a mismatching number of rows.