removeAllZeroVar: Remove all-zero variables from design matrix and the...

View source: R/removeAllZeroVar.R

removeAllZeroVarR Documentation

Remove all-zero variables from design matrix and the corresponding contrast matrix

Description

Remove all-zero variables from design matrix and the corresponding contrast matrix

Usage

removeAllZeroVar(obj, contrasts)

## S3 method for class 'matrix'
removeAllZeroVar(obj, contrasts)

## S3 method for class 'DesignContrast'
removeAllZeroVar(obj, contrasts = NULL)

Arguments

obj

Either a design matrix, rows are samples, columns are independent variables, and values are coefficients. Or a DesignContrast object that contains both design and contrast matrices. The design matrix may contain columns of all zeros, the independent variable corresponding to which can not be estimated.

contrasts

Either NULL, in case designMatrix is a DesignContrast object, or a contrast matrix matching the design matrix, i.e. the number of rows must equal the number of column of the design matrix. Rows are independent variables, columns are names of the contrasts to be estimated, the values are operations applied to the coefficients.

Value

Either a list of two matrices (design and contrasts), or a DesignContrast object, depending on the input parameter type. The design matrix and contrast matrix have an attribute each, notEstCoefs and notEstContrasts, that keep track of filtered variables and contrasts.

Methods (by class)

  • removeAllZeroVar(matrix): S3 function for matrix as input

  • removeAllZeroVar(DesignContrast): S3 function for matrix as input

Examples

myTestDesign <- matrix(c(1,1,1,1, 1,1,0,0,0,0,1,1,0,0,0,0), 
  byrow=FALSE, nrow=4L, 
  dimnames=list(sprintf("S%d", 1:4), c("Baseline", "Trt1", "Trt2", "Trt3")))
myTestContrast <- matrix(c(0,1,0,0, 0,0,1,0, 0,0,0,1), nrow=4L, byrow=FALSE,
  dimnames=list(colnames(myTestDesign), c("Trt1", "Trt2", "Trt3")))
removeAllZeroVar(myTestDesign, myTestContrast)
removeAllZeroVar(DesignContrast(myTestDesign, myTestContrast))

bedapub/ribiosExpression documentation built on Sept. 2, 2023, 4:37 a.m.