I'm going to try to provide some details, at the risk to confuse you even more.


In BioC 3.8 / R 3.5 base::lengths() was not just slow on some Bioconductor 
objects like IRanges or GRanges, it didn't work:


  > ir <- IRanges(1:21, 20)
  > base::lengths(ir)
  Error in getListElement(x, i, ...) :
    IRanges objects don't support [[, as.list(), lapply(), or unlist() at
    the moment


Now it works (in BioC 3.9 / R 3.6):


  > ir <- IRanges(1:21, 20)
  > base::lengths(ir)
   [1] 20 19 18 17 16 15 14 13 12 11 10  9  8  7  6  5  4  3  2  1  0


The change I announced in my original post is about base::lengths() being now 
an S4 generic. A standard S4 generic like BiocGenerics::lengths() or 
base::lengths() doesn't do any work beyond dispatching to the right method. 
What happened in R 3.6 is that base::lengths() is now an S4 generic. This means 
that it knows how to take care of dispatching to the right method. The various 
"lengths" methods defined in Bioconductor are the ones doing the real work and 
they are fast. They have not changed and their speed should not be affected by 
this change in base::lengths().


Furthermore: in R 3.6, even though you can't see it, there is a default 
"lengths" method defined in base (it's used as a fallback when no other method 
applies). In my 1st code chunk above (i.e. when base::lengths() was not a 
generic), I'm calling directly this default method (note that this was the 
default method of the BiocGenerics::lengths() generic). This default method is 
indeed slow or doesn't work on Bioconductor objects. By calling 
BiocGenerics::lengths() (in BioC 3.8) or base::lengths() (in BioC 3.9), 
dispatch selects the fast method so nothing has changed from that perspective.


Hope this helps,

H.


On 11/13/18 08:59, H�kon Tjeldnes wrote:
Just to be sure, you are saying that now base::lengths is as fast as 
BiocGenerics::lengths was ? Else we would still need the Bioc version. Because 
the old base implementation was terrible, I will try to verify this if you are 
unsure.
________________________________
Fra: Michael Lawrence 
<lawrence.mich...@gene.com><mailto:lawrence.mich...@gene.com>
Sendt: fredag 2. november 2018 23.50
Til: hauken_hey...@hotmail.com<mailto:hauken_hey...@hotmail.com>
Kopi: bioc-devel; Herv� Pag�s
Emne: Re: [Bioc-devel] Error : object 'lengths' is not exported by 
'namespace:BiocGenerics'

Yes, please follow Herv�'s instructions.

On Fri, Nov 2, 2018 at 3:41 PM H�kon Tjeldnes 
<hauken_hey...@hotmail.com<mailto:hauken_hey...@hotmail.com>> wrote:
Just a quick question, in 3.8 we used biogenerics::lengths for ORFik, since it 
was much faster than base, for our dataset 1 second vs 30 minutes. We should 
change to S4 version of lengths now ?

Get Outlook for 
Android<https://aka.ms/ghei36<https://urldefense.proofpoint.com/v2/url?u=https-3A__eur02.safelinks.protection.outlook.com_-3Furl-3Dhttps-253A-252F-252Faka.ms-252Fghei36-26data-3D02-257C01-257C-257Ce617c34c45584b70cf7008d6411590f9-257C84df9e7fe9f640afb435aaaaaaaaaaaa-257C1-257C0-257C636767958210704172-26sdata-3DUl3jkwHfZdrwQjkzzBQTKrXdQ5NXQ1vWRrx7vojZEAw-253D-26reserved-3D0&d=DwMFAw&c=eRAMFD45gAfqt84VtBcfhQ&r=BK7q3XeAvimeWdGbWY_wJYbW0WYiZvSXAJJKaaPhzWA&m=VkR31AqDi_FLujiTJm39v-jaLNkPJov4_ZlFjFit9UI&s=C8hC46CIc0bUw9WUxrvaekaCsN1NAlLcyxiuFKgRjCs&e=>>

________________________________
From: Bioc-devel 
<bioc-devel-boun...@r-project.org<mailto:bioc-devel-boun...@r-project.org>> on 
behalf of Pages, Herve <hpa...@fredhutch.org<mailto:hpa...@fredhutch.org>>
Sent: Friday, November 2, 2018 6:08:13 PM
To: bioc-devel@r-project.org<mailto:bioc-devel@r-project.org>
Subject: [Bioc-devel] Error : object 'lengths' is not exported by 
'namespace:BiocGenerics'

Hi developers,

