This function reads a genotype matrix (
X, encoded as reference allele dosages) and its associated locus (
bim) and individual (
fam) data tables in the three Plink files in BED, BIM, and FAM formats, respectively.
All inputs must exist or an error is thrown.
This function is a wrapper around the more basic functions
which simplifies data parsing and additionally better guarantees data integrity.
Below suppose there are
m loci and
Input file path, without extensions (each of .bed, .bim, .fam extensions will be added automatically as needed). Alternatively, input file path may have .bed extension (but not .bim, .fam, or other extensions).
A named list with items in this order:
X (genotype matrix, see description in return value of
bim (tibble, see
fam (tibble, see
X has row and column names corresponding to the
id values of the
geno_to_char() for translating numerical genotypes into more human-readable character encodings.
Plink BED/BIM/FAM format reference: https://www.cog-genomics.org/plink/1.9/formats
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
# to read "data.bed" etc, run like this: # obj <- read_plink("data") # this also works # obj <- read_plink("data.bed") # # you get a list with these three items: # genotypes # obj$X # locus annotations # obj$bim # individual annotations # obj$fam # The following example is more awkward # because package sample data has to be specified in this weird way: # first get path to BED file file <- system.file("extdata", 'sample.bed', package = "genio", mustWork = TRUE) # read genotypes and annotation tables plink_data <- read_plink(file) # genotypes plink_data$X # locus annotations plink_data$bim # individual annotations plink_data$fam # the same works without .bed extension file <- sub('\\.bed$', '', file) # remove extension # it works! plink_data <- read_plink(file)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.