DataPrep: Preparing the covariates/responses for function...

Description Usage Arguments Value Note Author(s) Examples

View source: R/misc.r

Description

A convenient function for generating the full covariate matrix and preparing the response variables in a format that can be directly used by function ols.eblup.trim().

Usage

1
DataPrep(GeneExp, CellProp, Demo, include.demo=TRUE, w="iid")

Arguments

GeneExp

'GeneExp' is a m by n dimensional gene expression matrix, where m is the number of genes, and n is the number of subjects.

CellProp

'CellProp' is a n by K dimensional matrix of cell proportions, where K is the number of cell proportions.

Demo

Demo is a n by p dimensional matrix of clinical and demographic variables to be tested, where p is the number of covariates.

include.demo

Whether the demographical covariates should be included as the main effects in the model or not. Default to TRUE.

w

The weight matrix. The default value of 'w' is 'iid', which refers to a diagonal weighting matrix that is appropriate for i.i.d. data.

Value

X

A combined covariate matrix with cell proportions as main effects and all the interaction terms between cell proportions and demographic covariates. If include.demo is TRUE, the demographic covariates are also included in the model as main effects. These covariates are stacked in the row direction so that each gene has the same covariate matrix (see our manuscript for more details). 'X' also includes a new variable 'ID' which represents each gene.

Y

Vectorized gene expressions to be used as the response variable in the model.

Note

This function checks the numerical singularity of 'X', the combined covariate matrix. If the smallest singular value is less than '1e-7', it stops and asks the user to reduce the complexity of the model.

Author(s)

Hao Sun

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
## load the data example
data(dat_train)

## preparing the covariate/response (the i.i.d. case)
des1 <- DataPrep(dat_train$GeneExp, dat_train$CellProp, dat_train$Demo,include.demo=TRUE)
dim(des1$X)

## an example of the weighted case.
nsamples <- nrow(dat_train$Demo)
# randomly generate some weights
tnmr <- runif(nsamples, 1, 5)     
w = diag(tnmr)

## 
des2 <- DataPrep(dat_train$GeneExp, dat_train$CellProp, dat_train$Demo,include.demo=TRUE, w = w)

terrysun0302/FastMix documentation built on Nov. 14, 2019, 4:54 a.m.