Skip to contents

Get upstream intervals from a GRanges object.

Usage

get_upstream(gr, width = 5000L)

Arguments

gr

A GenomicRanges object.

width

Width of the upstream interval. Default 5000.

Value

A GRanges object with intervals of width specified by width upstream of the start position of the gr input GRanges object.

Examples

gr <- data.frame(seqnames = "chr1",
                 strand = c("+", "-"),
                 start = c(42001, 67001),
                 width = c(1000, 1000),
                 gene = c("A", "B")) |>
  plyranges::as_granges()
gr
#> GRanges object with 2 ranges and 1 metadata column:
#>       seqnames      ranges strand |        gene
#>          <Rle>   <IRanges>  <Rle> | <character>
#>   [1]     chr1 42001-43000      + |           A
#>   [2]     chr1 67001-68000      - |           B
#>   -------
#>   seqinfo: 1 sequence from an unspecified genome; no seqlengths
get_upstream(gr)
#> GRanges object with 2 ranges and 2 metadata columns:
#>       seqnames      ranges strand |        gene ranges_original
#>          <Rle>   <IRanges>  <Rle> | <character>       <IRanges>
#>   [1]     chr1 37001-42000      + |           A     42001-43000
#>   [2]     chr1 67999-72998      - |           B     67001-68000
#>   -------
#>   seqinfo: 1 sequence from an unspecified genome; no seqlengths