generate_snps: Generate SNP data with prespecified spatial correlation...

View source: R/generate_data.R

generate_snpsR Documentation

Generate SNP data with prespecified spatial correlation structure.

Description

This function generates SNPs under Hardy-Weinberg equilibrium with specific block correlation structure and minor allele frequencies.

Usage

generate_snps(
  n,
  p,
  cor_type = NULL,
  vec_rho = NULL,
  vec_maf = NULL,
  n_cpus = 1,
  user_seed = NULL
)

Arguments

n

Number of observations.

p

Number of SNPs.

cor_type

String describing the type of dependence structure. The SNPs can autocorrelated, equicorrelated. Set to NULL for independent SNPs.

vec_rho

Vector of correlation coefficients. Its length determines the number of blocks of correlated SNPs. Must be smaller than p. Set to NULL if independent SNPs.

vec_maf

Vector of length p containing the reference minor allele frequencies used to generate the SNPs. If NULL, the minor allele frequencies drawn uniformly at random between 0.05 and 0.5.

n_cpus

Number of CPUs used when simulating correlated SNP blocks. Ignored if independent SNPs. Set to 1 for serial execution.

user_seed

Seed set for reproducibility. Default is NULL, no seed set.

Value

An object of class "sim_snps".

snps

Matrix containing the generated SNP data.

vec_maf

Vector containing the SNP sample minor allele frequencies.

See Also

convert_snps, replicate_real_snps, convert_phenos, generate_phenos, replicate_real_phenos, generate_dependence

Examples

user_seed <- 123; set.seed(user_seed)
n <- 500; p <- 10000
cor_type <- "autocorrelated"; vec_rho <- runif(100, min = 0.25, max = 0.95)
list_snps <- generate_snps(n, p, cor_type, vec_rho, n_cpus = 1,
                           user_seed = user_seed)


hruffieux/echoseq documentation built on Jan. 10, 2024, 10:06 p.m.