lmmatrix: Tests associations between multiple independent and dependent...

Description Usage Arguments Details Value Examples

Description

lmmatrix tests association between independent variables and dependent variables through simple linear regression (with 1 predictor variable)

Usage

1
lmmatrix(dep, ind, metric = "Rsquared")

Arguments

dep

n x d matrix or dataframe of dependent variables, where the variables are arranged in columns, and samples or observations in rows.

ind

n x i matrix or dataframe of independent variables, where the variables are arranged in columns, and samples or observations in rows.

metric

Determines what is returned from the linear models. 'Rsquared' returns the proportion of variance explained, and 'Pvalue' returns the p-value.

Details

Each independent variable is tested for their association with each dependent variable in simple linear regression (ind ~ dep), and a pvalue or rsquared is extracted and returned as a matrix. broom::glance() is used to calculate p value for the whole model.

Value

A i x d matrix of pvalues or rsquared values.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
## to calculate PC association with covariates

library(minfiData)
data(RGsetEx)
betas <- na.omit(getBeta(RGsetEx))
pDat <- as.data.frame(pData(RGsetEx))
pc_obj <- prcomp(t(betas))
pc_matrix <- pc_obj$x
cov <- pDat[,c('Sample_Group', 'age', 'sex')]

lmmatrix(dep = pc_matrix, ind = cov)
lmmatrix(dep = pc_matrix, ind = cov, metric = 'Pvalue')

wvictor14/vicbits documentation built on June 19, 2019, 4:48 p.m.