sim.expr: Simulate expression data

Description Usage Arguments Details Value See Also Examples

View source: R/oneStepSim.R

Description

This function simulates expression data for pure and mixed samples, with two cell types (namely, T and N).

Usage

1
sim.expr(n.samp, mu.T, mu.N, Sigma.T, Sigma.N, prop.T="seq")

Arguments

n.samp

number of samples to simulate for each cell type.

mu.T

mean vector for cell type T.

mu.N

mean vector for cell type N.

Sigma.T

covariance matrix for cell type T.

Sigma.N

covariance matrix for cell type N.

prop.T

a vector of mixing proportions for cell type T. Options: "seq" (default), "unif", or a customized vector of length n.samp. If "seq", prop.T = seq(0, 1, length=n.samp); if "unif", prop.T = runif(n.samp, 0, 1). And proportions for cell type N are 1-prop.T.

Details

The function takes the mean expression (at the log2-transformed scale) and designed covariance structure for two cell types, namely T and N. Mixing proportion of cell type T is required; cell type N takes the complementary proportion. Pure cell-type samples are simulated from multivariate normal (MVN) distribution at the log2-transformed scale. Mixing of cell types is made at the raw scale, i.e. 2^x. The mixed samples are then log2-transformed back.

All MVN simulated expression data are forced to be non-negative by replacing negative values with zero. All simulated samples are quantile normalized by normalize.quantiles() from the preprocessCore package.

Value

A list with the following components:

expr.pure.T

expression matrix for pure cell type T.

expr.pure.N

expression matrix for pure cell type N.

expr.mixed

expression matrix for mixed cell types.

See Also

rmvnorm from the mvtnorm package is used for simulate random MVN samples.

normalize.quantiles from the preprocessCore package is used for quantile normalization.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
## load cell type data
data("celltype")
mu.T <- expr[,ctab$Fastq_file_name[which(ctab$X3_letter_code=="ASM")]]
mu.N <- expr[,ctab$Fastq_file_name[which(ctab$X3_letter_code=="AEC")]]

## number of genes
m.gene <- length(mu.T)

## parameters
n.samp <- 5
rho <- c(0.9,0.8,0.7)
block.size <- c(5,10,15)
str.type <- c("interchangeable","decaying","star")

## mixing proportions for cell type T
prop.T <- seq(0, 1, length=n.samp)

## generate covariance matrices
out.Sigma.T <- generate.Sigma(m.gene=m.gene, dd=rep(1,m.gene), rho=rho, block.size=block.size, str.type=str.type)
Sigma.T <- out.Sigma.T$Sigma
Sigma.N <- diag(m.gene) # identity matrix

## simulate pure and mixed expression samples
out.expr <- sim.expr(n.samp, mu.T, mu.N, Sigma.T, Sigma.N, prop.T)

## If mixing proportions for cell type T are all 0's
prop0 <- rep(0, n.samp)
## mixed samples should be the same as the pure samples for cell type N
out.expr0 <- sim.expr(n.samp, mu.T, mu.N, Sigma.T, Sigma.N, prop0)
identical(as.numeric(out.expr0$expr.mixed), as.numeric(out.expr0$expr.pure.N))

yunzhang813/simDeNet-R-Package documentation built on Dec. 24, 2019, 3:02 p.m.