makeDesign: Generate design matrix from input phenotypes and proportions.

Description Usage Arguments Value Author(s) References Examples

View source: R/makeDesign.R

Description

This function generate design matrix and make preparations for following fitModel and csTest.

Usage

1
makeDesign(design, Prop)

Arguments

design

A N by P phenotype matrix, with rows as samples and columns as phenotypes (e.g. age, gender, disease, etc.).

Prop

A N by K proportion matrix, with rows as samples and columns as cell types

Value

design_matrix

A comprehensive design matrix incorporated phenotype and proportion information.

Prop

The input proportion matrix.

design

The input design/phenotype matrix.

all_coefs

The names of all phenotypes.

all_cell_types

The names of all cell types.

formula

The formula of the tested model, including all phenotypes, cell types and interaction terms.

Author(s)

Ziyi Li <ziyi.li@emory.edu>

References

Ziyi Li, Zhijin Wu, Peng Jin, Hao Wu. "Dissecting differential signals in high-throughput data from complex tissues."

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
N = 300 # simulation a dataset with 300 samples
K = 3 # 3 cell types

### simulate proportion matrix
Prop = matrix(runif(N*K, 10,60), ncol=K)
Prop = sweep(Prop, 1, rowSums(Prop), FUN="/")
colnames(Prop) = c("Neuron", "Astrocyte", "Microglia")

### simulate phenotype names
design <- data.frame(disease=factor(sample(0:1, size = N,replace=TRUE)),
                     age=round(runif(N, 30,50)),
                     race=factor(sample(1:3, size = N,replace=TRUE)))
Design_out <- makeDesign(design, Prop)

TOAST documentation built on Nov. 8, 2020, 5:55 p.m.