Entering edit mode
I'm using ensembldb to construct some ranges, and then was using select()
to select some metadata columns.
I noticed that the transcripts I was working with have a metadata column width
, not the same as the width of the range. This then interferes with select()
:
> gr <- GRanges("chr1",IRanges(1:3,width=10))
> mcols(gr)$width <- 7
> mcols(gr)$test <- 0
> mcols(gr)$test2 <- "a"
> gr
GRanges object with 3 ranges and 3 metadata columns:
seqnames ranges strand | width test test2
<Rle> <IRanges> <Rle> | <numeric> <numeric> <character>
[1] chr1 1-10 * | 7 0 a
[2] chr1 2-11 * | 7 0 a
[3] chr1 3-12 * | 7 0 a
-------
seqinfo: 1 sequence from an unspecified genome; no seqlengths
> gr %>% select(test2)
GRanges object with 3 ranges and 1 metadata column:
seqnames ranges strand | test2
<Rle> <IRanges> <Rle> | <numeric>
[1] chr1 1-10 * | 0
[2] chr1 2-11 * | 0
[3] chr1 3-12 * | 0
-------
seqinfo: 1 sequence from an unspecified genome; no seqlengths
This is using current release/devel branch.
I wonder if select() should complain about metadata columns with names shared with core variables at the outset to avoid this issue?
Another
select()
issue, I think the error here could be instead about the missing metadata column: