[Bioc-devel] as.list fails on IRanges inside of lapply(<IRanges>, blah)

Hervé Pagès hpages at fredhutch.org
Wed Feb 21 03:46:46 CET 2018


On 02/20/2018 01:25 PM, Gabe Becker wrote:
> Herve,
> 
> Thanks for the response. The looping across a ranges that's still in 
> tehre is:
> 
>     dss = switch(seqtype,
>                           bp = DNAStringSet(*lapply(ranges(srcs)*,
>     function(x) origin[x])),
>                           aa = AAStringSet(*lapply(ranges(srcs),*
>     function(x) origin[x])),
>                           stop("Unrecognized origin sequence type: ",
>     seqtype)
>                           )
> 
> (Line 495 in genbankReader.R)

That was also fixed in genbankr 1.7.2. I replaced this with

   dss = extractAt(origin, ranges(srcs))

Do 'git show 340b0d4fac511f8171391fdeb2233ca6a410743d' to see
the details of the changes I made.

Cheers,
H.

> 
> srcs is a GRanges, making ranges(srcs) an IRanges, so this lapply fails. 
> I'm not sure what I'm meant to do here as there's not an already 
> vectorized version that I know of that does the rigth thing (I want 
> separate DNAStrings for each range, so origin[ranges(srcs)] doesn't work).
> 
> I mean I can force the conversion to list issue with 
> lapply(1:length(srcs), function(i) ranges(srcs)[i]) or similar but that 
> seems pretty ugly...
> 
> As for the other issue with the build not working in release, that is a 
> bug in the rentrez (which is on CRAN, not Bioc). I've submitted a PR to 
> fix that, and we'll see what the response is as to whether I need to 
> remove that integration or not.
> 
> ~G
> 
> 
> 
> 
> 
> 
> On Tue, Feb 20, 2018 at 10:48 AM, Hervé Pagès <hpages at fredhutch.org 
> <mailto:hpages at fredhutch.org>> wrote:
> 
>     Hi Gabe,
> 
>     I made a couple of changes to genbankr (1.7.2) to avoid those looping
>     e.g. I replaced things like
> 
>          sapply(gr, width)
> 
>     with
> 
>          width(gr)
> 
>     I can't run a full 'R CMD build' + 'R CMD check' on the package though
>     because the code in the vignette seems to fail for reasons unrelated
>     to the recent changes to IRanges / GenomicRanges (I get the same error
>     with the release version, see release build report).
> 
>     The previous behavior of as.list() on IRanges ans GRanges objects will
>     be restored (with a deprecation warning) once all the packages that
>     need a fix get one (only 7 packages left on my list). I should be done
>     with them in the next couple of days.
> 
>     H.
> 
> 
>     On 02/20/2018 09:41 AM, Gabe Becker wrote:
> 
>         All,
> 
>         I'm trying to track down the new failure in my genbankr package
>         and it
>         appears to come down to the fact  that i'm trying to lapply over an
>         IRanges, which fails in the IRanges to list (or List?)
>         conversion. The
>         particular case that fails in my example is an IRanges of length
>         1 but that
>         does not appear to matter, as lapply fails over IRanges of
>         length >1 as
>         well.
> 
>         Is this intentional? If so, it seems a change of this magnitude
>         would
>         warrant a deprecation cycle at least. If not, please let me know
>         so I can
>         leave the code as is and wait for the fix.
> 
>             rng1 = IRanges(start = 1, end = 5)
> 
> 
>             rng2 = IRanges(start = c(1, 7), end = c(3, 10))
> 
> 
>             rng1
> 
> 
>         IRanges object with 1 range and 0 metadata columns:
> 
>                     start       end     width
> 
>                 <integer> <integer> <integer>
> 
>             [1]         1         5         5
> 
>             rng2
> 
> 
>         IRanges object with 2 ranges and 0 metadata columns:
> 
>                     start       end     width
> 
>                 <integer> <integer> <integer>
> 
>             [1]         1         3         3
> 
>             [2]         7        10         4
> 
>             lapply(rng1, identity)
> 
> 
>         *Error in (function (classes, fdef, mtable)  : *
> 
>         *  unable to find an inherited method for function
>         ‘getListElement’ for
>         signature ‘"IRanges"’*
> 
>             lapply(rng2, identity)
> 
> 
>         *Error in (function (classes, fdef, mtable)  : *
> 
>         *  unable to find an inherited method for function
>         ‘getListElement’ for
>         signature ‘"IRanges"’*
> 
>             sessionInfo()
> 
> 
>         R Under development (unstable) (2018-02-16 r74263)
> 
>         Platform: x86_64-apple-darwin15.6.0 (64-bit)
> 
>         Running under: OS X El Capitan 10.11.6
> 
> 
>         Matrix products: default
> 
>         BLAS:
>         /Users/beckerg4/local/Rdevel/R.framework/Versions/3.5/Resources/lib/libRblas.dylib
> 
>         LAPACK:
>         /Users/beckerg4/local/Rdevel/R.framework/Versions/3.5/Resources/lib/libRlapack.dylib
> 
> 
>         locale:
> 
>         [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
> 
> 
>         attached base packages:
> 
>         [1] stats4    parallel  stats     graphics  grDevices utils   
>           datasets
> 
>         [8] methods   base
> 
> 
>         other attached packages:
> 
>         *[1] IRanges_2.13.26     S4Vectors_0.17.33   BiocGenerics_0.25.3*
> 
> 
>         loaded via a namespace (a
>         <https://urldefense.proofpoint.com/v2/url?u=https-3A__maps.google.com_-3Fq-3Dd-2Bvia-2Ba-2Bnamespace-2B-28a-26entry-3Dgmail-26source-3Dg&d=DwMFaQ&c=eRAMFD45gAfqt84VtBcfhQ&r=BK7q3XeAvimeWdGbWY_wJYbW0WYiZvSXAJJKaaPhzWA&m=UXc_3kLawiEpQQcAHZhYs1gYYbOaugo9CDOvWJd10nQ&s=3tASrFpqenzsLC8hh1ay3-LhytVzFL86g_PO-RptAp8&e=>nd
>         not attached):
> 
>         [1] compiler_3.5.0 tools_3.5.0
> 
> 
> 
>         Best,
>         ~G
> 
> 
> 
> 
>     -- 
>     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: hpages at fredhutch.org <mailto:hpages at fredhutch.org>
>     Phone: (206) 667-5791 <tel:%28206%29%20667-5791>
>     Fax: (206) 667-1319 <tel:%28206%29%20667-1319>
> 
> 
> 
> 
> -- 
> Gabriel Becker, Ph.D
> Scientist
> Bioinformatics and Computational Biology
> Genentech Research

-- 
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: hpages at fredhutch.org
Phone:  (206) 667-5791
Fax:    (206) 667-1319



More information about the Bioc-devel mailing list