GRanges nearest fails for non-overlapping regions
0
0
Entering edit mode
dondelelcaro ▴ 10
@dondelelcaro-11528
Last seen 7.4 years ago
USA/Champaign/University of Illinois

GenomicRanges::nearest fails because strand(subject) != "-" is not logical:

> nearest(GRanges(seqnames=Rle("1",1),ranges=IRanges(start=1,end=10)),GRanges(seqnames=Rle("1",1),ranges=IRanges(start=100,end=120)))
Error in base::which(x, arr.ind, useNames, ...) :
  argument to 'which' is not logical

 

Changing which(strand(subject)!="-") to which(as.logical(strand(subject)!="-"))

should fix this.

bug genomicranges granges nearest • 1.3k views
ADD COMMENT
0
Entering edit mode

sessionInfo? I am not able to reproduce this. Probably a namespace/generic issue, because there should be no need to coerce the logical Rle to a logical vector just to call which().

ADD REPLY
0
Entering edit mode
R version 3.3.2 (2016-10-31)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Debian GNU/Linux stretch/sid

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

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

other attached packages:
 [1] MASS_7.3-45                            
 [2] data.table_1.9.6                       
 [3] ggbio_1.22.0                           
 [4] ggplot2_2.0.0                          
 [5] Homo.sapiens_1.3.1                     
 [6] TxDb.Hsapiens.UCSC.hg19.knownGene_3.1.2
 [7] org.Hs.eg.db_3.1.2                     
 [8] GO.db_3.1.2                            
 [9] OrganismDbi_1.16.0                     
[10] GenomicFeatures_1.24.5                 
[11] GenomicRanges_1.26.1                   
[12] GenomeInfoDb_1.6.0                     
[13] AnnotationDbi_1.34.4                   
[14] IRanges_2.8.0                          
[15] S4Vectors_0.12.0                       
[16] Biobase_2.30.0                         
[17] BiocGenerics_0.20.0                    

loaded via a namespace (and not attached):
 [1] httr_0.6.1                    AnnotationHub_2.6.0          
 [3] splines_3.3.2                 Formula_1.2-1                
 [5] shiny_0.13.2                  interactiveDisplayBase_1.12.0
 [7] latticeExtra_0.6-26           RBGL_1.44.0                  
 [9] BSgenome_1.38.0               Rsamtools_1.22.0             
[11] RSQLite_1.0.0                 lattice_0.20-33              
[13] biovizBase_1.20.0             chron_2.3-47                 
[15] digest_0.6.8                  RColorBrewer_1.1-2           
[17] XVector_0.12.1                colorspace_1.2-6             
[19] htmltools_0.3.5               httpuv_1.3.3                 
[21] plyr_1.8.3                    XML_3.98-1.3                 
[23] biomaRt_2.26.1                zlibbioc_1.14.0              
[25] xtable_1.8-2                  scales_0.3.0                 
[27] BiocParallel_1.4.0            SummarizedExperiment_1.2.3   
[29] nnet_7.3-11                   hexbin_1.27.0                
[31] survival_2.38-3               magrittr_1.5                 
[33] mime_0.3                      GGally_0.5.0                 
[35] foreign_0.8-66                graph_1.50.0                 
[37] BiocInstaller_1.20.0          tools_3.3.2                  
[39] stringr_1.0.0                 munsell_0.4.2                
[41] cluster_2.0.3                 ensembldb_1.6.0              
[43] lambda.r_1.1.7                Biostrings_2.40.2            
[45] compiler_3.3.2                futile.logger_1.4.1          
[47] grid_3.3.2                    RCurl_1.95-4.7               
[49] dichromat_2.0-0               VariantAnnotation_1.16.3     
[51] bitops_1.0-6                  labeling_0.3                 
[53] gtable_0.1.2                  DBI_0.3.1                    
[55] reshape_0.8.5                 reshape2_1.4.1               
[57] R6_2.1.0                      GenomicAlignments_1.10.0     
[59] gridExtra_2.0.0               rtracklayer_1.32.2           
[61] Hmisc_3.17-1                  futile.options_1.0.0         
[63] stringi_1.0-1                 Rcpp_0.12.2                  
[65] rpart_4.1-10                  acepack_1.3-3.3              

 

ADD REPLY
0
Entering edit mode

Looks like I can reduce this to:

> library("S4Vectors")
Loading required package: stats4
Loading required package: BiocGenerics
Loading required package: parallel

Attaching package: ‘BiocGenerics’

The following objects are masked from ‘package:parallel’:

    clusterApply, clusterApplyLB, clusterCall, clusterEvalQ,
    clusterExport, clusterMap, parApply, parCapply, parLapply,
    parLapplyLB, parRapply, parSapply, parSapplyLB

The following objects are masked from ‘package:stats’:

    IQR, mad, xtabs

The following objects are masked from ‘package:base’:

    anyDuplicated, append, as.data.frame, cbind, colnames, do.call,
    duplicated, eval, evalq, Filter, Find, get, grep, grepl, intersect,
    is.unsorted, lapply, lengths, Map, mapply, match, mget, order,
    paste, pmax, pmax.int, pmin, pmin.int, Position, rank, rbind,
    Reduce, rownames, sapply, setdiff, sort, table, tapply, union,
    unique, unsplit, which, which.max, which.min

Attaching package: ‘S4Vectors’

The following objects are masked from ‘package:base’:

    colMeans, colSums, expand.grid, rowMeans, rowSums

> which(Rle(c("+","-"),c(5,3))=="-")
Error in base::which(x, arr.ind, useNames, ...) :
  argument to 'which' is not logical

 

ADD REPLY
0
Entering edit mode

Hmm. I've tried to replicate your environment but I still can't reproduce it. Maybe try removing and reinstalling Bioconductor from scratch? Something might be cached somewhere.

ADD REPLY
0
Entering edit mode

OK, I'm still not sure what is causing this, but rebuilding S4Vectors and BiocGenerics fixes the issue.

The difference that I can tell is:

 

> which(Rle(c(TRUE,FALSE),c(5,3)))
Error in base::which(x, arr.ind, useNames, ...) :
  argument to 'which' is not logical
> showMethods("which")
Function: which (package BiocGenerics)
x="ANY"
x="Rle"
    (inherited from: x="ANY")


vs on a rebuild:

> which(Rle(c(TRUE,FALSE),c(5,3)))
[1] 1 2 3 4 5
> showMethods("which")
Function: which (package BiocGenerics)
x="ANY"
x="Rle"

Maybe it's because something changed in the S4 inheritance between R versions? Kind of out of my depth here.

ADD REPLY

Login before adding your answer.

Traffic: 594 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