getReadMatrix.CP: Simulate a read matrix from compound Poisson mixed effect...

Description Usage Arguments Value Examples

View source: R/HeriTools.R

Description

Simulate a (possibly unbalanced) read matrix from CPMM. For a compound Poisson (CP) random variable Y_{gsr} with mean μ_{gs}, its variance can be expressed as φ_gμ_{gs}^{p_g}, for some 1<p_g<2. Under the CPMM, with a \log-link, the regression on the mean has the form:
\log(μ_{gs}) = α_g+ b_{gs}, \;\;b_{gs}\sim N(0, σ^2_g).

Usage

1
getReadMatrix.CP(vec.num.rep, alphas, sigma2s, ps, phis)

Arguments

vec.num.rep

A vector of replicate numbers for each strain.

alphas

Intercept vector α_g's, 1 x num.features.

sigma2s

Random effect variance vector σ^2_g's, 1 x num.features.

ps

Tweedie parameter in CP models, p_g's, a 1 x num.features vector.

phis

Dispersion parameter in CP models, φ_g's, a 1 x num.features vector.

Value

A G x N matrix with CP reads. N is the total number of samples; G is the number of features. Column names are sample names of the form "Ss_r", where S stands for sample, s is the strain number, r is the replicate number within the strain. Row names are the feature names of the form "Gene g", where g is the feature index.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
## Generate a sequencing dataset with 5 features and 6 strains. 
## Assign parameter values.
rep.num <- c(3, 5, 2, 3, 4, 2)
a0s <- c(-1, 1, 2, 5, 10)
sig2s <- c(10, 0.2, 0.1, 0.03, 0.01)
ps <- rep(1.5, 5)
phis <- c(1.5, 1, 0.5, 0.1, 0.1)

set.seed(1234)
## Generate reads:
cpData <- getReadMatrix.CP(rep.num, a0s, sig2s, ps, phis)
## Generate strain names:
str <- sapply(1:length(rep.num), function(x){
  str.x <- paste0("S", x)
  return(rep(str.x, rep.num[x]))
})
str <- do.call(c, str)

HeritSeq documentation built on July 13, 2021, 1:06 a.m.