Starting with R 3.6, base::lengths() can now be treated as an S4 generic
function (like base::length() or base::names()) so there is no need for
us to define our own lengths() generic function in BiocGenerics.
Therefore we've removed the lengths() generic from BiocGenerics (in
version 0.29.1). Note that you can see the S4 generic associated with
base::lengths() by calling getGeneric("lengths") in a fresh R session:

   > getGeneric("lengths")
   standardGeneric for "lengths" defined from package "base"

   function (x, use.names = TRUE)
   standardGeneric("lengths")
   <bytecode: 0x3548c90>
   <environment: 0x3540928>
   Methods may be defined for arguments: x
   Use  showMethods("lengths")  for currently available ones.

This used to return NULL in R < 3.6.

Because of these changes, packages that currently explicitly import
lengths or a lengths method in their NAMESPACE are failing to install
with an error that looks like this:

   ** byte-compile and prepare package for lazy loading
   Error : object 'lengths' is not exported by 'namespace:BiocGenerics'
   ERROR: lazy loading failed for package 'BubbleTree'

The packages currently affected by this are: BubbleTree, csaw,
GA4GHclient, matter, NADfinder, and SomaticSignatures. The fix is to
simply remove any explicit import of lengths from the NAMESPACE.

Note that many other software packages currently fail to install in BioC
3.9 because they depend on one of the above packages.

Please let us know if you have questions or need assistance with this.

H.

--
Herv� Pag�s

Program in Computational Biology
Division of Public Health Sciences
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N, M1-B514
P.O. Box 19024
Seattle, WA 98109-1024

E-mail: hpa...@fredhutch.org<mailto:hpa...@fredhutch.org>
Phone:  (206) 667-5791
Fax:    (206) 667-1319

_______________________________________________
Bioc-devel@r-project.org<mailto:Bioc-devel@r-project.org> mailing list
https://nam05.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fbioc-devel&amp;data=02%7C01%7C%7C7c4bb0f70b934115a93708d6410fbb9d%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636767933158117589&amp;sdata=0UfC1T6Q52n1V%2FcKb6vR4RT0h5m0DXuWv4C6EwJ2YCA%3D&amp;reserved=0<https://urldefense.proofpoint.com/v2/url?u=https-3A__eur02.safelinks.protection.outlook.com_-3Furl-3Dhttps-253A-252F-252Fstat.ethz.ch-252Fmailman-252Flistinfo-252Fbioc-2Ddevel-26data-3D02-257C01-257C-257Ce617c34c45584b70cf7008d6411590f9-257C84df9e7fe9f640afb435aaaaaaaaaaaa-257C1-257C0-257C636767958210704172-26sdata-3DnWJ1xrPRmDExBtqAQt4QnYojC8btTQCDKbNHNtGXEKg-253D-26reserved-3D0&d=DwMFAw&c=eRAMFD45gAfqt84VtBcfhQ&r=BK7q3XeAvimeWdGbWY_wJYbW0WYiZvSXAJJKaaPhzWA&m=VkR31AqDi_FLujiTJm39v-jaLNkPJov4_ZlFjFit9UI&s=X1qstfX2NwHi1UEDdonTJAg-XpXfkWfEjftcE9o8S3c&e=>

        [[alternative HTML version deleted]]

_______________________________________________
Bioc-devel@r-project.org<mailto:Bioc-devel@r-project.org> mailing list
https://stat.ethz.ch/mailman/listinfo/bioc-devel<https://urldefense.proofpoint.com/v2/url?u=https-3A__eur02.safelinks.protection.outlook.com_-3Furl-3Dhttps-253A-252F-252Fstat.ethz.ch-252Fmailman-252Flistinfo-252Fbioc-2Ddevel-26data-3D02-257C01-257C-257Ce617c34c45584b70cf7008d6411590f9-257C84df9e7fe9f640afb435aaaaaaaaaaaa-257C1-257C0-257C636767958210704172-26sdata-3DnWJ1xrPRmDExBtqAQt4QnYojC8btTQCDKbNHNtGXEKg-253D-26reserved-3D0&d=DwMFAw&c=eRAMFD45gAfqt84VtBcfhQ&r=BK7q3XeAvimeWdGbWY_wJYbW0WYiZvSXAJJKaaPhzWA&m=VkR31AqDi_FLujiTJm39v-jaLNkPJov4_ZlFjFit9UI&s=X1qstfX2NwHi1UEDdonTJAg-XpXfkWfEjftcE9o8S3c&e=>

--
Herv� Pag�s

Program in Computational Biology
Division of Public Health Sciences
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N, M1-B514
P.O. Box 19024
Seattle, WA 98109-1024

E-mail: hpa...@fredhutch.org<mailto:hpa...@fredhutch.org>
Phone:  (206) 667-5791
Fax:    (206) 667-1319


        [[alternative HTML version deleted]]

_______________________________________________
Bioc-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/bioc-devel

Reply via email to