DistanceToNearest() error: 'nLnode' and 'nRnode' must be single integers
4
1
Entering edit mode
roladali ▴ 20
@roladali-9193
Last seen 7.6 years ago

I am trying to use distanceToNearest() to get the closest distance between two GRanges objects. The method usually works well but has been giving me an error (Error in new_Hits(Class, from, to, nLnode, nRnode, mcols) : 
  'nLnode' and 'nRnode' must be single integers)
which I am not sure how to resolve. 

 

distanceToNearest(myRanges1, myRanges2, ignore.strand=T)
Error in new_Hits(Class, from, to, nLnode, nRnode, mcols) : 
  'nLnode' and 'nRnode' must be single integers

myRanges1

GRanges object with 5547 ranges and 0 metadata columns:
         seqnames               ranges strand
            <Rle>            <IRanges>  <Rle>
     [1]     chr1   [      0,       0]      *
     [2]     chr1   [ 300000,  300000]      *
     [3]     chr1   [ 425000,  425000]      *
     [4]     chr1   [ 800000,  800000]      *
     [5]     chr1   [1875000, 1875000]      *
     ...      ...                  ...    ...

myRanges2

GRanges object with 9535 ranges and 0 metadata columns:
         seqnames                 ranges strand
            <Rle>              <IRanges>  <Rle>
     [1]     chr1 [   825000,    825000]      *
     [2]     chr1 [144900000, 144900000]      *
     [3]     chr1 [145000000, 145000000]      *
     [4]     chr1 [145400000, 145400000]      *
     [5]     chr1 [145650000, 145650000]      *
     ...      ...                    ...    ...

genomicranges DistanceToNearest • 1.9k views
ADD COMMENT
0
Entering edit mode

Are your packages up-to-date and consistent, as reported by BiocInstaller::biocValid() ?

ADD REPLY
0
Entering edit mode

BiocInstaller::biocValid()

* sessionInfo()

R version 3.3.0 (2016-05-03)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.10.2 (Yosemite)

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

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

other attached packages:
[1] BiocInstaller_1.22.3 reshape_0.8.5        stringr_1.1.0        ggplot2_2.1.0        GenomicRanges_1.24.2
[6] GenomeInfoDb_1.8.5   IRanges_2.6.1        S4Vectors_0.10.3     BiocGenerics_0.18.0 

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.6      digest_0.6.10    grid_3.3.0       plyr_1.8.4       gtable_0.2.0     magrittr_1.5    
 [7] scales_0.4.0     stringi_1.1.1    zlibbioc_1.18.0  reshape2_1.4.1   XVector_0.12.1   labeling_0.3    
[13] tools_3.3.0      munsell_0.4.3    colorspace_1.2-6

 

ADD REPLY
0
Entering edit mode

* Out-of-date packages
Package
BSgenome.Hsapiens.UCSC.hg19         "BSgenome.Hsapiens.UCSC.hg19"                 
BSgenome.Hsapiens.UCSC.hg38        "BSgenome.Hsapiens.UCSC.hg38"                 
DO.db                                        "DO.db"  
IlluminaHumanMethylation450kanno.ilmn12.hg19 "IlluminaHumanMethylation450kanno.ilmn12.hg19"
IlluminaHumanMethylation450kmanifest         "IlluminaHumanMethylation450kmanifest"        
pd.hugene.1.0.st.v1                          "pd.hugene.1.0.st.v1"                         
TxDb.Hsapiens.UCSC.hg19.knownGene     "TxDb.Hsapiens.UCSC.hg19.knownGene"           
TxDb.Hsapiens.UCSC.hg38.knownGene     "TxDb.Hsapiens.UCSC.hg38.knownGene"           
   LibPath     
