makeDesign {TOAST}R 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 <ziyi.li@emory.edu>

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)

[Package TOAST version 1.7.1 Index]