This function allows users to lift genomic co-ordinates from one genome build to another. It uses an over.chain liftOver conversion file. Conversion files can be downloaded from UCSC.

liftover_coord(df, path_to_chain)

Arguments

df

a data.frame object with genomic coordinates. Must include the following columns:

  • CHR - character() vector, with "chr" attached to the chromosome e.g. chr1

  • BP - base pair, as a numeric() vector

Any additional columns included will be preserved.

path_to_chain

a character() vector, with the file path to the UCSC chain file for transformation.

Value

Dataframe with coordinates in different genome build.

Examples

file_path <- system.file( "testdata", "liftover_test_data.txt", package = "rutils", mustWork = TRUE ) hg19_path <- system.file( "testdata", "hg19ToHg38.over.chain", package = "rutils", mustWork = TRUE ) genomic_df <- readr::read_delim(file_path, delim = " ", col_types = readr::cols( SNP = readr::col_character(), CHR = readr::col_factor(), BP_hg19 = readr::col_integer(), BP_hg38 = readr::col_integer() ) ) liftover_coord( df = genomic_df %>% dplyr::select(SNP, CHR, BP = BP_hg19 ), path_to_chain = hg19_path )
#> # A tibble: 10 x 3 #> CHR BP SNP #> <chr> <int> <chr> #> 1 9 68413211 rs2639606 #> 2 6 25056560 rs75264089 #> 3 11 5842331 rs73396229 #> 4 13 94507628 rs55871206 #> 5 2 208036470 rs10932221 #> 6 4 176727425 rs56219727 #> 7 7 81365934 rs73709730 #> 8 1 78612399 rs55838886 #> 9 5 820966 rs3734153 #> 10 11 130258442 rs79381275