data_sim: Data Simulation

Description Usage Arguments Value Examples

View source: R/data_sim.R

Description

Data Simulation

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
data_sim(
  n,
  K,
  prop,
  strg,
  binary = FALSE,
  case = NULL,
  corr = NULL,
  maf = NULL,
  beta = NULL
)

Arguments

n

Number of subjects.

K

Number of SNVs.

prop

Proportion of true causal/associated SNVs.

strg

Effect size. SNV effects are selected from U(-strg, strg) distribution.

binary

Idicator of whether the trait is binary.

case

Number of cases if binary trait is simulated. Default is n/2.

corr

Correlation matrix of the underlying multivariate normal distribution. Default is a first order autoregressive structure with adjacent correlation 0.9.

maf

Minor allele frequencies for the SNVs.

beta

SNV effects including the constant. If beta is given, K, prop and strg should be missing; otherwise, beta will be overwritten.

Value

A list object.

SNV

A n by K matrix with counts of minor alleles.

trait

A vector with simulated traits for n subjects.

zero_var

Indexes for columns with no variation. These columns should be removed if SNV is further used by perm_score, wAF and wAFd functions.

Examples

1
2
3
4
5
6
7
# Simulate data using n, K, prop, strg
data1 <- data_sim(100, 10, 0.1, 2)

# Simulate data using given beta
beta0 <- runif(11)
maf <- runif(10, min = 0.001, max = 0.3)
data2 <- data_sim(100, case = 60, maf = maf, beta = beta0)

songbiostat/wAF documentation built on Feb. 26, 2021, 6:24 p.m.