-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy path38-medulloblastoma_DELV.Rmd
185 lines (143 loc) · 5.14 KB
/
38-medulloblastoma_DELV.Rmd
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
---
title: "Identifying differentially expressed latent variables in
medulloblastoma"
output:
html_notebook:
toc: true
toc_float: true
---
**J. Taroni 2018**
Here, we're testing for latent variable differential expression between
medulloblastoma subgroups (Group 3, Group 4, and SHH).
As in `37-medulloblastoma_recount2_model`, where we prepped the data we are
analyzing here, this is using
[Northcott, et al.](https://dx.doi.org/10.1038/nature11327) and
[Robinson, et al.](https://dx.doi.org/10.1038/nature11213) data.
## Set up
```{r}
# pipe is required for LVTestWrapper
`%>%` <- dplyr::`%>%`
```
We have several custom functions that we've written and previously used in our
ANCA-associated vasculitis analyses.
They are general enough that we can use them again here.
```{r}
source(file.path("util", "test_LV_differences.R"))
```
#### Directories
```{r}
# directories specific to this notebook
plot.dir <- file.path("plots", "38")
dir.create(plot.dir, recursive = TRUE, showWarnings = FALSE)
results.dir <- file.path("results", "38")
dir.create(results.dir, recursive = TRUE, showWarnings = FALSE)
```
## Read in files
We need two things to do this analysis: a B matrix (latent variable values) and
a `data.frame` that contains the sample labels for the groups that we'd like
to test for differences between.
### GSE37382 (Northcott, et al.)
```{r}
northcott.b.file <- file.path("results", "37", "GSE37382_recount2_B.RDS")
northcott.sample.file <- file.path("data", "sample_info",
"GSE37382_cleaned_metadata.tsv")
```
Read in `B` (MultiPLIER)
```{r}
northcott.b.matrix <- readRDS(northcott.b.file)
```
Read in the `data.frame` with the subgroup information and check that the
sample names match between these two files.
```{r}
northcott.sample.df <- readr::read_tsv(northcott.sample.file)
all(northcott.sample.df$source_name %in% colnames(northcott.b.matrix))
```
`LVTestWrapper` requires that the sample names/identifiers are in a column named
`Sample`, so we'll change `source_name` to `Sample`.
```{r}
colnames(northcott.sample.df)[1] <- "Sample"
```
### GSE37418 (Robinson, et al.)
We'll repeat that process for the Robinson, et al. data
```{r}
robinson.b.file <- file.path("results", "37", "GSE37418_recount2_B.RDS")
robinson.sample.file <- file.path("data", "sample_info",
"metadata_GSE37418.tsv")
```
```{r}
robinson.b.matrix <- readRDS(robinson.b.file)
robinson.sample.df <- readr::read_tsv(robinson.sample.file)
```
The subgroup information in this data set is a bit different, let's look at
the counts
```{r}
robinson.sample.df %>%
dplyr::group_by(subgroup) %>%
dplyr::tally()
```
To do differential expression analysis, we'll remove the `SHH OUTLIER` and
`U` samples
```{r}
sample.index <- which(robinson.sample.df$subgroup %in% c("U",
"SHH OUTLIER"))
samples.to.remove <- robinson.sample.df$refinebio_accession_code[sample.index]
samples.to.remove
```
```{r}
remove.column.index <- which(colnames(robinson.b.matrix) %in% samples.to.remove)
```
Do the filtering
```{r}
robinson.b.matrix <- robinson.b.matrix[, -remove.column.index]
robinson.sample.df <- robinson.sample.df %>%
dplyr::filter(!(refinebio_accession_code %in% samples.to.remove)) %>%
dplyr::select(c("refinebio_accession_code", "subgroup", "Sex", "age",
"title"))
```
```{r}
all(robinson.sample.df$refinebio_accession_code %in%
colnames(robinson.b.matrix))
```
```{r}
colnames(robinson.sample.df)[1] <- "Sample"
```
## Test for differential expression
`LVTestWrapper` gives us 3 things: 1) differential expression results from
`limma`, 2) boxplot + jitter plots of the latent variable expression and 3)
the `B` matrix in "long" format -- this is what is used for plotting.
We'll use `"BH"` correction for multiple hypotheses testing (the default).
```{r}
northcott.results <-
LVTestWrapper(b.matrix = northcott.b.matrix,
sample.info.df = northcott.sample.df,
phenotype.col = "subgroup",
# the boxplot output, the "long" format B data.frame (useful for
# plotting), and the limma differential expression results
# will be output in files that begin with this string
file.lead = "GSE37382_subgroup_recount2_model",
plot.dir = plot.dir,
results.dir = results.dir)
```
```{r}
robinson.results <-
LVTestWrapper(b.matrix = robinson.b.matrix,
sample.info.df = robinson.sample.df,
phenotype.col = "subgroup",
file.lead = "GSE37418_subgroup_recount2_model",
plot.dir = plot.dir,
results.dir = results.dir)
```
### Any overlap at all?
```{r}
northcott.delvs <-
northcott.results$limma$LV[which(northcott.results$limma$adj.P.Val < 0.05)]
```
```{r}
robinson.delvs <-
robinson.results$limma$LV[which(robinson.results$limma$adj.P.Val < 0.05)]
```
```{r}
VennDiagram::venn.diagram(list(Robinson = robinson.delvs,
Northcott = northcott.delvs),
file.path(plot.dir, "Medulloblastoma_DELV_Venn.tiff"))
```