fitModel: Fit model with proportions and phenotypes.

View source: R/fitModel.R

fitModelR Documentation

Fit model with proportions and phenotypes.

Description

This function receives design matrix from makeDesign() and fits the model including all cell types and phenotypes.

Usage

fitModel(Design_out, Y)

Arguments

Design_out

The output from function makeDesign().

Y

A G*N matrix, G is the number of features, N is the number of subjects; or a SummarizedExperiment object.

Value

Design_out

The input Design_out object.

N

Number of samples from matrix Y.

coefs

Estimated coefficients (beta) in the model.

coefs_var

Estimated variance of the coefficients (beta variance) in the model.

Y

Observation Y matrix.

Ypred

Predicted Y from the fitted model.

all_coefs

The names of all phenotypes.

all_cell_types

The names of all cell types.

MSE

Estimated mean squared error.

model_names

The names of all terms in the fitted model.

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
P <- 500 # 500 features

### 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")
Y <- matrix(rnorm(N*P, N, P), ncol = N)

### 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)

### fit model
fitted_model <- fitModel(Design_out, Y)


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