[Bioc-devel] as.list of a GRanges

Hervé Pagès hpages at fredhutch.org
Thu Feb 15 20:02:58 CET 2018


On 02/15/2018 08:37 AM, Michael Lawrence wrote:
> So is as.list() no longer supported for GRanges objects? I have found it 
> useful in places.

Very few places. I found a dozen of them in the entire software repo.
Now you should use as.list(as(gr, "GRangesList")) instead.
as.list() was behaving inconsistently on IRanges and GRanges objects,
which is blocking new developments. It will come back with a consistent
behavior. More generally speaking IRanges and GRanges will behave
consistently as far as their "list interpretation" is concerned.

I'll send more details later.

H.

> 
> On Thu, Feb 15, 2018 at 8:30 AM, Hervé Pagès <hpages at fredhutch.org 
> <mailto:hpages at fredhutch.org>> wrote:
> 
>     Hi Bernat,
> 
>     Use as(gr, "GRangesList") instead of as.list() on your GRanges objects.
> 
>     Most of the times (e.g. for passing to lapply() or mclapply()), you
>     don't need an ordinary list, but, if you really want one, you can call
>     as.list() on the GRangesList object returned by as(gr, "GRangesList").
> 
>     Hope this helps,
>     H.
> 
> 
>     On 02/15/2018 12:05 AM, Bernat Gel wrote:
> 
>         Hi,
> 
>         I'm having an error in the devel version of my package
>         karyoploteR due to an error when converting a GRanges into a
>         list of GRanges with "as.list".
> 
>         This used to be possible and it was working a few weeks ago.
> 
>         Am I suposed to use a different approach or is there a problem
>         somewhere?
> 
>         Thanks!
> 
>         Bernat
> 
>         Here's an example
> 
>         rr <- GRanges(seqnames = c("chr1", "chr2"), ranges =
>         IRanges(start=c(1, 2), end=c(11, 12)))
>         as.list(rr)
> 
>         And the error message
> 
>         Error in (function (classes, fdef, mtable)  :
>             unable to find an inherited method for function
>         'getListElement' for signature '"GRanges"'
> 
> 
>         and the sessionInfo
> 
>           > sessionInfo()
>         R Under development (unstable) (2018-02-14 r74250)
>         Platform: x86_64-pc-linux-gnu (64-bit)
>         Running under: Debian GNU/Linux 8 (jessie)
> 
>         Matrix products: default
>         BLAS:
>         /software/debian-8/general/R-Bioc-Devel/current/lib/R/lib/libRblas.so
>         LAPACK:
>         /software/debian-8/general/R-Bioc-Devel/current/lib/R/lib/libRlapack.so
> 
>         locale:
>            [1] LC_CTYPE=en_US.UTF-8      LC_NUMERIC=C LC_TIME=C
>         LC_COLLATE=en_US.utf8
>            [5] LC_MONETARY=en_US.utf8    LC_MESSAGES=en_US.utf8
>         LC_PAPER=es_ES.UTF-8      LC_NAME=C
>            [9] LC_ADDRESS=C              LC_TELEPHONE=C
>         LC_MEASUREMENT=en_US.utf8 LC_IDENTIFICATION=C
> 
>         attached base packages:
>         [1] parallel  stats4    stats     graphics  grDevices utils
>         datasets methods   base
> 
>         other attached packages:
>         [1] GenomicRanges_1.31.20 GenomeInfoDb_1.15.5 IRanges_2.13.26
>         S4Vectors_0.17.32     BiocGenerics_0.25.3
> 
>         loaded via a namespace (and not attached):
>         [1] zlibbioc_1.25.0        compiler_3.5.0 XVector_0.19.8
>         tools_3.5.0            GenomeInfoDbData_1.1.0
>         [6] RCurl_1.95-4.10        bitops_1.0-6
> 
> 
> 
> 
>     -- 
>     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>
> 
> 
>     _______________________________________________
>     Bioc-devel at r-project.org <mailto:Bioc-devel at r-project.org> mailing list
>     https://stat.ethz.ch/mailman/listinfo/bioc-devel
>     <https://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_mailman_listinfo_bioc-2Ddevel&d=DwMFaQ&c=eRAMFD45gAfqt84VtBcfhQ&r=BK7q3XeAvimeWdGbWY_wJYbW0WYiZvSXAJJKaaPhzWA&m=i21ySDBZuY-_wWlEBmfdjm2XPMEHP5PcXGHapMlX2Tw&s=bN6AMFpO0vidOay3ITzHe149LOwS30pooDaVEvIgHKw&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: hpages at fredhutch.org
Phone:  (206) 667-5791
Fax:    (206) 667-1319



More information about the Bioc-devel mailing list