Skip to content

tile_ranges and slide_ranges add directed argument #112

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
mikelove opened this issue Apr 1, 2025 · 0 comments
Open

tile_ranges and slide_ranges add directed argument #112

mikelove opened this issue Apr 1, 2025 · 0 comments
Assignees

Comments

@mikelove
Copy link
Member

mikelove commented Apr 1, 2025

It would be convenient to have negative strand features tiled/windowed in reverse.

I can work on a PR in the next devel cycle.

Some demo code:

x <- data.frame(seqnames=1, start=c(1,101), width=c(30,50), strand=c("+","-")) |> as_granges()
> x
GRanges object with 2 ranges and 0 metadata columns:
      seqnames    ranges strand
         <Rle> <IRanges>  <Rle>
  [1]        1      1-30      +
  [2]        1   101-150      -

> x |> slide_ranges(step=10, width=20) |> mutate(order = 1:n(), dir=ifelse(strand=="+",1,-1))
GRanges object with 6 ranges and 3 metadata columns:
      seqnames    ranges strand | partition     order       dir
         <Rle> <IRanges>  <Rle> | <integer> <integer> <numeric>
  [1]        1      1-20      + |         1         1         1
  [2]        1     11-30      + |         1         2         1
  [3]        1   101-120      - |         2         3        -1
  [4]        1   111-130      - |         2         4        -1
  [5]        1   121-140      - |         2         5        -1
  [6]        1   131-150      - |         2         6        -1

> y <- x |> slide_ranges(step=10, width=20) |> mutate(order = 1:n(), dir=ifelse(strand=="+",1,-1))

> y |> arrange(partition, dir * order)
GRanges object with 6 ranges and 3 metadata columns:
      seqnames    ranges strand | partition     order       dir
         <Rle> <IRanges>  <Rle> | <integer> <integer> <numeric>
  [1]        1      1-20      + |         1         1         1
  [2]        1     11-30      + |         1         2         1
  [3]        1   131-150      - |         2         6        -1
  [4]        1   121-140      - |         2         5        -1
  [5]        1   111-130      - |         2         4        -1
  [6]        1   101-120      - |         2         3        -1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: In Progress
Development

No branches or pull requests

1 participant