noiseBgEffects: Simulate observational noise effects.

Description Usage Arguments Details Value Examples

View source: R/variancecomponentFunctions.R

Description

noiseBgEffects simulates observational noise with a proportion of the effect shared across samples and a proportion independent across samples.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
noiseBgEffects(
  N,
  P,
  mean = 0,
  sd = 1,
  sampleID = "ID_",
  phenoID = "Trait_",
  shared = TRUE,
  independent = TRUE,
  id_samples = NULL,
  id_phenos = NULL
)

Arguments

N

Number [integer] of samples to simulate.

P

Number [integer] of phenotypes to simulate.

mean

Mean [double] of the normal distribution.

sd

Standard deviation [double] of the normal distribution.

sampleID

Prefix [string] for naming samples.

phenoID

Prefix [string] for naming traits.

shared

[bool] shared effect simulated if set to TRUE; at least one of shared or independent has to be set to TRUE.

independent

[bool] independent effect simulated if set to TRUE.

id_samples

Vector of [NrSamples] sample IDs [string]; if not provided constructed by paste(sampleID, 1:N, sep="").

id_phenos

Vector of [NrTraits] phenotype IDs [string]; if not provided constructed by paste(phenoID, 1:P, sep="").

Details

For the simulation of the observational noise effects, two components are used: i) matrix B [N x P] with vec(B) drawn from a normal distribution with mean=mean and sd=sd and ii) the trait design matrix A [P x P]. For the independent effect, A is a diagonal matrix with normally distributed values. A for the shared effect is a matrix of rowrank one, with normally distributed entries in row 1 and zeros elsewhere. To construct the final effects, the two matrices are multiplied as: E = BA^T.

Value

Named list of shared noise effects (shared: [N x P] matrix) and independent noise effects (independent: [N x P] matrix), the covariance term of the shared effect (cov_shared: [P x P] matrix) and the covariance term of the independent effect (cov_independent: [P x P] matrix).

Examples

1
noiseBG <- noiseBgEffects(N=100, P=20, mean=2)

HannahVMeyer/PhenotypeSimulator documentation built on July 19, 2021, 7:41 a.m.