[Bioc-sig-seq] `+` for GenomeData and coverage from several lanes

Simon Anders anders at ebi.ac.uk
Sun Jul 5 20:33:53 CEST 2009


Hi

I'm stupid, I've forgotten the "1:".

>> system.time({
> +    cvg2 <- GenomeData( list() )
> +    for( i in length(lanes) )
                 ^^^^^^^^^^^^^
> +       cvg2 <- cvg2 + coverage( lanes[[i]], width=seqlens )
> + })
>    user  system elapsed
>  56.551   9.050  65.634

No wonder that the for loop was so drastically faster; it was iterated
only once.

Here are the correct timings:

> system.time({
+    cvg2 <- GenomeData( list() )
+    for( i in seq_along(lanes) )
+       cvg2 <- cvg2 + coverage( lanes[[i]], width=seqlens )
+ })
   user  system elapsed
378.704 102.946 482.406

> system.time(
+    cvg1 <- Reduce( `+`, lapply( lanes, coverage, width=seqlens ) )
+ )
   user  system elapsed
377.510 101.509 484.885

So, there is no performance difference between 'Reduce' and 'for'. Sorry
for the nonsense.

  Simon



More information about the Bioc-sig-sequencing mailing list