generate_phenos: Generate phenotypic data with prespecified block-wise...

View source: R/generate_data.R

generate_phenosR Documentation

Generate phenotypic data with prespecified block-wise correlation structure.

Description

This function generates Gaussian phenotypes with specific block correlation structure. If binary phenotypes are wanted, must be used in conjunction with the generate_dependence function: the present function simulates latent Gaussian phenotypes which will be used in generate_dependence to generate binary phenotypes associated with SNPs from a probit model.

Usage

generate_phenos(
  n,
  d,
  var_err = 1,
  cor_type = NULL,
  vec_rho = NULL,
  n_cpus = 1,
  user_seed = NULL
)

Arguments

n

Number of observations.

d

Number of phenos.

var_err

Vector of length 1 or d containing the variances of the (latent) Gaussian distributions used to generate the phenotypes. If of length 1, the value is repeated d times. If binary data are targeted (using the probit modelling within the generate_dependence function), var_err is usually set to 1 (no impact on inference).

cor_type

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

vec_rho

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

n_cpus

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

user_seed

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

Value

An object of class "sim_phenos".

phenos

Matrix containing the generated phenotypic data.

var_err

Vector containing the sample phenotypic variances.

ind_bl

List of length given by the number of blocks, containing the indices of the phenotypes in each block. Is NULL if cor_type is NULL.

See Also

convert_snps, generate_snps, replicate_real_snps, convert_phenos, replicate_real_phenos, generate_dependence

Examples

user_seed <- 123; set.seed(user_seed)
n <- 500; d <- 10000
cor_type <- "equicorrelated"; vec_rho <- runif(100, min = 0.25, max = 0.95)

list_phenos <- generate_phenos(n, d, cor_type = cor_type, vec_rho = vec_rho,
                               n_cpus = 1, user_seed = user_seed)


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