Bioconductor / GenomicRanges

Representation and manipulation of genomic intervals
https://bioconductor.org/packages/GenomicRanges
41 stars 17 forks source link

GPos doesn't survive round-trip conversion to data.frame #46

Open PeteHaitch opened 3 years ago

PeteHaitch commented 3 years ago
suppressPackageStartupMessages(library(GenomicRanges))

# Errors
gpos <- GPos(c("chr1", "chr2"), pos = c(3, 10))
as(as.data.frame(gpos), "GPos")
#> Error in .try_to_coerce_to_GRanges_first(from, "UnstitchedGPos"): object to coerce to UnstitchedGPos couldn't be coerced to GRanges first

# Workaround by first coercing to GRanges and then coercing result back to GPos
as(as(as.data.frame(as(gpos, "GRanges")), "GRanges"), "GPos")
#> UnstitchedGPos object with 2 positions and 0 metadata columns:
#>       seqnames       pos strand
#>          <Rle> <integer>  <Rle>
#>   [1]     chr1         3      *
#>   [2]     chr2        10      *
#>   -------
#>   seqinfo: 2 sequences from an unspecified genome; no seqlengths

Created on 2020-08-24 by the reprex package (v0.3.0)

Session info ``` r devtools::session_info() #> ─ Session info ─────────────────────────────────────────────────────────────── #> setting value #> version R version 4.0.2 (2020-06-22) #> os macOS Catalina 10.15.5 #> system x86_64, darwin17.0 #> ui X11 #> language (EN) #> collate en_AU.UTF-8 #> ctype en_AU.UTF-8 #> tz Australia/Melbourne #> date 2020-08-24 #> #> ─ Packages ─────────────────────────────────────────────────────────────────── #> package * version date lib source #> assertthat 0.2.1 2019-03-21 [1] CRAN (R 4.0.0) #> backports 1.1.8 2020-06-17 [1] CRAN (R 4.0.0) #> BiocGenerics * 0.35.4 2020-06-04 [1] Bioconductor #> bitops 1.0-6 2013-08-17 [1] CRAN (R 4.0.0) #> callr 3.4.3 2020-03-28 [1] CRAN (R 4.0.0) #> cli 2.0.2 2020-02-28 [1] CRAN (R 4.0.0) #> crayon 1.3.4 2017-09-16 [1] CRAN (R 4.0.0) #> desc 1.2.0 2018-05-01 [1] CRAN (R 4.0.0) #> devtools 2.3.1 2020-07-21 [1] CRAN (R 4.0.2) #> digest 0.6.25 2020-02-23 [1] CRAN (R 4.0.0) #> ellipsis 0.3.1 2020-05-15 [1] CRAN (R 4.0.0) #> evaluate 0.14 2019-05-28 [1] CRAN (R 4.0.0) #> fansi 0.4.1 2020-01-08 [1] CRAN (R 4.0.0) #> fs 1.5.0 2020-07-31 [1] CRAN (R 4.0.2) #> GenomeInfoDb * 1.25.10 2020-08-06 [1] Bioconductor #> GenomeInfoDbData 1.2.3 2020-04-30 [1] Bioconductor #> GenomicRanges * 1.41.6 2020-08-12 [1] Bioconductor #> glue 1.4.1 2020-05-13 [1] CRAN (R 4.0.0) #> highr 0.8 2019-03-20 [1] CRAN (R 4.0.0) #> htmltools 0.5.0 2020-06-16 [1] CRAN (R 4.0.0) #> IRanges * 2.23.10 2020-06-13 [1] Bioconductor #> knitr 1.29 2020-06-23 [1] CRAN (R 4.0.0) #> magrittr 1.5 2014-11-22 [1] CRAN (R 4.0.0) #> memoise 1.1.0 2017-04-21 [1] CRAN (R 4.0.0) #> pkgbuild 1.1.0 2020-07-13 [1] CRAN (R 4.0.0) #> pkgload 1.1.0 2020-05-29 [1] CRAN (R 4.0.0) #> prettyunits 1.1.1 2020-01-24 [1] CRAN (R 4.0.0) #> processx 3.4.3 2020-07-05 [1] CRAN (R 4.0.1) #> ps 1.3.4 2020-08-11 [1] CRAN (R 4.0.2) #> R6 2.4.1 2019-11-12 [1] CRAN (R 4.0.0) #> RCurl 1.98-1.2 2020-04-18 [1] CRAN (R 4.0.0) #> remotes 2.2.0 2020-07-21 [1] CRAN (R 4.0.2) #> rlang 0.4.7 2020-07-09 [1] CRAN (R 4.0.0) #> rmarkdown 2.3 2020-06-18 [1] CRAN (R 4.0.0) #> rprojroot 1.3-2 2018-01-03 [1] CRAN (R 4.0.0) #> S4Vectors * 0.27.12 2020-06-09 [1] Bioconductor #> sessioninfo 1.1.1 2018-11-05 [1] CRAN (R 4.0.0) #> stringi 1.4.6 2020-02-17 [1] CRAN (R 4.0.0) #> stringr 1.4.0 2019-02-10 [1] CRAN (R 4.0.0) #> testthat 2.3.2 2020-03-02 [1] CRAN (R 4.0.0) #> usethis 1.6.1 2020-04-29 [1] CRAN (R 4.0.0) #> withr 2.2.0 2020-04-20 [1] CRAN (R 4.0.0) #> xfun 0.16 2020-07-24 [1] CRAN (R 4.0.2) #> XVector 0.29.3 2020-06-25 [1] Bioconductor #> yaml 2.2.1 2020-02-01 [1] CRAN (R 4.0.0) #> zlibbioc 1.35.0 2020-05-14 [1] Bioconductor #> #> [1] /Library/Frameworks/R.framework/Versions/4.0/Resources/library ```

Context: I'm looking to convert GPos objects to data.frame objects before writing to disk in an HDF5 file so that I can make use of the existing write/read data.frame functionality in rhdf5.

PeteHaitch commented 3 years ago

Fairly minor issue but do you think it'll be fixed for the next release?

hpages commented 3 years ago

Hi Pete,

Sorry for the delay. Yes I want this fixed for the next release. A clean fix would actually require that I take care of this first, which I will ASAP.

H.