[Bioc-devel] as.list.List (was Re: parallel package generics)

Cook, Malcolm MEC at stowers.org
Thu Oct 25 22:35:48 CEST 2012


Martin,

Great.  Nice, and makes sense, and should be added to R/List-class

But, but

It is 'a good thing' that it make Reduce and mclapply 'work'...

But, they work in an inefficient manner.

Modifying base::Reduce and parallel::mclapply as I suggest (to NOT coerce
to list at all) make them VERY MUCH faster.

and does away with the need for BioC Generics

Do you agree that these changes should be made in 'upstream' packages?


--Malcolm

On 10/25/12 2:34 PM, "Martin Morgan" <mtmorgan at fhcrc.org> wrote:

>On 10/25/2012 07:53 PM, Cook, Malcolm wrote:
>> Namely, base::Reduce coerces X to a list using as.list  if it is an
>>object
>> whereas BiocGenerics::Reduce does not.  Otherwise they are identical.
>>
>> As a result, base::Reduce(myGRangesList) fails with "no method for
>>coercing
>> this S4 class to a vector".
>
>Well, so when you put it this way... I was wondering why there is no
>
>   as.list.List
>
>i.e., an S3 method for List on the generic as.list? This seems to be
>consistent 
>with the recommendation on ?Methods under 'Methods for S3 Generic
>Functions' 
>(and this little hack seems to allow both Reduce and mclapply to 'work').
>
>Index: NAMESPACE
>===================================================================
>--- NAMESPACE	(revision 70700)
>+++ NAMESPACE	(working copy)
>@@ -332,3 +332,4 @@
>      expand
>  )
> 
>+S3method(as.list, List)
>Index: R/List-class.R
>===================================================================
>--- R/List-class.R	(revision 70700)
>+++ R/List-class.R	(working copy)
>@@ -442,10 +442,11 @@
>  ### Coercion.
>  ###
>
>+as.list.List <-
>+    function(x, ...) lapply(x, identity)
>+
>  setAs("List", "list", function(from) as.list(from))
>
>-setMethod("as.list", "List", function(x, ...) lapply(x, identity))
>-
>  setGeneric("as.env", function(x, ...) standardGeneric("as.env"))
>
>  setMethod("as.env", "List",
>
>-- 
>Computational Biology / Fred Hutchinson Cancer Research Center
>1100 Fairview Ave. N.
>PO Box 19024 Seattle, WA 98109
>
>Location: Arnold Building M1 B861
>Phone: (206) 667-2793



More information about the Bioc-devel mailing list