replicate_real_snps: Generate SNPs emulating real SNP data at hand.

View source: R/replicate_data.R

replicate_real_snpsR Documentation

Generate SNPs emulating real SNP data at hand.

Description

This function simulates SNPs from real SNP data based on their sample minor allele frequencies and correlation structure.

Usage

replicate_real_snps(
  n,
  real_snps,
  bl_lgth,
  p = NULL,
  maf_thres = NULL,
  n_cpus = 1,
  user_seed = NULL
)

Arguments

n

Number of observations.

real_snps

Matrix of real SNPs (rows observations, columns SNP variables), without missing values. The entries must be 0, 1 or 2.

bl_lgth

Number of variables per block for reproducing the dependence structure of real SNPs. Must be between 2 and p. Must be small enough (e.g. 1000) for tractability reasons.

p

Number of SNPs. If NULL, the total number of SNPs available in the real_snps matrix is used (default).

maf_thres

Lower bound for sample minor allele frequencies. Simulated SNPs with lower sample minor allele frequencies are excluded (as a result the number of simulated SNPs can be smaller than p). Default is NULL for no exclusion.

n_cpus

Number of CPUs used when simulating SNP by blocks. 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, generate_snps, convert_phenos, generate_phenos, replicate_real_phenos, generate_dependence

Examples

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


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