[Bioc-sig-seq] the as.matrix method of the RangesMatchingList

Nicolas Delhomme delhomme at embl.de
Wed May 13 16:05:29 CEST 2009


Hi all,

I've got the impression that the as.matrix method of the  
RangesMatchingList does not work as it should.

I have a RangesMatchingList which I obtained by using the overlap  
(from the RangesList class) function that takes two RangesList as  
input. When I apply as.matrix() on the RangesMatchingList, it gives me  
the following error:

Error in .Method(..., deparse.level = deparse.level) :
   number of rows of matrices must match (see arg 2)

The function is pretty easy:

setMethod("as.matrix", "RangesMatchingList", function(x) {
   cbind(space = space(x), do.call(cbind, lapply(x, as.matrix)))
})

When I replace the cbind in the do.call by an rbind, it's already better

Warning message:
In .Method(..., deparse.level = deparse.level) :
   number of rows of result is not a multiple of vector length (arg 1)

This is due to the fact that space(x) returns many more spaces than  
there are overlaps.

I could solve that by changing the function into:

setMethod("as.matrix", "RangesMatchingList", function(x) {
   do.call(rbind,lapply(c(1:length(x)),function(i){mat <-  
as.matrix(x[[i]]);cbind(space=rep(names(x)[[i]],nrow(mat)),mat)}))
})

Now, I do not know if I might have a particular use-case (having a  
RangesMatchingList coming from the RangesList overlap function) that  
you guys did not think of.

Just let me know,

Best,

---------------------------------------------------------------
Nicolas Delhomme

High Throughput Functional Genomics Center

European Molecular Biology Laboratory

Tel: +49 6221 387 8426
Email: nicolas.delhomme at embl.de
Meyerhofstrasse 1 - Postfach 10.2209
69102 Heidelberg, Germany



More information about the Bioc-sig-sequencing mailing list