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

Wolfgang Huber huber at ebi.ac.uk
Wed May 13 16:11:15 CEST 2009



A tangential remark, nevertheless...:
   seq(along=x)
is equivalent to and sometimes probably closer to what you want than
   c(1:length(x))

  Best wishes	
  Wolfgang


Nicolas Delhomme ha scritto:
> 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
> 
> _______________________________________________
> Bioc-sig-sequencing mailing list
> Bioc-sig-sequencing at r-project.org
> https://stat.ethz.ch/mailman/listinfo/bioc-sig-sequencing


-- 

Best wishes
      Wolfgang

------------------------------------------------
Wolfgang Huber, EMBL, http://www.ebi.ac.uk/huber



More information about the Bioc-sig-sequencing mailing list