Skip to content

Commit 3e21ce7

Browse files
committed
setup and post-class scripts for week 6 lesson 04
1 parent 560d602 commit 3e21ce7

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

lessons/wk6_lesson04_design_formulas.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,28 @@ Approximate time: 30 minutes
1111
- Demonstrate the use of the design formula with simple and complex designs
1212
- Construct R code to execute the differential expression analysis workflow with DESeq2
1313

14+
## Catch-up Script:
15+
16+
If you need to be completely caught up, you can copy and paste the following into an R Script and run it. If you don't already have the files in your `/data` directory, please see [Wk 5 Lesson 01](../wk5_lesson01_introR_Rstudio.md) for instructions on where to obtain the input files.
17+
18+
``` r
19+
# Setup
20+
# Bioconductor and CRAN libraries used - already installed on Biowulf
21+
library(tidyverse)
22+
library(RColorBrewer)
23+
library(DESeq2)
24+
library(pheatmap)
25+
library(BiocManager)
26+
27+
# Load in data
28+
data <- read.table("data/mov10_AllSamples_featurecounts.Rmatrix.txt", header=T, row.names=1)
29+
30+
meta <- read.table("data/mov10_AllSamples_metadata.txt", header=T, row.names=1)
31+
32+
# Create DESeq2Dataset object
33+
dds <- DESeqDataSetFromMatrix(countData = data, colData = meta, design = ~ sampletype)
34+
```
35+
1436
# Differential expression analysis with DESeq2
1537

1638
The final step in the differential expression analysis workflow is **fitting the raw counts to the NB model and performing the statistical test** for differentially expressed genes. In this step we essentially want to determine whether the mean expression levels of different sample groups are significantly different.
@@ -168,3 +190,28 @@ Given the the metadata table you have sent me for your own experiment, do the fo
168190

169191
1. Write a design formula for your experiment, in the format of `design = ~ sex + age + treatment` . Make sure to include any interaction terms or terms that you want to "regress" out. There are additional recommendations for complex designs in the [DESeq2 vignette](https://www.bioconductor.org/packages/devel/bioc/vignettes/DESeq2/inst/doc/DESeq2.html#interactions).
170192
2. Briefly explain (in 1-2 sentences) the reasoning for this design formula.
193+
194+
## Your DE script
195+
196+
In this lesson, we took the additional step of running the actual DESeq2 analysis. Your `de_script.R` should now contain the following commands to re-create necessary data objects (click to show):
197+
198+
``` r
199+
# Setup
200+
# Bioconductor and CRAN libraries used - already installed on Biowulf
201+
library(tidyverse)
202+
library(RColorBrewer)
203+
library(DESeq2)
204+
library(pheatmap)
205+
library(BiocManager)
206+
207+
# Load in data
208+
data <- read.table("data/mov10_AllSamples_featurecounts.Rmatrix.txt", header=T, row.names=1)
209+
210+
meta <- read.table("data/mov10_AllSamples_metadata.txt", header=T, row.names=1)
211+
212+
# Create DESeq2Dataset object
213+
dds <- DESeqDataSetFromMatrix(countData = data, colData = meta, design = ~ sampletype)
214+
215+
# Run DESeq2 on DESeq2Dataset object
216+
dds <- DESeq(dds)
217+
```

scripts/de_analysis_wk6_lesson01.R

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,8 @@ data <- read.table("data/mov10_AllSamples_featurecounts.Rmatrix.txt", header=T,
1111

1212
meta <- read.table("data/mov10_AllSamples_metadata.txt", header=T, row.names=1)
1313

14+
# Create DESeq2Dataset object
15+
dds <- DESeqDataSetFromMatrix(countData = data, colData = meta, design = ~ sampletype)
16+
17+
# Run DESeq2 on DESeq2Dataset object
18+
dds <- DESeq(dds)

0 commit comments

Comments
 (0)