Question: 3.7 behaviour change with snplocs snpsById?
0
19 months ago by
j.abbott0
j.abbott0 wrote:

I have some code using snpsById from SNPlocs which worked under R 3.4.4/Bioconductor 3.6 which has now broken since upgrading to R-3.5.0/Bioconductor 3.7. I've not been able to find any documented change which may be responsible for this. The following snippet illustrates the problem:

library("SNPlocs.Hsapiens.dbSNP144.GRCh37")
snps<-c("rs429358");
snplocs<-SNPlocs.Hsapiens.dbSNP144.GRCh37
locs<-snpsById(snplocs, snps)
positions<-lapply(locs,pos)


This used to return a list of SNP positions, but now reports:

Error in (function (classes, fdef, mtable)  :
unable to find an inherited method for function ‘getListElement’ for signature ‘"GPos"’


I've searched http://bioconductor.org/news/bioc_3_7_release/ for changes to GPos but can't see anything. I know I can use as.data.frame which is probably the simplest fix, but I'm interested to know why this no longer works.

SessionInfo() output pasted below...

Many thanks James

R version 3.5.0 (2018-04-23)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS High Sierra 10.13.4

Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRlapack.dylib

locale:
[1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8

attached base packages:
[1] stats4    parallel  stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] SNPlocs.Hsapiens.dbSNP144.GRCh37_0.99.20 BSgenome_1.48.0                          rtracklayer_1.40.2
[4] Biostrings_2.48.0                        XVector_0.20.0                           GenomicRanges_1.32.2
[7] GenomeInfoDb_1.16.0                      IRanges_2.14.8                           S4Vectors_0.18.1
[10] BiocGenerics_0.26.0

loaded via a namespace (and not attached):
[1] zlibbioc_1.26.0             GenomicAlignments_1.16.0    BiocParallel_1.14.1         lattice_0.20-35
[5] tools_3.5.0                 SummarizedExperiment_1.10.1 grid_3.5.0                  Biobase_2.40.0
[9] matrixStats_0.53.1          yaml_2.1.19                 Matrix_1.2-14               GenomeInfoDbData_1.1.0
[13] bitops_1.0-6                RCurl_1.95-4.10             DelayedArray_0.6.0          compiler_3.5.0
[17] Rsamtools_1.32.0            XML_3.98-1.11

snplocs software error gpos • 336 views
modified 18 months ago by Hervé Pagès ♦♦ 14k • written 19 months ago by j.abbott0
Answer: 3.7 behaviour change with snplocs snpsById?
0
18 months ago by
Hervé Pagès ♦♦ 14k
United States
Hervé Pagès ♦♦ 14k wrote:

Hi James,

Those changes are documented as changes to GRanges objects and their derivatives (GPos is a subclass of GRanges). The change in question is this:

• GenomicRanges now is a List subclass. This means that GRanges objects and their derivatives are now considered list-like objects (even though [[ does not work on them yet, this will be implemented in Bioconductor 3.8).

There has been some discussion related to this in this thread: https://stat.ethz.ch/pipermail/bioc-devel/2018-May/013599.html

In your case using an lapply() loop to extract the positions of a GPos object is not a good idea. We provide the pos() getter for that (which you use inside the loop so you know the existence of it!), which is much faster. More generally speaking, any GRanges derivative supports the seqnames(), start(), end(), width(), and strand() getters so one should never need to use a loop to extract that information. Please consult ?GRanges for basic information about GRanges objects. This is a must-read. GPos objects, being GRanges derivatives, also support these getters plus the pos() getter that is specific to these objects. See ?GPos for important information about these objects and some useful examples.

If you want to turn the integer vector returned by pos() into a list (like you would get with the lapply() solution), just call as.list() on it.

Hope this helps,

H.