Estimate kinship from standardised genotypes or read pre-computed kinship file. Standardised genotypes can be obtained via standardiseGenotypes.

getKinship(N, sampleID = "ID_", X = NULL, kinshipfile = NULL,
  id_samples = NULL, standardise = FALSE, sep = ",", header = TRUE,
  verbose = TRUE)

Arguments

N

Number [integer] of samples to simulate.

sampleID

Prefix [string] for naming samples (will be followed by sample number from 1 to N when constructing id_samples).

X

[NrSamples x totalNrSNPs] Matrix of (standardised) genotypes.

kinshipfile

path/to/kinshipfile [string] to be read; either X or kinshipfile must be provided.

id_samples

Vector of [NrSamples] sample IDs [string]; if not provided constructed by paste(sampleID, 1:N, sep="").

standardise

[boolean] If TRUE genotypes will be standardised before kinship estimation.

sep

Field separator [string] of kinship file.

header

[boolean], If TRUE kinship file has header information.

verbose

[boolean]; If TRUE, progress info is printed to standard out

Value

[NrSamples x NrSamples] Matrix of kinship estimate.

Details

The kinship is estimated as \(K = XX_T\), with X the standardised genotypes of the samples. When estimating the kinship from the provided genotypes, the kinship is normalised by the mean of its diagonal elements and 1e-4 added to the diagonal for numerical stability.

Examples

geno <- simulateGenotypes(N=10, NrSNP=50)
#> Simulate 50 SNPs...
K_fromGenotypesNormalised <- getKinship(N=10, X=geno$genotypes, standardise=TRUE)
#> Standardising the 50 SNPs provided
#> Estimating kinship from 50 SNPs provided
#> Normalising kinship
kinshipfile <- system.file("extdata/kinship", "kinship.csv", package = "PhenotypeSimulator") K_fromFile <- getKinship(N=50, kinshipfile=kinshipfile)
#> Reading kinship file from /private/var/folders/rc/xlxbh6n92qzbm6dh_qqcd56h0000gq/T/RtmpKT8ktk/temp_libpath125b94774d8ae/PhenotypeSimulator/extdata/kinship/kinship.csv