makeDesign: Generate design matrix from input phenotypes and proportions.

View source: R/makeDesign.R

makeDesignR Documentation

Generate design matrix from input phenotypes and proportions.

Description

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

Usage

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 <zli16@mdanderson.org>

References

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

Examples

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)

ziyili20/TOAST documentation built on Aug. 28, 2022, 11:28 a.m.