Coerce a table of windows to a GRanges-class. Two input layouts are supported:

  • chr, window_start, window_end (as in qsea::makeTable() output), or

  • seqnames, start, end.

qseaTableToChrGRanges(dataTable)

Arguments

dataTable

data.frame. Table of windows to convert. Must contain either the trio chr/window_start/window_end or seqnames/start/end. Default: none (must be supplied).

Value

A GRanges with seqnames in UCSC style. The genome is unset.

Details

If chromosome labels lack the "chr" prefix, it is added automatically so that seqnames are in UCSC style (e.g., "chr1").

  • When given chr/window_start/window_end, the columns are renamed to seqnames/start/end before coercion.

  • When given seqnames/start/end, seqnames are first coerced to character and normalised to include the "chr" prefix.

  • The returned GRanges does not set a genome tag; set it yourself if needed (e.g., GenomeInfoDb::genome(gr) <- "hg38").

Examples

# From makeTable-like columns
data.frame(chr = c("1", "2"),
    window_start = c(100, 500),
    window_end = c(200, 600)) %>%
    qseaTableToChrGRanges()
#> GRanges object with 2 ranges and 3 metadata columns:
#>       seqnames    ranges strand |         chr window_start window_end
#>          <Rle> <IRanges>  <Rle> | <character>    <numeric>  <numeric>
#>   [1]     chr1   100-200      * |           1          100        200
#>   [2]     chr2   500-600      * |           2          500        600
#>   -------
#>   seqinfo: 2 sequences from an unspecified genome; no seqlengths

# From seqnames/start/end; adds 'chr' if missing
data.frame(seqnames = c("chr3", "4"),
    start = c(1000, 2000),
    end = c(1100, 2100)) %>%
    qseaTableToChrGRanges()
#> GRanges object with 2 ranges and 0 metadata columns:
#>       seqnames    ranges strand
#>          <Rle> <IRanges>  <Rle>
#>   [1]     chr3 1000-1100      *
#>   [2]     chr4 2000-2100      *
#>   -------
#>   seqinfo: 2 sequences from an unspecified genome; no seqlengths