write_fam | R Documentation |
This function writes a tibble with the right columns into a standard Plink *.fam file.
It uses readr::write_tsv()
to do it efficiently.
write_fam(file, tib, verbose = TRUE)
file |
Output file (whatever is accepted by |
tib |
The tibble or data.frame to write.
It must contain these columns: |
verbose |
If |
The output tib
invisibly (what readr::write_tsv()
returns).
write_plink()
for writing a set of BED/BIM/FAM files.
Plink FAM format reference: https://www.cog-genomics.org/plink/1.9/formats#fam
# to write an existing table `fam` into file "data.fam", run like this: # write_fam("data", fam) # this also works # write_fam("data.fam", fam) # 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( fam = 1:3, id = 1:3, pat = 0, mat = 0, sex = 1, pheno = 1 ) # a dummy file file_out <- tempfile('delete-me-example', fileext = '.fam') # will also work without extension # write the table out in *.fam format (no header, columns in right order) write_fam(file_out, tib) # delete output when done file.remove(file_out)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.