Skip to content

tile_ranges and slide_ranges add directed argument #112

@mikelove

Description

@mikelove

It would be minor convenient to have negative strand features tiled/windowed in reverse. Just the arrangement.

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

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions