Entering edit mode
dondelelcaro
▴
10
@dondelelcaro-11528
Last seen 9.0 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.

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().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 logicalHmm. 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.
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.