This function writes a tibble with the right columns into a standard Eigenstrat *.snp file.
readr::write_tsv() to do it efficiently.
Output file (whatever is accepted by
The tibble or data.frame to write.
It must contain these columns:
tib invisibly (what
Eigenstrat SNP format reference: https://github.com/DReichLab/EIG/tree/master/CONVERTF
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
# to write an existing table `snp` into file "data.snp", run like this: # write_snp("data", snp) # this also works # write_snp("data.snp", snp) # 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( id = 1:3, chr = 1:3, posg = 0, pos = 1:3, ref = 'A', alt = 'B' ) # a dummy file file_out <- tempfile('delete-me-example', fileext = '.snp') # will also work without extension # write the table out in *.snp format (no header, columns in right order) write_snp(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.