BSgenome.Hsapiens.UCSC.hg19       "/Library/Frameworks/R.framework/Versions/3.3/Resources/library"
BSgenome.Hsapiens.UCSC.hg38      "/Library/Frameworks/R.framework/Versions/3.3/Resources/library"
DO.db      "/Library/Frameworks/R.framework/Versions/3.3/Resources/library"
IlluminaHumanMethylation450kanno.ilmn12.hg19 "/Library/Frameworks/R.framework/Versions/3.3/Resources/library"
IlluminaHumanMethylation450kmanifest         "/Library/Frameworks/R.framework/Versions/3.3/Resources/library"
pd.hugene.1.0.st.v1     "/Library/Frameworks/R.framework/Versions/3.3/Resources/library"
TxDb.Hsapiens.UCSC.hg19.knownGene            "/Library/Frameworks/R.framework/Versions/3.3/Resources/library"
TxDb.Hsapiens.UCSC.hg38.knownGene            "/Library/Frameworks/R.framework/Versions/3.3/Resources/library"
 Installed Built   ReposVer
BSgenome.Hsapiens.UCSC.hg19      "1.4.0"   "3.2.2" "1.4.0" 
BSgenome.Hsapiens.UCSC.hg38       "1.4.1"   "3.2.2" "1.4.1" 
DO.db                 "2.9"     "3.2.2" "2.9"   
IlluminaHumanMethylation450kanno.ilmn12.hg19 "0.2.1"   "3.2.2" "0.2.1" 
IlluminaHumanMethylation450kmanifest         "0.4.0"   "3.2.2" "0.4.0" 
pd.hugene.1.0.st.v1            "3.14.1"  "3.2.2" "3.14.1"
TxDb.Hsapiens.UCSC.hg19.knownGene         "3.2.2"   "3.2.2" "3.2.2" 
TxDb.Hsapiens.UCSC.hg38.knownGene         "3.1.3"   "3.2.2" "3.1.3" 
 Repository     
BSgenome.Hsapiens.UCSC.hg19     "https://bioconductor.org/packages/3.3/data/annotation/src/contrib"
BSgenome.Hsapiens.UCSC.hg38      "https://bioconductor.org/packages/3.3/data/annotation/src/contrib"
DO.db           "https://bioconductor.org/packages/3.3/data/annotation/src/contrib"
IlluminaHumanMethylation450kanno.ilmn12.hg19 "https://bioconductor.org/packages/3.3/data/annotation/src/contrib"
IlluminaHumanMethylation450kmanifest         "https://bioconductor.org/packages/3.3/data/annotation/src/contrib"
pd.hugene.1.0.st.v1                          "https://bioconductor.org/packages/3.3/data/annotation/src/contrib"
TxDb.Hsapiens.UCSC.hg19.knownGene            "https://bioconductor.org/packages/3.3/data/annotation/src/contrib"
TxDb.Hsapiens.UCSC.hg38.knownGene            "https://bioconductor.org/packages/3.3/data/annotation/src/contrib"

update with biocLite()

Error: 8 package(s) out of date

ADD REPLY
0
Entering edit mode

biocLite isnt really updating the 8 packages

 

> biocLite()
BioC_mirror: https://bioconductor.org
Using Bioconductor 3.3 (BiocInstaller 1.22.3), R 3.3.0 (2016-05-03).

ADD REPLY
0
Entering edit mode

provide the package names requiring update as a vector, biocLite(c("BSgenome.Hsapiens.UCSC.hg19", "BSgenome.Hsapiens.UCSC.hg38")), etc. but these are not likely to be the source of your problem so I'll leave it for others to answer.

ADD REPLY
0
Entering edit mode

We need a reproducible example in order to help. If you still have this problem after updating with biocLite()  please provide the GRanges (or a small subset) that produce the error. You can send to valerie.obenchain@roswellpark.org.

Valerie

ADD REPLY
0
Entering edit mode

I added it below. 

Is there another way to find the closest GRanges object besides distanceToNearest()?

Thanks for the help!

ADD REPLY
0
Entering edit mode

Hi roladali,

