read_snp {genio} | R Documentation |
Read Eigenstrat *.snp files
Description
This function reads a standard Eigenstrat *.snp file into a tibble.
It uses readr::read_table()
to do it efficiently.
Usage
read_snp(file, verbose = TRUE)
Arguments
file |
Input file (whatever is accepted by |
verbose |
If |
Value
A tibble with columns: id
, chr
, posg
, pos
, ref
, alt
See Also
Eigenstrat SNP format reference: https://github.com/DReichLab/EIG/tree/master/CONVERTF
Examples
# to read "data.snp", run like this:
# snp <- read_snp("data")
# this also works
# snp <- read_snp("data.snp")
# The following example is more awkward
# because package sample data has to be specified in this weird way:
# read an existing Eigenstrat *.snp file
file <- system.file("extdata", 'sample.snp', package = "genio", mustWork = TRUE)
snp <- read_snp(file)
snp
# can specify without extension
file <- sub('\\.snp$', '', file) # remove extension from this path on purpose
file # verify .snp is missing
snp <- read_snp(file) # load it anyway!
snp