sim_genotypes: sim_genotypes

Description Usage Arguments Details Value

View source: R/genotype_sim.R

Description

Simulate a matrix of genotypes following a set of model parameters.

Usage

1
2
3
4
sim_genotypes(n_snps = 50000, n_control = 2000, n_case = c(1000, 1000),
  pars = c(0.9, 0.05, 2, 2, 3, 1), q2SEd = NULL, q2SEa1 = NULL,
  q2SEa2 = NULL, cor_st = NULL, seed = NULL, return_matrix = FALSE,
  null_model = TRUE)

Arguments

n_snps

number of SNPs

n_control

number of controls

n_case

two-element vector; number of cases in subtypes 1 and 2

pars

expected observed parameter values. If NULL, values are chosen randomly; pi0 from c(0.1,0.01,0.001),1), pi1 from c(0.2,0.1,0.05); q2SEd from c(1,1.2,1.5,2); q2SEa1 from c(1.2,1.5,2); (if null_model==FALSE) q2SEa2 from c(1.2,1.5,2); and rho from c(0,0.1,0.5).

q2SEd

97.5% quantile (ie, +2SD) of population odds-ratios for subtype-differentiating SNPs. Corresponds to tau in pars and overrides pars if set.

q2SEa1

97.5% quantile (ie, +2SD) of population odds-ratios for disease-causative SNPs which do NOT differentiate subtypes (category 2). Corresponds to sigma_1 in pars and overrides pars if set.

q2SEa2

97.5% quantile (ie, +2SD) of population odds-ratios for disease-causative SNPs which DO differentiate subtypes (category 3). Corresponds to sigma_2 in pars and overrides pars if set.

cor_st

correlation (as opposed to covariance) between sigma2 and tau. Overrides pars if set.

seed

random seed; if NULL is set to clock time

return_matrix

if TRUE, returns a SNP matrix, otherwise returns Z_a and Z_d scores

null_model

if pars=NULL and other parameters are null, parameters are chosen randomly. If null_model=TRUE, parameters are chosen from H0, otherwise H1.

Details

Sets global variable pars_true containing 'true' parameter values, and or_true containing details of underlying odds ratio distribution.

Value

Either object of type SnpMatrix, in which indices are, in order: controls, case subtype 1, case subtype 2; or Z_d and Z_a scores in an n x 2 matrix, with Z[,1]=Z_d, Z[,2]=Z_a. Global variable pars_true contains 'true' values of parameters of Z_a, Z_d distribution and can be used to start the fitting algorithm. Global variable or_true contains values (pi0,pi1,q2SEd,q2SEa1,q2SEa2,cor_st)


jamesliley/subtest documentation built on May 18, 2019, 11:21 a.m.