read_grm: Read GCTA GRM binary files

Description Usage Arguments Value See Also Examples

View source: R/read_grm.R

Description

This function reads a GCTA Genetic Relatedness Matrix (GRM, i.e. kinship) set of files in their binary format, returning the kinship matrix and, if available, the corresponding matrix of pair sample sizes (non-trivial under missingness) and individuals table.

Usage

1
read_grm(name, n_ind = NA, verbose = TRUE)

Arguments

name

The base name of the input files. Files with that base and extensions .grm.bin, .grm.N.bin, and .grm.id are read if they exist. Only .grm.bin is absolutely required; .grm.id can be substituted by the number of individuals (see below); .grm.N.bin is entirely optional.

n_ind

The number of individuals, required if the file with the extension .grm.id is missing. If the file with the .grm.id extension is present, then this n_ind is ignored.

verbose

If TRUE (default), function reports the path of the files being loaded.

Value

A list with named elements:

See Also

Greatly adapted from sample code from GCTA: https://cnsgenomics.com/software/gcta/#MakingaGRM

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
# to read "data.grm.bin" and etc, run like this:
# obj <- read_grm("data")
# obj$kinship # the kinship matrix
# obj$M       # the pair sample sizes matrix
# obj$fam     # the fam and ID tibble

# The following example is more awkward
# because package sample data has to be specified in this weird way:

# read an existing set of GRM files
file <- system.file("extdata", 'sample.grm.bin', package = "genio", mustWork = TRUE)
file <- sub('\\.grm\\.bin$', '', file) # remove extension from this path on purpose
obj <- read_grm(file)
stopifnot( !is.null( obj$kinship ) ) # the kinship matrix
stopifnot( !is.null( obj$M ) )       # the pair sample sizes matrix
stopifnot( !is.null( obj$fam ) )     # the fam and ID tibble

genio documentation built on July 27, 2021, 1:06 a.m.