Closed iimog closed 5 years ago
I think the conversion error may be coming from the IRanges package rather than plyranges here. I think this is due to there not being a as.data.frame
method for IntegerRanges class. If we take the example from the IRanges constructor man page:
suppressPackageStartupMessages(library(IRanges))
ir1 <- IRanges(c(1, 10, 20), width=5)
mcols(ir1) <- DataFrame(score=runif(3))
as.data.frame(ir1)
#> start end width
#> 1 1 5 5
#> 2 10 14 5
#> 3 20 24 5
We get the same issue. It'd be best to get this fixed on the IRanges end rather than implementing your own as.tibble method I think. I agree it's weird that the metadata gets silently dropped.
cc @lawremi would you be able to fix this? Is there a reason for this behaviour?
Thanks for looking into this. I fully agree, I'd rather see this fixed upstream than using my own as_tibble
method. I'm happy to help/test if I can.
Hi @iimog I'm closing this as it's not relevant to plyranges I would recommend posting an issue on Bioconductor/IRanges
When converting a
tibble
toIRanges
and back totibble
the metadata gets lost (while forGRanges
it is retained):My use case is to convert two
tibble
to IRanges in order to merge their metadata on overlapping intervals. Then I need to do some other modifications (e.g.replace_na
) for which I want to convert it back totibble
. My current workaround is to overwrite theas_tibble
method manually like this:This works for me but feels a little hacky and assumes that
elementMetadata
is always ordered identically to the ranges themselves. Is this a safe assumption? For me it is a rather common workflow to convert toIRanges
and back again and it feels quite naturally to me to do it as described above (with metadata included). Do you think this would be a good default behavior or are there good reasons to drop the metadata?I'm using
plyranges
1.3.2 onR
version 3.5.1, mysessionInfo()
: