Entering edit mode
The statement
m[, 1L] <- map[m[, 1L]]
seems pretty likely to cause
Error in map[m[, 1L]] : object of type 'closure' is not
subsettable
This occurs with nearest(select="all") when there is no overlap.
Slightly sanitized real-life example:
> library(TxDb.Hsapiens.UCSC.hg19.knownGene)
Loading required package: GenomicFeatures
Loading required package: BiocGenerics
...
> TT <- transcriptsBy(TxDb.Hsapiens.UCSC.hg19.knownGene, by="gene")
> tt <- TT[[1]]
> tt
GRanges with 2 ranges and 2 metadata columns:
seqnames ranges strand | tx_id tx_name
<rle> <iranges> <rle> | <integer> <character>
[1] chr19 [58858172, 58864865] - | 68796 uc002qsd.4
[2] chr19 [58859832, 58874214] - | 68797 uc002qsf.2
---
seqlengths:
chr1 chr2 ...
chrUn_gl000249
249250621 243199373 ...
38502
> q <- GRanges(IRanges(1,1), seqnames="chr19", strand="*")
> nearest(q, tt)
[1] 1
> nearest(q, tt, select="all")
Error in map[m[, 1L]] : object of type 'closure' is not subsettable
> sessionInfo()
R version 2.15.1 Patched (2012-07-01 r59713)
Platform: x86_64-unknown-linux-gnu (64-bit)
locale:
[1] LC_CTYPE=en_US.iso885915 LC_NUMERIC=C
[3] LC_TIME=en_US.iso885915 LC_COLLATE=en_US.iso885915
[5] LC_MONETARY=en_US.iso885915 LC_MESSAGES=en_US.iso885915
[7] LC_PAPER=C LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.iso885915 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices datasets utils methods base
other attached packages:
[1] TxDb.Hsapiens.UCSC.hg19.knownGene_2.8.0
[2] GenomicFeatures_1.10.0
[3] AnnotationDbi_1.20.2
[4] Biobase_2.18.0
[5] GenomicRanges_1.10.2
[6] IRanges_1.16.3
[7] BiocGenerics_0.4.0
loaded via a namespace (and not attached):
[1] biomaRt_2.14.0 Biostrings_2.26.2 bitops_1.0-4.1
BSgenome_1.26.1
[5] DBI_0.2-5 parallel_2.15.1 RCurl_1.95-1.1
Rsamtools_1.10.1
[9] RSQLite_0.11.2 rtracklayer_1.18.0 stats4_2.15.1
tools_2.15.1
[13] XML_3.95-0.1 zlibbioc_1.4.0