liftover_coord: Liftover genomic coordinates from one genome build to...

View source: R/liftover_coord.R

liftover_coordR Documentation

Liftover genomic coordinates from one genome build to another.

Description

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.

Usage

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
)

RHReynolds/rutils documentation built on March 26, 2022, 8:17 a.m.