write_bim {genio} | R Documentation |
Write Plink *.bim files
Description
This function writes a tibble with the right columns into a standard Plink *.bim file.
It uses readr::write_tsv()
to do it efficiently.
Usage
write_bim(file, tib, verbose = TRUE, append = FALSE)
Arguments
file |
Output file (whatever is accepted by |
tib |
The tibble or data.frame to write.
It must contain these columns: |
verbose |
If |
append |
If |
Value
The output tib
invisibly (what readr::write_tsv()
returns).
See Also
write_plink()
for writing a set of BED/BIM/FAM files.
Plink BIM format references: https://www.cog-genomics.org/plink/1.9/formats#bim https://www.cog-genomics.org/plink/2.0/formats#bim
Examples
# to write an existing table `bim` into file "data.bim", run like this:
# write_bim("data", bim)
# this also works
# write_bim("data.bim", bim)
# The following example is more detailed but also more awkward
# because (only for these examples) the package must create the file in a *temporary* location
# create a dummy tibble with the right columns
library(tibble)
tib <- tibble(
chr = 1:3,
id = 1:3,
posg = 0,
pos = 1:3,
alt = 'B',
ref = 'A'
)
# a dummy file
file_out <- tempfile('delete-me-example', fileext = '.bim') # will also work without extension
# write the table out in *.bim format (no header, columns in right order)
write_bim(file_out, tib)
# example cleanup
file.remove(file_out)