replicate_real_phenos: Generate phenotypes emulating real phenotypic data at hand.

View source: R/replicate_data.R

replicate_real_phenosR Documentation

Generate phenotypes emulating real phenotypic data at hand.

Description

This function simulates phenotypes from real phenotypic data based on their sample correlation structure. If binary data are provided, will simulate latent Gaussian data from them (binary data can then be obtained using the generate_dependence function).

Usage

replicate_real_phenos(
  n,
  real_phenos,
  input_family = "gaussian",
  bl_lgth = NULL,
  d = NULL,
  n_cpus = 1,
  user_seed = NULL
)

Arguments

n

Number of observations.

real_phenos

Matrix of real phenotypes (rows observations, columns phenotypic variables), without missing values.

input_family

Phenotype distribution assumption for the phenotypes provided in real_phenos. Must be either "gaussian" or "binomial" for binary phenotypes.

bl_lgth

Number of variables per block for reproducing the dependence structure of real phenotypes. Must be between 2 and d. Must be small enough (e.g. 1000) for tractability reasons. Default is NULL for a single block.

d

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

n_cpus

Number of CPUs used when simulating phenotypes 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_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, generate_phenos, generate_dependence

Examples

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

# Provided phenotypes assumed to be normally distributed
var_err <- runif(d, min = 0.1, max = 0.4)
list_fake_real_phenos <- generate_phenos(n, d, var_err, cor_type = cor_type,
                                         vec_rho = vec_rho, n_cpus = 1,
                                         user_seed = user_seed)
list_phenos <- replicate_real_phenos(n, list_fake_real_phenos$phenos,
                                     input_family = "gaussian", bl_lgth = 100,
                                     n_cpus = 1, user_seed = user_seed)


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