create_design: Create design matrix

View source: R/8_fit_limma.R

create_designR Documentation

Create design matrix

Description

Create design matrix for statistical analysis

Usage

create_design(object, ...)

## S3 method for class 'SummarizedExperiment'
create_design(
  object,
  formula = default_formula(object),
  drop = varlevels_dont_clash(object, all.vars(formula)),
  codingfun = contr.treatment.explicit,
  verbose = TRUE,
  ...
)

## S3 method for class 'data.table'
create_design(
  object,
  formula = default_formula(object),
  drop = varlevels_dont_clash(object, all.vars(formula)),
  codingfun = contr.treatment.explicit,
  verbose = TRUE,
  ...
)

Arguments

object

SummarizedExperiment or data.frame

...

required to s3ify

formula

formula with svars

drop

whether to drop predictor names

codingfun

factor coding function

  • contr.treatment: intercept = y0, coefi = yi - y0

  • contr.treatment.explicit: intercept = y0, coefi = yi - y0

  • code_control: intercept = ymean, coefi = yi - y0

  • contr.diff: intercept = y0, coefi = yi - y(i-1)

  • code_diff: intercept = ymean, coefi = yi - y(i-1)

  • code_diff_forward: intercept = ymean, coefi = yi - y(i+)

  • code_deviation: intercept = ymean, coefi = yi - ymean (drop last)

  • code_deviation_first: intercept = ymean, coefi = yi - ymean (drop first)

  • code_helmert: intercept = ymean, coefi = yi - mean(y0:(yi-1))

  • code_helmert_forward: intercept = ymean, coefi = yi - mean(y(i+1):yp)

verbose

whether to message

Value

design matrix

Examples

file <- system.file('extdata/atkin.metabolon.xlsx', package = 'autonomics')
object <- read_metabolon(file)
unique(create_design(object))
unique(create_design(object, ~ Time))
unique(create_design(object, ~ Time, codingfun = contr.treatment.explicit))
unique(create_design(object, ~ Time, codingfun = contr.diff))
unique(create_design(object, ~ Time + Diabetes))
unique(create_design(object, ~ Time / Diabetes))
unique(create_design(object, ~ Time * Diabetes))

bhagwataditya/autonomics documentation built on Nov. 1, 2024, 5:47 a.m.