Simulate genetic data in R, including genotypes, phenotype status and liabilities, for individuals.

sim_test(n, m, q, hsq, k, to_ped = T)

Arguments

n

number of genotypes (individuals).

m

number of SNPS per genotype.

q

number of causal SNPs, i.e. SNPs that effect chances of having the phenotype.

hsq

squared heritability parameter.

k

prevalence of phenotype.

to_ped

if `TRUE`, write the genotype output in PLINK's .ped format. Else, write the number of minor alleles for each genotype at each SNP.

Value

Returns a list with 5 entries, containing a matrix of genotypes, a vector specifying effect sizes of SNPs, a vector with liability of individual i, a vector specifying phenotype status of individual i, and the transformed phenotype status used for linear regression in PLINK.

Details

A quick way of simulating a small amount of data to be stored in the R-session. Note that this function only simulates data for individuals without family history, i.e. they are not simulated as offspring. Hence, the simulation cannot be used in a study of family history.

Warning

Since this function saves the generated data directly in R (that is, on RAM), the function should not be used for large simulations, but rather to get an idea of the general framework.
The function does not run in parallel.

Examples

sim_test(10, 15, 5, 0.5, 0.05, TRUE)
#> $genotypes #> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] #> [1,] "1" "1" "1" "1" "1" "1" "c" "a" "c" "a" "a" "a" "c" #> [2,] "2" "1" "1" "1" "1" "1" "a" "a" "a" "a" "c" "a" "a" #> [3,] "3" "1" "1" "1" "1" "1" "a" "a" "c" "c" "a" "a" "a" #> [4,] "4" "1" "1" "1" "1" "1" "a" "a" "c" "a" "a" "a" "a" #> [5,] "5" "1" "1" "1" "1" "1" "c" "a" "a" "a" "a" "a" "c" #> [6,] "6" "1" "1" "1" "1" "1" "a" "a" "a" "a" "a" "a" "a" #> [7,] "7" "1" "1" "1" "1" "1" "a" "a" "c" "c" "a" "a" "a" #> [8,] "8" "1" "1" "1" "1" "1" "c" "c" "c" "a" "c" "a" "c" #> [9,] "9" "1" "1" "1" "1" "1" "c" "c" "a" "a" "a" "a" "a" #> [10,] "10" "1" "1" "1" "1" "1" "c" "a" "c" "a" "c" "a" "a" #> [,14] [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22] [,23] [,24] [,25] #> [1,] "a" "c" "c" "c" "a" "a" "a" "a" "a" "c" "a" "a" #> [2,] "a" "a" "a" "a" "a" "c" "a" "c" "a" "c" "c" "a" #> [3,] "a" "c" "a" "a" "a" "a" "a" "a" "a" "c" "c" "a" #> [4,] "a" "c" "a" "c" "c" "c" "a" "c" "a" "c" "a" "a" #> [5,] "a" "a" "a" "c" "a" "c" "a" "a" "a" "a" "a" "a" #> [6,] "a" "a" "a" "c" "c" "a" "a" "a" "a" "c" "a" "a" #> [7,] "a" "a" "a" "c" "c" "a" "a" "a" "a" "a" "a" "c" #> [8,] "a" "c" "a" "c" "a" "a" "a" "a" "a" "c" "a" "a" #> [9,] "a" "a" "a" "c" "a" "a" "a" "a" "a" "c" "a" "a" #> [10,] "a" "a" "a" "c" "a" "a" "a" "a" "a" "c" "a" "a" #> [,26] [,27] [,28] [,29] [,30] [,31] [,32] [,33] [,34] [,35] [,36] #> [1,] "a" "c" "c" "a" "a" "a" "a" "c" "c" "c" "a" #> [2,] "a" "c" "a" "a" "a" "a" "a" "a" "a" "c" "c" #> [3,] "a" "c" "a" "a" "a" "c" "a" "a" "a" "c" "a" #> [4,] "a" "c" "c" "a" "a" "a" "a" "a" "a" "c" "a" #> [5,] "a" "c" "a" "a" "a" "c" "a" "a" "a" "c" "a" #> [6,] "a" "a" "a" "c" "a" "c" "a" "c" "a" "c" "c" #> [7,] "a" "a" "a" "a" "a" "a" "a" "c" "c" "a" "a" #> [8,] "a" "c" "a" "a" "a" "c" "c" "c" "a" "c" "a" #> [9,] "a" "c" "c" "a" "a" "c" "a" "c" "a" "c" "c" #> [10,] "a" "c" "c" "a" "a" "a" "a" "c" "a" "a" "a" #> #> $effect_sizes #> [,1] #> [1,] 0.000000000 #> [2,] 0.000000000 #> [3,] 0.000000000 #> [4,] 0.000000000 #> [5,] 0.000000000 #> [6,] -0.065170493 #> [7,] 0.272615682 #> [8,] 0.000000000 #> [9,] 0.006064487 #> [10,] 0.009347931 #> [11,] 0.000000000 #> [12,] -0.076918211 #> [13,] 0.000000000 #> [14,] 0.000000000 #> [15,] 0.000000000 #> #> $liability #> [,1] #> [1,] -0.98080019 #> [2,] 1.00955437 #> [3,] -0.01082752 #> [4,] -0.70594804 #> [5,] -0.36774766 #> [6,] -0.14039586 #> [7,] -0.84222371 #> [8,] -0.37318018 #> [9,] 0.46251880 #> [10,] -0.12272320 #> #> $Phenotype #> [1] 1 1 1 1 1 1 1 1 1 1 #> #> $PLINK_linear_phenotype #> [1] 2 2 2 2 2 2 2 2 2 2 #>