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)
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 |
[NrSamples x NrSamples] Matrix of kinship estimate.
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.
#>K_fromGenotypesNormalised <- getKinship(N=10, X=geno$genotypes, standardise=TRUE)#>#>#>kinshipfile <- system.file("extdata/kinship", "kinship.csv", package = "PhenotypeSimulator") K_fromFile <- getKinship(N=50, kinshipfile=kinshipfile)#>