kin2gds: Store kinship matrix in GDS

Description Usage Arguments Details Author(s) See Also Examples

View source: R/kin2gds.R

Description

kin2gds and mat2gds write kinship matrices to GDS files.

Usage

1
2
kin2gds(ibdobj, gdsfile)
mat2gds(mat, gdsfile)

Arguments

ibdobj

A list with elements sample.id and kinship, such as the output of snpgdsIBDKING.

mat

A matrix with sample identifiers in colnames.

gdsfile

A character string with the name of the GDS file to create.

Details

When using pcair or pcairPartition with large sample sizes, it can be more memory efficient to read data from GDS files. kin2gds and mat2gds store kinship matrices in GDS files for use with these functions.

Author(s)

Stephanie M. Gogarten

See Also

kingToMatrix, snpgdsIBDKING

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
library(gdsfmt)

# KING results from the command-line program
file.kin0 <- system.file("extdata", "MXL_ASW.kin0", package="GENESIS")
file.kin <- system.file("extdata", "MXL_ASW.kin", package="GENESIS")
KINGmat <- kingToMatrix(c(file.kin0, file.kin), estimator="Kinship")
gdsfile <- tempfile()
mat2gds(KINGmat, gdsfile)
gds <- openfn.gds(gdsfile)
gds
closefn.gds(gds)

# KING results from SNPRelate
library(SNPRelate)
geno <- snpgdsOpen(snpgdsExampleFileName())
king <- snpgdsIBDKING(geno)
closefn.gds(geno)
kin2gds(king, gdsfile)
gds <- openfn.gds(gdsfile)
gds
closefn.gds(gds)

Example output

Reading in Kinship estimates from KING --kinship output...
Using 173 samples provided
Identifying clusters of relatives...
    173 relatives in 1 clusters; largest cluster = 173
Creating block matrices for clusters...
0 samples with no relatives included
File: /work/tmp/tmp/RtmpGp9Zmv/file2593122bf7ddd6 (235.5K)
+    [  ]
|--+ sample.id   { Str8 173, 1.4K }
\--+ kinship   { Float64 173x173, 233.8K }
SNPRelate -- supported by Streaming SIMD Extensions 2 (SSE2)
IBD analysis (KING method of moment) on genotypes:
Excluding 365 SNPs on non-autosomes
Excluding 1 SNP (monomorphic: TRUE, MAF: NaN, missing rate: NaN)
    # of samples: 279
    # of SNPs: 8,722
    using 1 thread
No family is specified, and all individuals are treated as singletons.
Relationship inference in the presence of population stratification.
KING IBD:    the sum of all selected genotypes (0,1,2) = 2446510
CPU capabilities: Double-Precision SSE2
Tue Mar  9 22:07:23 2021    (internal increment: 13056)

[..................................................]  0%, ETC: ---        
[==================================================] 100%, completed, 0s
Tue Mar  9 22:07:23 2021    Done.
File: /work/tmp/tmp/RtmpGp9Zmv/file2593122bf7ddd6 (610.7K)
+    [  ]
|--+ sample.id   { Str8 279, 2.2K }
\--+ kinship   { Float64 279x279, 608.1K }

GENESIS documentation built on Jan. 30, 2021, 2:01 a.m.