Skip to content

Commit 13ca58c

Browse files
author
JSRM
committed
fixed notebook bugs
1 parent 4946786 commit 13ca58c

5 files changed

Lines changed: 20 additions & 19 deletions

File tree

Notebooks/07b_hypothesis_testing.Rmd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ dds <- estimateSizeFactors(dds)
5757
dds <- estimateDispersions(dds)
5858
```
5959

60-
Approximate time: 400 minutes
60+
Approximate time: 40 minutes
6161

6262
## Learning Objectives
6363

@@ -175,7 +175,7 @@ Define contrasts for Control vs Vampirium samples using one of the two methods a
175175
**Your code here**
176176

177177
```{r}
178-
contrast_cont <-
178+
contrast_cont <-
179179
```
180180

181181
***

Notebooks/07c_DEA_visualization.Rmd

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,9 @@ We will be working with three different data objects we have already created in
147147

148148
- Metadata for our samples (a dataframe): `meta`
149149
- Normalized expression data for every gene in each of our samples (a matrix): `normalized_counts`
150-
- Tibble versions of the DESeq2 results we generated in the last lesson: `res_tableCont_tb` and `res_tableKD_tb`
150+
- Tibble versions of the DESeq2 results we generated in the last lesson: `res_tableCont_tb` and `res_tableGar_tb`
151151

152152
First, we already have a metadata tibble.
153-
154153
```{r}
155154
meta %>% head()
156155
```

Notebooks/08a_FA_genomic_annotation.Rmd

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,10 @@ To get started with AnnotationHub, we first load the library and connect to the
121121

122122
**The script will ask you to create a cache directory, type yes! **
123123
```{r}
124-
# Load libraries
124+
# We have a tiny problem here with one of our packages, so we need to install this specific version first
125+
install.packages("devtools")
126+
devtools::install_version("dbplyr", version = "2.3.4")
127+
125128
library(AnnotationHub)
126129
library(ensembldb)
127130

Notebooks/08c_FA_GSEA.Rmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ knitr::opts_chunk$set(autodep = TRUE,
3333
eval = TRUE)
3434
```
3535

36-
```{r setup, include = FALSE, echo = FALSE}
36+
```{r, include = FALSE, echo = FALSE}
3737
# DO NOT RUN IF YOU HAVE ALREADY RUN PREVIOUS NOTEBOOKS
3838
# This chunk is ONLY necessary if you want to knit this document into a pdf!!
3939
library(tidyverse)

Notebooks/09_summarized_workflow.Rmd

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ We have detailed the various steps in a differential expression analysis workflo
6464
Load data and metadata
6565

6666
```{r}
67-
data <- read_table("../Data/Mov10_counts_traditional.txt")
67+
data <- read_table("../Data/Vampirium_counts_traditional.tsv")
6868
6969
meta <- read_csv("../Data/samplesheet.csv")
7070
```
@@ -73,14 +73,14 @@ Check that the row names of the metadata equal the column names of the **raw cou
7373

7474
```{r}
7575
### Check that sample names match in both files
76-
all(colnames(data)[-1] %in% meta$sample)
77-
all(colnames(data)[-1] == meta$sample)
76+
all(colnames(data)[-c(1,2)] %in% meta$sample)
77+
all(colnames(data)[-c(1,2)] == meta$sample)
7878
```
7979

8080
Reorder meta rows so it matches count data colnames
8181

8282
```{r}
83-
reorder <- match(colnames(data)[-1],meta$sample)
83+
reorder <- match(colnames(data)[-c(1,2)],meta$sample)
8484
reorder
8585
8686
meta <- meta[reorder,]
@@ -89,7 +89,7 @@ meta <- meta[reorder,]
8989
Create DESeq2Dataset object
9090

9191
```{r}
92-
dds <- DESeqDataSetFromMatrix(countData = data %>% column_to_rownames("GeneSymbol"),
92+
dds <- DESeqDataSetFromMatrix(countData = data %>% select(-gene_name) %>% column_to_rownames("gene_id") %>% mutate_all(as.integer),
9393
colData = meta %>% column_to_rownames("sample"),
9494
design = ~ condition)
9595
```
@@ -164,7 +164,7 @@ Extract the rlog matrix from the object
164164

165165
```{r}
166166
rld_mat <- assay(rld)
167-
rld_cor <- cor(rld_mat) # Pearson correlation betweeen samples
167+
rld_cor <- cor(rld_mat) # Pearson correlation between samples
168168
rld_dist <- as.matrix(dist(t(assay(rld)))) #distances are computed by rows, so we need to transponse the matrix
169169
```
170170

@@ -221,7 +221,7 @@ Formal LFC calculation
221221

222222
```{r}
223223
# Specify contrast for comparison of interest
224-
contrast <- c("condition", "MOV10_overexpression", "control")
224+
contrast <- c("condition", "control", "vampirium")
225225
226226
# Output results of Wald test for contrast
227227
res <- results(dds,
@@ -237,7 +237,7 @@ resultsNames(dds)
237237
238238
# Shrink the log2 fold changes to be more accurate
239239
res <- lfcShrink(dds,
240-
coef = "condition_MOV10_overexpression_vs_control",
240+
coef = "condition_vampirium_vs_control",
241241
type = "apeglm")
242242
```
243243

@@ -269,13 +269,13 @@ lookup <- function(gene_name, tx2gene, dds){
269269
return(hits)
270270
}
271271
272-
lookup(gene_name = "MOV10", tx2gene = tx2gene, dds = dds)
272+
lookup(gene_name = "TSPAN7", tx2gene = tx2gene, dds = dds)
273273
```
274274

275275
Plot expression for single gene
276276

277277
```{r counts_plot}
278-
plotCounts(dds, gene="ENSG00000155363", intgroup="condition")
278+
plotCounts(dds, gene="ENSG00000156298", intgroup="condition")
279279
```
280280

281281
Function to annotate all your gene results
@@ -285,7 +285,6 @@ res_tbl <- merge(res_tbl, tx2gene %>% select(-transcript_ID) %>% distinct(),
285285
by.x = "gene", by.y = "gene_ID", all.x = T)
286286
287287
res_tbl
288-
289288
```
290289

291290
### MAplot
@@ -319,7 +318,7 @@ head(res_tbl)
319318
ggplot(res_tbl, aes(x = log2FoldChange, y = -log10(padj))) +
320319
geom_point(aes(colour = threshold)) +
321320
geom_text_repel(aes(label = genelabels)) +
322-
ggtitle("Mov10 overexpression") +
321+
ggtitle("Vampirium vs Control") +
323322
xlab("log2 fold change") +
324323
ylab("-log10 adjusted p-value") +
325324
theme(legend.position = "none",
@@ -350,7 +349,7 @@ pheatmap(norm_sig,
350349
### Annotate with `annotables`
351350

352351
```{r}
353-
ids <- grch37 %>% dplyr::filter(ensgene %in% res_tbl$gene)
352+
ids <- grch38 %>% dplyr::filter(ensgene %in% res_tbl$gene)
354353
res_ids <- inner_join(res_tbl, ids, by=c("gene"="ensgene"))
355354
```
356355

0 commit comments

Comments
 (0)