Shuffle does not preserve feature width #51

Closed
snystrom opened this Issue Mar 30, 2017 · 1 comment

Comments

Projects
None yet
2 participants
@snystrom

`
library(GenomicRanges)
library(ChIPseeker)
gr <- GRanges(Rle(c("chr2L", "chr2L", "chrX", "chr3R"), c(1, 3, 2, 4)),
IRanges(1:10, width=10:1, names=head(letters, 10)),
Rle(strand(c("-", "+", "*", "+", "-")), c(1, 2, 2, 3, 2)))

shuffle_gr <- shuffle(gr, BSgenome.Dmelanogaster.UCSC.dm3::BSgenome.Dmelanogaster.UCSC.dm3)
`

These values should be equal but they are not:
`

width(gr)
[1] 10 9 8 7 6 5 4 3 2 1
width(shuffle_gr)
[1] 11 10 9 8 5 4 3 2 7 6
`

Shuffle also does not correctly deal with granges objects that are not sorted by chromosome name (see also in my example how the width of the region output is not only off by 1 but is in the incorrect order. The 'order' function used to calculate ii should be replaced with seq_along() to avoid this error. Further, explicitly setting width = w[ii] in the RLE call will solve the width issue instead of using start[ii] + w[ii]. The end result here is that not only are the features the wrong size, but if the input is not a sorted list by chromosome, the incorrect chromosome size will be used to calculate the shuffled position.

@GuangchuangYu

This comment has been minimized.

Show comment
Hide comment
@GuangchuangYu

GuangchuangYu Mar 31, 2017

Owner

I intended to order the output GRanges in chromosome alphabetical order. It do calculate the chromosome size correctly. All the things you mentioned here are not true except the width issue.

Thank you for pointing the width issue, it was fixed.

Owner

GuangchuangYu commented Mar 31, 2017

I intended to order the output GRanges in chromosome alphabetical order. It do calculate the chromosome size correctly. All the things you mentioned here are not true except the width issue.

Thank you for pointing the width issue, it was fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment