Convert genomic intervals from UCSC hg19 to hg38/GRCh38 using a preloaded chain object.
liftOverHg19(grOrDf)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).
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".
# 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