write_grm | R Documentation |
This function writes a GCTA Genetic Relatedness Matrix (GRM, i.e. kinship) set of files in their binary format, given a kinship matrix and, if available, the corresponding matrix of pair sample sizes (non-trivial under missingness) and individuals table.
Setting some options allows writing plink2 binary kinship formats such as "king" (follow examples in read_grm()
).
write_grm( name, kinship, M = NULL, fam = NULL, verbose = TRUE, ext = "grm", shape = c("triangle", "strict_triangle", "square"), size_bytes = 4 )
name |
The base name of the output files.
Files with that base, plus shared extension (default "grm", see |
kinship |
The symmetric |
M |
The optional symmetric |
fam |
The optional data.frame or tibble with individual annotations (columns with names |
verbose |
If |
ext |
Shared extension for all three outputs (see |
shape |
The shape of the information to write (may be abbreviated).
Default "triangle" assumes there are |
size_bytes |
The number of bytes per number encoded. Default 4 corresponds to GCTA GRM and plink2 "bin4", whereas plink2 "bin" requires a value of 8. |
read_grm()
# to write existing data `kinship`, `M`, and `fam` into files "data.grm.bin" etc, run like this: # write_grm("data", kinship, M = M, 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 dummy data to write # kinship for 3 individuals kinship <- matrix( c( 0.6, 0.2, 0.0, 0.2, 0.5, 0.1, 0.0, 0.1, 0.5 ), nrow = 3 ) # pair sample sizes matrix M <- matrix( c( 10, 9, 8, 9, 9, 7, 8, 7, 8 ), nrow = 3 ) # individual annotations table library(tibble) fam <- tibble( fam = 1:3, id = 1:3 ) # dummy files to write and delete name <- tempfile('delete-me-example') # no extension # write the data now! write_grm( name, kinship, M = M, fam = fam ) # delete outputs when done delete_files_grm( name )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.