make_design_matrix: Create a design matrix

Description Usage Arguments Details Value Examples

View source: R/de_analysis.R

Description

'make_design_matrix()' creates a model matrix for your DE analysis. See model.matrix for further details on what a design (or model) matrix is. This function prints out the column names so that you can view what your design matrix variable names are

Usage

1
make_design_matrix(metadata, vars)

Arguments

metadata

cleaned metadata for RNAseq data

vars

a character vector of variables to include in the model these should be case-specific and match the variable names in the metadata

Details

The order in which you specify your variables will affect which variable is dummy coded as the reference variable.

Value

a 'tbl' of the design matrix. Column names will be formatted as 'paste0(variablename, samplename)'

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
make_design_matrix(metadata, "CellType")

make_design_matrix(metadata, c("CellType", "Status"))

# Results in a different design matrix
make_design_matrix(metadata, c("Status", "CellType"))

# In a pipeline
counts <- readr::read_delim("data/GSE60450_Lactation-GenewiseCounts.txt", delim = "\t")
meta <- readr::read_delim("data/SampleInfo_Corrected.txt", delim = "\t") %>%
  mutate(FileName = stringr::str_replace(FileName, "\\.", "-"))

my_design <- check_sample_names(counts, c(1,2), meta, FileName) %>%
  purrr::pluck("meta") %>%
  make_design_matrix(., c("CellType"))

latlio/tidyde documentation built on Dec. 21, 2021, 9:40 a.m.