Convert genomic intervals from UCSC hg19 to hg38/GRCh38 using a preloaded chain object.

liftOverHg19(grOrDf)

Arguments

grOrDf

GRanges or data.frame. Input intervals. Data frames must contain at least seqnames, start, and end. seqnames may include or omit the "chr" prefix; it is added automatically if missing. Default: none (must be supplied).

Value

A GRanges-class in hg38 coordinates (with GenomeInfoDb::genome(x) <- "hg38"). Intervals that cannot be mapped by the chain are dropped (i.e., may return fewer ranges than provided).

Details

Internally, the input is coerced to a GRanges (adding "chr" if needed), then lifted over via rtracklayer with the chain stored in mesa::hg19ToHg38.over.chain. Unmappable or split mappings are handled by rtracklayer::liftOver(), and unmapped intervals are discarded when the result is unlisted. The returned object is tagged as "hg38".

Examples

# Data.frame input; mix of 'chr' and no 'chr' is fine
data.frame(
    seqnames = c("1", "chr2"),
    start    = c(100000, 200000),
    end      = c(100100, 200100)
) %>%
    liftOverHg19() %>%
    {
        GenomeInfoDb::genome(.)
    }
#> Performing coordinate liftover from hg19 to hg38
#>   chr1   chr2 
#> "hg38" "hg38" 

# GRanges input (some intervals may not map and can be dropped)
gr <- GenomicRanges::GRanges("chr1", IRanges::IRanges(100000, 100300))
liftOverHg19(gr)
#> Performing coordinate liftover from hg19 to hg38
#> Discarding unchained sequences: 1
#> GRanges object with 0 ranges and 0 metadata columns:
#>    seqnames    ranges strand
#>       <Rle> <IRanges>  <Rle>
#>   -------
#>   seqinfo: no sequences