[Bioc-devel] GenomicRanges: Concatenation of GRanges with matrices in mcols

Julian Gehring julian.gehring at embl.de
Tue May 20 10:22:40 CEST 2014


Hi,

If I want to bind two GRanges object with a matrix in the meta columns, 
the concatenation of the two fails in bioc-stable (GenomicRanges 1.16.3) 
and bioc-devel (GenomicRanges 1.17.13) with:

'''
Error in validObject(.Object) :
   invalid class “GRanges” object: number of rows in DataTable 
'mcols(x)' must match length of 'x'
'''

If multiple columns are used, the class of of the first column seem to 
determine the behavior:

#+BEGIN_SRC R
   library(GenomicRanges)

   ## sample data, two identical GRanges
   gr1 = gr2 = GRanges(1, IRanges(1:2, width = 1))
   m = matrix(1:4, 2)

   ## the vector alone works
   mcols(gr1) = mcols(gr2) = DataFrame(x = 1)
   c(gr1, gr2) ## works

   ## vector first, matrix second works
   mcols(gr1) = mcols(gr2) = DataFrame(x = 1, m = I(m))
   c(gr1, gr2) ## works

   ## the matrix alone fails
   mcols(gr1) = mcols(gr2) = DataFrame(m = I(m))
   c(gr1, gr2) ## fails

   ## matrix first, vector second fails
   mcols(gr1) = mcols(gr2) = DataFrame(m = I(m), x = 1)
   c(gr1, gr2) ## fails
#+END_SRC

Best wishes
Julian



More information about the Bioc-devel mailing list