I suspect there is something specific/unusual to your GRanges objects myRanges1 and myRanges2 that triggers this error. Could you please provide a reproducible example i.e. code that we can run that triggers this error? If you can't provide the code that generated the 2 GRanges objects maybe you can serialize them (with save()) and make the 2 resulting files available somewhere via an URL.

Thanks,

H.

ADD REPLY
0
Entering edit mode

I added the objects below. 

Thanks!

ADD REPLY
0
Entering edit mode
roladali ▴ 20
@roladali-9193
Last seen 7.6 years ago

Hello,

I am actually getting 2 different errors:

> distanceToNearest(myRanges1, myRanges2, ignore.strand=T)
Error in new_Hits(Class, from, to, nLnode, nRnode, mcols) : 
  'nLnode' and 'nRnode' must be single integers


> distanceToNearest(myRanges3, myRanges4, ignore.strand=T)
Error in rep(seq(lx)[v], w) : invalid 'times' argument

 

I have attached objects myRanges1 to myRanges4, as well as my R session. Nothing looks unusual about these ranges. Also, some ranges combinations fail but work fine if combined with other ranges. 

 

Thanks!

Rola

## TO DOWNLOAD: press on the "myRanges" link, NOT on the "Download" button which pops up an ad. 

I tested the links; 

Rsession:

http://s000.tinyupload.com/?file_id=07521718617224259851

Ranges1:4

http://s000.tinyupload.com/?file_id=00421462498421829601

http://s000.tinyupload.com/?file_id=04242812352144597405

http://s000.tinyupload.com/?file_id=70020862917644622055

 http://s000.tinyupload.com/?file_id=06464838747515157530

 

 

 

Here is my session info in case that is helpful:

> sessionInfo()
R version 3.3.0 (2016-05-03)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.10.2 (Yosemite)

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

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

other attached packages:
[1] reshape_0.8.5        stringr_1.1.0        ggplot2_2.1.0        GenomicRanges_1.24.2 GenomeInfoDb_1.8.5  
[6] IRanges_2.6.1        S4Vectors_0.10.3     BiocGenerics_0.18.0 

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.6      grid_3.3.0       plyr_1.8.4       gtable_0.2.0     magrittr_1.5     scales_0.4.0    
 [7] stringi_1.1.1    zlibbioc_1.18.0  XVector_0.12.1   tools_3.3.0      munsell_0.4.3    colorspace_1.2-6

ADD COMMENT
0
Entering edit mode
@fadihariri-11417
Last seen 7.6 years ago

When I do it, on my mac I get a different error:

distanceToNearest(myRanges1, myRanges2)
Error in .Call2("Hits_new", queryHits, subjectHits, queryLength, subjectLength,  : 
  'subjectHits' must contain non-NA values >= 1 and <= 'subjectLength'

ADD COMMENT
0
Entering edit mode
roladali ▴ 20
@roladali-9193
Last seen 7.6 years ago

I have figured out what triggers one of the errors but not the other:

distanceToNearest(myRanges3, myRanges4, ignore.strand=T)
Error in rep(seq(lx)[v], w) : invalid 'times' argument

 

seems to be triggered by ranges that start at 0. if I remove all the ranges that start at zero, the error is not triggered. 

 

ADD COMMENT
0
Entering edit mode
@valerie-obenchain-4275
Last seen 2.3 years ago
United States

FYI, when adding information to your question use 'ADD COMMENT' or 'edit' instead of posting an answer to your own question.

Thanks for sending the files. This was a bug in the follow() method for GenomicRanges. distanceToNearest() calls both proceed() and follow() and was failing because of the problems in follow(). I've checked in a fix to GenomicRanges 1.24.3 in release and 1.25.94 in devel. Both should be available via biocLite() Saturday after noon PST or immediately from svn.

Thanks for reporting the bug. Let us know if you have any other problems.

Valerie

ADD COMMENT
0
Entering edit mode

Thanks for the fix!

ADD REPLY

Login before adding your answer.

Traffic: 474 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6