Skip to content

Commit

Permalink
Update solutions to session 3
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Dunning authored and Mark Dunning committed Dec 6, 2024
1 parent b1d0c4d commit 33e15f8
Show file tree
Hide file tree
Showing 2 changed files with 223 additions and 111 deletions.
38 changes: 15 additions & 23 deletions session3_solutions.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ results_tgf %>%

The tricky part of making a heatmap is deciding which genes to include. The gene names have to be in ENSEMBL format, as the count matrix we will be plotting has ENSEMBL names in the rows.

In the following example, we chose the genes with most extreme log2 fold-change

```{r}
# The pheatmap library is needed to make the heatmap
Expand All @@ -64,42 +66,32 @@ library(pheatmap)
vsd <- vst(dds)
sampleInfo <- as.data.frame(colData(dds)[,c("condition","Treated")])
# create a new table that includes gene variability
res_with_var <- mutate(results_tgf, GeneVar = rowSds(assay(vsd))) %>%
filter(!is.na(padj))
# arrange by the new column and extract ENSEMBL ID of the first 100 rows
## Order results by log2FoldChange and get the most extreme
genes_to_plot <- arrange(res_with_var, desc(GeneVar)) %>%
dplyr::slice(1:100) %>%
top_genes_logFC <- results_tgf %>%
arrange(desc(abs(log2FoldChange))) %>%
slice(1:30) %>%
pull(ENSEMBL)
top_genes_logFC_labels <- results_tgf %>%
arrange(desc(abs(log2FoldChange))) %>%
slice(1:30) %>%
pull(SYMBOL)
```
## get the corresponding geen symbols
```{r fig.width=12}
pheatmap(assay(vsd)[top_genes_logFC,],
scale = "row",
labels_row = top_genes_logFC_labels)
pheatmap(assay(vsd)[genes_to_plot,],
annotation_col = sampleInfo,
scale="row")
```

```{r fig.width=12}
gene_labels <- arrange(res_with_var, desc(GeneVar)) %>%
dplyr::slice(1:100) %>%
pull(SYMBOL)

pheatmap(assay(vsd)[genes_to_plot,],
annotation_col = sampleInfo,
labels_row = gene_labels,
scale="row")

```


# Exercise: Pathways

**Need to fix, as currently this doesn't return anything!**

In order to use the `enrichKEGG` function, we will have to define a set of enriched genes in terms of their `ENTREZID` (instead of `ENSEMBL`)

Expand Down
Loading

0 comments on commit 33e15f8

Please sign in to comment.