Learn R Programming

genio (version 1.0.9)

read_bim: Read plink *.bim files

Description

This function reads a standard plink *.bim file into a tibble. It uses readr::read_table2 to do it efficiently.

Usage

read_bim(file, verbose = TRUE)

Arguments

file

Input file (whatever is accepted by readr::read_table2). If file as given does not exist and is missing the expected *.bim extension, the function adds the .bim extension and uses that path if that file exists. Additionally, the .gz extension is added automatically if the file (after *.bim extension is added as needed) is still not found and did not already contained the .gz extension and adding it points to an existing file.

verbose

If TRUE (default) function reports the path of the file being loaded (after autocompleting the extensions).

Value

A tibble with columns: chr, id, posg, pos, ref, alt

See Also

read_plink for reading a set of BED/BIM/FAM files.

Plink BIM format reference: https://www.cog-genomics.org/plink/1.9/formats#bim

Examples

Run this code
# NOT RUN {
# read an existing plink *.bim file
file <- system.file("extdata", 'sample.bim', package = "genio", mustWork = TRUE)
bim <- read_bim(file)
bim

# can specify without extension
file <- sub('\\.bim$', '', file) # remove extension from this path on purpose
file # verify .bim is missing
bim <- read_bim(file) # loads too!
bim

# }

Run the code above in your browser using DataLab