oneStepSim: One-step function for data simulation

Description Usage Arguments Details Value See Also Examples

View source: R/oneStepSim.R

Description

This function simulates pure and mixed cell-type expression data for two cell types, namely T and N. The simulation is based on multivariate normal (MVN) distribution.

Usage

1
2
3
4
5
oneStepSim(n.samp, mu.T, mu.N, Sigma.T=NULL, Sigma.N=NULL, prop.T="seq", 
           # structure for Sigma.T
           block.size, rho, dd=NULL, str.type="interchangeable",
           # selected genes to add structure
           select.gene="first")

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. If NULL, covariance matrix with special structure will be generated by generate.Sigma(). See also generate.Sigma().

Sigma.N

covariance matrix for cell type N. If NULL, identity matrix will be generated.

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.

block.size

see generate.Sigma().

rho

see generate.Sigma().

dd

see generate.Sigma().

str.type

see generate.Sigma().

select.gene

select which genes to add special structures on. Note that mu.T and mu.N should have the same order of genes. Options: "first" (default) means to select from the first gene in the mean vector; "random" means to randomly select genes; "DEG" means to select differentially expressed genes (according to order(abs(mu.T-mu.N),decreasing=TRUE)).

Details

The function takes the mean expression of each cell type at the log2-transformed scale and mixes the cell types in the raw scale (i.e. 2^x). If covariance matrices are not given, by default, the function generates an identity matrix for Sigma.N; and Sigma.T can be customized using corresponding arguments. Mixing proportion of cell type T is required; cell type N takes the complementary proportion. Pure cell-type samples are simulated from MVN; after mixing, the mixed samples are log2-transformed.

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:

m.gene

number of genes.

Sigma.T

covariance matrix of cell type T.

Sigma.N

covariance matrix of cell type N.

true.str.T

true structure in generated Sigma.T. A matrix with 0 (no structure) and 1 (an edge). If Sigma.T is given, it returns NULL.

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.

prop.T

true proportions of cell type T in mixed samples.

See Also

See sim.expr and generate.Sigma for more intermediate details.

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
## load cell type data
set.seed(999)
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 samples to simulate
n.samp <- 5

## parameters for correlation design of cell type T
rho <- c(0.9,0.8,0.7)
block.size <- c(5,10,15)
str.type <- c("interchangeable","decaying","star")
select.gene <- "DEG"

## mixing proportion of cell type T
prop.T <- runif(n.samp)

## one-step simulation
out.oneStepSim <- oneStepSim(n.samp, mu.T, mu.N, Sigma.T=NULL, Sigma.N=NULL, prop.T=prop.T, 
                             # structure for Sigma.T
                             dd=NULL, rho=rho, block.size=block.size, str.type=str.type,
                             # selected genes to add structure
                             select.gene=select.gene)

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