fitModel {TOAST} | R 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 <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
    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)

[Package TOAST version 1.6.0 Index]