gr_to_bed: Convert Granges to bed tibble

Description Usage Arguments Value Examples

View source: R/tbls.r

Description

Convert Granges to bed tibble

Usage

1

Arguments

x

GRanges object to convert to bed tibble.

Value

tibble::tibble()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
## Not run: 
gr <- GenomicRanges::GRanges(
        seqnames = S4Vectors::Rle(
                     c("chr1", "chr2", "chr1", "chr3"),
                     c(1, 1, 1, 1)),
        ranges   = IRanges::IRanges(
                     start = c(1, 10, 50, 100),
                     end = c(100, 500, 1000, 2000),
                     names = head(letters, 4)),
        strand   = S4Vectors::Rle(
                     c("-", "+"), c(2, 2))
      )

gr_to_bed(gr)

# There are two ways to convert a bed-like data.frame to GRanges:

gr <- GenomicRanges::GRanges(
        seqnames = S4Vectors::Rle(x$chrom),
        ranges   = IRanges::IRanges(
                     start = x$start + 1,
                     end = x$end,
                     names = x$name),
        strand   = S4Vectors::Rle(x$strand)
        )
# or:

gr <- GenomicRanges::makeGRangesFromDataFrame(dplyr::mutate(x, start = start +1))


## End(Not run)

valr documentation built on Dec. 11, 2021, 9:57 a.m.