Accept a GRanges or a data frame containing window coordinates and return a valid GenomicRanges::GRanges. Supported data-frame schemas:

  • seqnames, start, end

  • chr, start, end (renamed to seqnames)

  • chr, window_start, window_end (renamed to seqnames/start/end)

asValidGranges(object)

Arguments

object

GRanges or data.frame with window coordinates. Default: none (must be supplied).

Value

A GenomicRanges::GRanges built from object. Errors if no supported schema is found.

Examples

# From GRanges (passes through)
GenomicRanges::GRanges("chr1", IRanges::IRanges(100, 200)) %>%
    asValidGranges()
#> GRanges object with 1 range and 0 metadata columns:
#>       seqnames    ranges strand
#>          <Rle> <IRanges>  <Rle>
#>   [1]     chr1   100-200      *
#>   -------
#>   seqinfo: 1 sequence from an unspecified genome; no seqlengths

# From data.frame (seqnames/start/end)
data.frame(seqnames = "chr2", start = 10, end = 20) %>%
    asValidGranges()
#> GRanges object with 1 range and 0 metadata columns:
#>       seqnames    ranges strand
#>          <Rle> <IRanges>  <Rle>
#>   [1]     chr2     10-20      *
#>   -------
#>   seqinfo: 1 sequence from an unspecified genome; no seqlengths

# From data.frame (chr/window_start/window_end)
data.frame(chr = "1", window_start = 1000, window_end = 1100) %>%
    asValidGranges()
#> GRanges object with 1 range and 0 metadata columns:
#>       seqnames    ranges strand
#>          <Rle> <IRanges>  <Rle>
#>   [1]        1 1000-1100      *
#>   -------
#>   seqinfo: 1 sequence from an unspecified genome; no seqlengths