LTLA / InteractionSet

Clone of the Bioconductor repository for the InteractionSet package, see https://bioconductor.org/packages/devel/bioc/html/InteractionSet.html for the official development version.
2 stars 0 forks source link

Combining two InteractionSet objects with `c()` fails #6

Closed liz-is closed 5 years ago

liz-is commented 5 years ago

Hey,

I get an error when trying to combine two InteractionSet objects with c(). InteractionSet v 1.10.0, R v 3.5.1. The error is:

> c(iset1, iset2)
# Error in validObject(ans) : invalid class “InteractionSet” object: 
#  nb of rows in 'assay' (20) must equal nb of rows in 'rowData' (40)

rbind does what I'm looking for, but I'd expect c to also work here. Is this a bug or is there something I'm missing?

Reproducible example and sessionInfo below. Thanks!

> library(InteractionSet)
> example(GInteractions, echo=FALSE)
> Nlibs <- 4
> counts <- matrix(rpois(Np*Nlibs, lambda=10), ncol=Nlibs)
> colnames(counts) <- seq_len(Nlibs)
> 
> iset <- InteractionSet(counts, gi)
> c(iset, iset)
# Error in validObject(ans) : invalid class “InteractionSet” object: 
#  nb of rows in 'assay' (20) must equal nb of rows in 'rowData' (40)
> sessionInfo()
# R version 3.5.1 (2018-07-02)
# Platform: x86_64-apple-darwin15.6.0 (64-bit)
# Running under: macOS Sierra 10.12.6
# 
# Matrix products: default
# BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
# LAPACK: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRlapack.dylib
# 
# locale:
#   [1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8
# 
# attached base packages:
#   [1] parallel  stats4    stats     graphics  grDevices utils     datasets  methods   base     
# 
# other attached packages:
#   [1] InteractionSet_1.10.0       SummarizedExperiment_1.12.0 DelayedArray_0.8.0         
# [4] BiocParallel_1.16.5         matrixStats_0.54.0          Biobase_2.42.0             
# [7] GenomicRanges_1.34.0        GenomeInfoDb_1.18.1         IRanges_2.16.0             
# [10] S4Vectors_0.20.1            BiocGenerics_0.28.0        
# 
# loaded via a namespace (and not attached):
#   [1] Rcpp_1.0.0             lattice_0.20-38        bitops_1.0-6           grid_3.5.1            
# [5] zlibbioc_1.28.0        XVector_0.22.0         Matrix_1.2-15          tools_3.5.1           
# [9] RCurl_1.95-4.11        yaml_2.2.0             compiler_3.5.1         GenomeInfoDbData_1.2.0
LTLA commented 5 years ago

This is consistent with the behaviour of the base SummarizedExperiment class:

library(SummarizedExperiment)
example(SummarizedExperiment, echo=FALSE)
c(se, se)
## Error in validObject(.Object) : 
##   invalid class “SummarizedExperiment” object: 
##   nb of rows in 'assay' (200) must equal nb of rows in 'rowData' (400)

Recalling my discussions with the BioC core developers, c was deliberately not supported for 2D objects like SEs, because using rbind/cbind was clearer w.r.t. the dimension being combined.

liz-is commented 5 years ago

That's fair enough. IMO the error message could be improved to make it clearer that this is deliberately not supported, but it's not a big deal.

LTLA commented 5 years ago

You should post an issue at the SE repo, it's not the first time the error message was cryptic.