rtracklayer export method requires unique names
1
0
Entering edit mode
@samuel-younkin-5497
Last seen 10.2 years ago
BioC, It seems that the export method in rtracklayer for the GRanges class requires that the GRanges object have unique names. The error message given when names are not unique is the following: Error in export(object, FileForFormat(con), ...) : cannot export object of class 'GRanges' As one can easily make a case that non-unique names may be troublesome, I am curious to know whether you intentionally disallowed non-unique names. For future users, it would be great if the error message was not so misleading. I imagine that others may label ranges by subject ID, as I did, and therefore are likely to create a GRanges object with non- unique names. See code below for an example. Thanks, Sam ~~ > foo <- GRangesForUCSCGenome( genome = "hg18", chrom = rep("chr1",10) , ranges = IRanges(start = 1:10, width = 5), strand = "*" ) > names(foo) <- 1:10 > export(foo, "foo.bed" ) > foobar <- foo > names(foobar) <- c(rep(1,2),3:10) > export(foobar, "foobar.bed" ) Error in export(object, FileForFormat(con), ...) : cannot export object of class 'GRanges' > sessionInfo() R Under development (unstable) (2013-01-08 r61589) 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] parallel stats graphics grDevices datasets utils methods [8] base other attached packages: [1] rtracklayer_1.19.6 CleftCNVAssoc_0.1.0 MinimumDistance_1.3.3 [4] GWASTools_1.5.5 gdsfmt_0.9.10 sandwich_2.2-9 [7] zoo_1.7-9 GWASExactHW_1.01 ncdf_1.6.6 [10] Biobase_2.19.2 GenomicRanges_1.11.21 IRanges_1.17.24 [13] BiocGenerics_0.5.6 loaded via a namespace (and not attached): [1] affyio_1.27.1 annotate_1.37.3 AnnotationDbi_1.21.9 [4] BiocInstaller_1.9.6 Biostrings_2.27.8 bit_1.1-9 [7] bitops_1.0-5 BSgenome_1.27.1 codetools_0.2-8 [10] crlmm_1.17.12 DBI_0.2-5 DNAcopy_1.33.1 [13] ellipse_0.3-7 ff_2.2-10 foreach_1.4.0 [16] genefilter_1.41.1 grid_3.0.0 iterators_1.0.6 [19] lattice_0.20-13 lmtest_0.9-30 Matrix_1.0-10 [22] msm_1.1.4 mvtnorm_0.9-9994 oligoClasses_1.21.6 [25] preprocessCore_1.21.1 quantsmooth_1.25.0 RcppEigen_0.3.1.2 [28] RCurl_1.95-3 Rsamtools_1.11.14 RSQLite_0.11.2 [31] SNPchip_2.5.1 splines_3.0.0 stats4_3.0.0 [34] survival_2.37-2 tools_3.0.0 VanillaICE_1.21.10 [37] XML_3.95-0.1 xtable_1.7-0 zlibbioc_1.5.0 >
rtracklayer rtracklayer • 1.2k views
ADD COMMENT
0
Entering edit mode
@michael-lawrence-3846
Last seen 3.0 years ago
United States
Thanks for pointing this out. The non-unique names are disallowed by the internal coercion to RangedData, which translates the names to rownames, which are required to be unique by R conventions. We really need to get away from using RangedData inside of rtracklayer. But until then, the easiest work-around (and arguably cleaner for your use case, anyway) is to use a metadata column called "name". I've made the error message more meaningful. Michael On Wed, Jan 9, 2013 at 9:04 AM, Samuel Younkin <syounkin@jhsph.edu> wrote: > BioC, > > It seems that the export method in rtracklayer for the GRanges class > requires that the GRanges object have unique names. The error message > given when names are not unique is the following: > > Error in export(object, FileForFormat(con), ...) : > cannot export object of class 'GRanges' > > As one can easily make a case that non-unique names may be troublesome, I > am curious to know whether you intentionally disallowed non-unique names. > > For future users, it would be great if the error message was not so > misleading. I imagine that others may label ranges by subject ID, as I > did, and therefore are likely to create a GRanges object with non- unique > names. > > See code below for an example. > > Thanks, > > Sam > > ~~ > > > foo <- GRangesForUCSCGenome( genome = "hg18", chrom = rep("chr1",10) , > ranges = IRanges(start = 1:10, width = 5), strand = "*" ) > > names(foo) <- 1:10 > > export(foo, "foo.bed" ) > > foobar <- foo > > names(foobar) <- c(rep(1,2),3:10) > > export(foobar, "foobar.bed" ) > Error in export(object, FileForFormat(con), ...) : > cannot export object of class 'GRanges' > > sessionInfo() > R Under development (unstable) (2013-01-08 r61589) > 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] parallel stats graphics grDevices datasets utils methods > [8] base > > other attached packages: > [1] rtracklayer_1.19.6 CleftCNVAssoc_0.1.0 MinimumDistance_1.3.3 > [4] GWASTools_1.5.5 gdsfmt_0.9.10 sandwich_2.2-9 > [7] zoo_1.7-9 GWASExactHW_1.01 ncdf_1.6.6 > [10] Biobase_2.19.2 GenomicRanges_1.11.21 IRanges_1.17.24 > [13] BiocGenerics_0.5.6 > > loaded via a namespace (and not attached): > [1] affyio_1.27.1 annotate_1.37.3 AnnotationDbi_1.21.9 > [4] BiocInstaller_1.9.6 Biostrings_2.27.8 bit_1.1-9 > [7] bitops_1.0-5 BSgenome_1.27.1 codetools_0.2-8 > [10] crlmm_1.17.12 DBI_0.2-5 DNAcopy_1.33.1 > [13] ellipse_0.3-7 ff_2.2-10 foreach_1.4.0 > [16] genefilter_1.41.1 grid_3.0.0 iterators_1.0.6 > [19] lattice_0.20-13 lmtest_0.9-30 Matrix_1.0-10 > [22] msm_1.1.4 mvtnorm_0.9-9994 oligoClasses_1.21.6 > [25] preprocessCore_1.21.1 quantsmooth_1.25.0 RcppEigen_0.3.1.2 > [28] RCurl_1.95-3 Rsamtools_1.11.14 RSQLite_0.11.2 > [31] SNPchip_2.5.1 splines_3.0.0 stats4_3.0.0 > [34] survival_2.37-2 tools_3.0.0 VanillaICE_1.21.10 > [37] XML_3.95-0.1 xtable_1.7-0 zlibbioc_1.5.0 > > > [[alternative HTML version deleted]]
ADD COMMENT

Login before adding your answer.

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