Learn R Programming

plinkFile (version 0.1.0)

saveBSM: Save Symmetric Matrix to Binary

Description

Save symmetric matrix to a binary core file (.bin), and a text file of IDs (.id), recognizable by PLINK.

Usage

saveBSM(pfx, x, ltr = TRUE, diag = TRUE, unit = 4L, fid = ".")

Arguments

pfx

prefix of output files

x

symmetric matrix to save

ltr

store the lower triangle only? (def=TRUE)

diag

save diagnal? (def=TRUE) ignored if ltr is FALSE.

unit

numerical unit, (def=4, single precision)

fid

separator between FID and IID (def=".").

Examples

Run this code
pfx <- file.path(system.file("extdata", package="plinkFile"), "m20.rel")
rel <- readBSM(pfx)  # relatedness kernel matrix
re2 <- rel^2         # 2nd order polynomial kernel

tmp <- tempdir()
dir.create(tmp, FALSE)
out <- file.path(tmp, 'm20.re2')
saveBSM(out, re2)    # save the polynomial kernel
dir(tmp)             # show new files, then clean up
unlink(tmp, recursive=TRUE)

Run the code above in your browser using DataLab