[BioC] IRanges/List oddity: do.call of `c` on a list of IRangesList returns "list" only when the list is named

Cook, Malcolm MEC at stowers.org
Fri Nov 30 20:56:26 CET 2012


Hi,

The following shows that do.call of `c` on a list of IRangesList returns "list" only when the list is named.


> library(IRanges)
>example(IRangesList)
> class(x)
[1] "CompressedIRangesList"
attr(,"package")
[1] "IRanges"
> class(do.call(c,list(x1=x,x2=x)))
[1] "list"

I am confused this.

I would not expect the fact that the list is named to have any impact on the result.

But, look, omitting the list names the class is now an IRangesList

> class(do.call(c,list(x,x)))
[1] "CompressedIRangesList"
attr(,"package")
[1] "IRanges"


> class(c(x,x))
[1] "CompressedIRangesList"
attr(,"package")
[1] "IRanges"

A 'workaround' is to unname the list, as demonstrated:

> class(do.call(c,unname(list(x1=x,x2=x)))) 
[1] "CompressedIRangesList"
attr(,"package")
[1] "IRanges"

But, why does having a 'names' attribute effect the behavior of do.calling `c` so much as to change the class returned?


Thanks for your help/education.....

Malcolm Cook
Computational Biology - Stowers Institute for Medical Research


> sessionInfo()
R version 2.15.1 (2012-06-22)
Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)

locale:
[1] C

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

other attached packages:
[1] IRanges_1.16.4     BiocGenerics_0.4.0

loaded via a namespace (and not attached):
 [1] AnnotationDbi_1.20.3   BSgenome_1.26.1        Biobase_2.18.0         Biostrings_2.26.2      DBI_0.2-5              GenomicFeatures_1.10.1 GenomicRanges_1.10.5   RCurl_1.95-3           RSQLite_0.11.2         Rsamtools_1.10.2       XML_3.95-0.1           biomaRt_2.14.0         bitops_1.0-4.2         colorspace_1.2-0       data.table_1.8.6       functional_0.1         graph_1.36.1           gtools_2.7.0           parallel_2.15.1        rtracklayer_1.18.1     stats4_2.15.1          tools_2.15.1           zlibbioc_1.4.0        
>



More information about the Bioconductor mailing list