Dear bioC support,
I have constructed a list of IRanges named rl:
> class(rl)
[1] "list"
> class(rl[[1]])
[1] "IRanges"
attr(,"package")
[1] "IRanges"
Now I realized that there is already a RangesList class in the IRanges package that I could use instead of the "primitive" list. Problem: I used dlply() from the plyr package to construct the list and I do not see how I could use the RangesList constructor function in the split+apply+combine context. But one can coerce a RangedList to a list by as. list(), Now I was wondering, is there a function that does the opposite?
Greetings,
Tobi
> sessionInfo() R version 3.3.2 (2016-10-31) Platform: x86_64-apple-darwin13.4.0 (64-bit) Running under: macOS Sierra 10.12.3 locale: [1] C attached base packages: [1] parallel stats4 stats graphics grDevices utils datasets methods base other attached packages: [1] lattice_0.20-34 plyr_1.8.4 Biostrings_2.42.1 XVector_0.14.0 [5] IRanges_2.8.1 S4Vectors_0.12.1 BiocGenerics_0.20.0 loaded via a namespace (and not attached): [1] Rcpp_0.12.9 nloptr_1.0.4 MSstats_3.7.3 bitops_1.0-6 [5] tools_3.3.2 zlibbioc_1.20.0 lme4_1.1-12 preprocessCore_1.36.0 [9] tibble_1.2 nlme_3.1-130 gtable_0.2.0 Matrix_1.2-8 [13] ggrepel_0.6.5 stringr_1.1.0 gtools_3.5.0 caTools_1.17.1 [17] grid_3.3.2 marray_1.52.0 survival_2.40-1 minpack.lm_1.2-1 [21] gdata_2.17.0 limma_3.30.9 minqa_1.2.4 ggplot2_2.2.1 [25] reshape2_1.4.2 magrittr_1.5 scales_0.4.1 gplots_3.0.1 [29] MASS_7.3-45 splines_3.3.2 assertthat_0.1 colorspace_1.3-2 [33] KernSmooth_2.23-15 stringi_1.1.2 lazyeval_0.2.0 munsell_0.4.3 >
THX!
Where is that function documented?
The
as
function is documented as part of the methods package. I think under the hood it ends up callingRangesList
though, which is documented in ?RangesList. Either way works:The
as()
function call looks forcoerce()
methods, so?"coerce,list,RangesList"
. Many things in that last sentence are not obvious.THX Martin! A general question: I am starting to develop a package for dealing with peptide mapping data (data coming from a bottom-up proteomics experiment) and I think the Biostrings and IRanges package could be the basis for this, but I am having trouble to get an overview what functionality is already available. Where can I find such information apart from the package vignettes?
The GenomicRanges vignettes are also relevant to IRanges. One might also look at conference presentations, especially last year and other course material.
Hi Martin,
I am having a bit of a problem using as(..., "RangesList") in the context of my package. I always get the error that the appropriate method is not found in the context of testthat(...). How would you handle this? Calling the RangesList() constructor directly instead of as() -> coerce() -> ...
?
Better to ask questions about package development on the Bioconductor devel mailing list. For packages you need to import the appropriate method,
importMethodsFrom(IRanges, coerce)
. if your unit test uses the public interface to your package, then problems likely indicate inappropriate NAMESPACE, but a more accurate diagnosis would benefit from actually looking at the package code, e.g., including a github reference.Note that there is also an
IRangesList()
constructor function that is very similar toRangesList()
except that it produces an IRangesList object which is more specific than a RangesList (i.e. the former is a subclass of the latter):Also,
IRangesList()
has acompress
argument to let you choose between 2 internal representations: CompressedIRangesList or SimpleIRangesList. By default you get the first, which is more efficient than the second if the list is very long (e.g. has > 10000 list elements).H.
I tried to use as(..., "IRangesList") and got:
Is there a reason why one can not coerce a list to a IRangesList? What is more specific about IRangesList objects?
No particular reason. It was just missing. I added it to IRanges 2.9.20.
Cheers,
H.