File: test_design_matrix.R

package info (click to toggle)
r-bioc-deseq2 1.30.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,720 kB
  • sloc: cpp: 413; sh: 14; makefile: 2
file content (33 lines) | stat: -rw-r--r-- 1,117 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
context("design matrix")
test_that("design can be a matrix", {
  testthat::skip_if_not_installed("apeglm")

  m <- matrix(rpois(12*100,100),ncol=12)
  coldata <- data.frame(condition=factor(rep(1:2,each=6)),
                        batch=factor(rep(c(1,2,1,2),each=3)))
  dm <- model.matrix(~condition, coldata)
  dm2 <- model.matrix(~batch + condition, coldata)
  dds <- DESeqDataSetFromMatrix(m, coldata, dm)
  dds <- DESeq(dds, fitType="mean")
  resultsNames(dds)
  
  # specifying 'full' overrides...
  dds2 <- DESeq(dds, full=dm2, fitType="mean")
  resultsNames(dds2)

  dds <- DESeqDataSetFromMatrix(m, coldata, dm2)
  dds <- DESeq(dds, fitType="mean")
  
  res <- results(dds)
  res <- results(dds, contrast=list("condition2","batch2"))
  res <- results(dds, contrast=c(0,-1,1))
  expect_error(res <- results(dds, contrast=c("condition","2","1")), "only list- and numeric-type")

  res <- lfcShrink(dds, coef="condition2", type="normal")
  res <- lfcShrink(dds, coef="condition2", type="apeglm")
  res <- lfcShrink(dds, coef="condition2", type="ashr")
  
  # test replace with matrix
  design(dds) <- dm
  
})