[BioC] multicore and GRangesList

Martin Morgan mtmorgan at fhcrc.org
Tue Jan 11 21:35:16 CET 2011


On 01/11/2011 06:34 AM, arne.mueller at novartis.com wrote:
> Dear All,
> 
> Has anybody experience using the multicore package with GRangesLists from 
> the GenomicRanges package? I can't get it working ..., here's an example:
> 
>> a = GRanges(seqnames="A", ranges=IRanges(start=1:3, width=5))
>> b = GRanges(seqnames="A", ranges=IRanges(start=c(10,20,30), width=5))
>> grl = GRangesList(a, b)
>> sapply(grl, length)
> [1] 3 3
>> mclapply(grl, length, mc.cores=2)
> [[1]]
> [1] "Error in as.list.default(X) : \n  no method for coercing this S4 
> class to a vector\n"

A hack is

  assignInNamespace("lapply", lapply, "base")

and then

  idx <- seq_len(1000)
  res3 <- mclapply(tx[idx], length)

this is about 6x faster than Cory's

  mclapply(idx, function(i, grl) length(grl[[i]]), tx[idx])

because lapply,GRangesList is being more efficient at extracting ranges
than [[ (maybe less validity checking?).

I think this should scale with the number of cores, but for whatever
reason all my processes stay on the same cpu.

Martin

> 
> [[2]]
> [1] "Error in as.list.default(X) : \n  no method for coercing this S4 
> class to a vector\n"
> 
> 
>> sessionInfo()
> R version 2.13.0 Under development (unstable) (2010-12-20 r53870)
> Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)
> 
> locale:
> [1] en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8
> 
> attached base packages:
> [1] stats     graphics  grDevices utils     datasets  methods   base 
> 
> other attached packages:
> [1] multicore_0.1-3     GenomicRanges_1.3.7 IRanges_1.9.17 
> 
> loaded via a namespace (and not attached):
> [1] tools_2.13.0
> 
>     thanks a lot for hints ..
> 
>    arne
> 	[[alternative HTML version deleted]]
> 
> _______________________________________________
> Bioconductor mailing list
> Bioconductor at r-project.org
> https://stat.ethz.ch/mailman/listinfo/bioconductor
> Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor


-- 
Computational Biology
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N. PO Box 19024 Seattle, WA 98109

Location: M1-B861
Telephone: 206 667-2793



More information about the Bioconductor mailing list