-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFeature-selections.Rmd
372 lines (314 loc) · 13.3 KB
/
Feature-selections.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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
# **Signature Score and Relevant phenotypes**
## Loading packages
Load the IOBR package in your R session after the installation is complete:
```{r, eval=TRUE, warning=FALSE, message=FALSE}
library(IOBR)
library(survminer)
library(tidyverse)
```
## Downloading data for example
Obtaining data set from GEO [Gastric cancer: GSE62254](https://pubmed.ncbi.nlm.nih.gov/25894828/) using `GEOquery` R package.
```{r,message=FALSE,warning=FALSE}
if (!requireNamespace("GEOquery", quietly = TRUE)) BiocManager::install("GEOquery")
library("GEOquery")
# NOTE: This process may take a few minutes which depends on the internet connection speed. Please wait for its completion.
eset_geo <- getGEO(GEO = "GSE62254", getGPL = F, destdir = "./")
eset <- eset_geo[[1]]
eset <- exprs(eset)
eset[1:5,1:5]
```
## Gene Annotation
Annotation of genes in the expression matrix and removal of duplicate genes.
```{r,message=FALSE,warning=FALSE}
# Load the annotation file `anno_hug133plus2` in IOBR.
head(anno_hug133plus2)
# Conduct gene annotation using `anno_hug133plus2` file; If identical gene symbols exists, these genes would be ordered by the mean expression levels. The gene symbol with highest mean expression level is selected and remove others.
eset<-anno_eset(eset = eset,
annotation = anno_hug133plus2,
symbol = "symbol",
probe = "probe_id",
method = "mean")
eset[1:5, 1:3]
```
## Estimation of signatures
```{r, message = F, warning = F}
sig_tme<-calculate_sig_score(pdata = NULL,
eset = eset,
signature = signature_collection,
method = "pca",
mini_gene_count = 2)
sig_tme <- t(column_to_rownames(sig_tme, var = "ID"))
sig_tme[1:5, 1:3]
```
## Combining score data and phenotype data
```{r, message = F, warning = F, fig.width= 7, fig.height=7.5, fig.align='center'}
data("pdata_acrg", package = "IOBR")
head(pdata_acrg)
input <- combine_pd_eset(eset = sig_tme, pdata = pdata_acrg, scale = T)
```
## Identifying features associated with survival
```{r, message = F, warning = F, fig.width= 7, fig.height=7.5, fig.align='center'}
res<- batch_surv(pdata = input,
time = "OS_time",
status = "OS_status",
variable = colnames(input)[69:ncol(input)])
head(res)
```
Use forest plots `sig_forest` to show the most relevant variables to overall survival
```{r, message = F, warning = F, fig.width= 7, fig.height=7.5, fig.align='center'}
res<- res[nchar(res$ID)<=28, ]
p1<- sig_forest(res, signature = "ID", n = 20)
```
## Visulization using heatmap
Relationship between Signatures and molecular typing.
Heatmap visualisation using `IOBR`'s `sig_heatmap`
```{r, message=FALSE, fig.width= 9, fig.height = 6, fig.align='center'}
p2 <- sig_heatmap(input = input,
features = res$ID[1:20],
group = "Subtype",
palette_group = "jama",
palette = 6,
path = "result" )
```
## Focus on target signatures
```{r, fig.show= 'hide', fig.width= 12, fig.height=8.5, message = F, warning = F}
p1 <- sig_box(data = input,
signature = "Glycogen_Biosynthesis",
variable = "Subtype",
jitter = FALSE,
cols = NULL,
palette = "jama",
show_pvalue = TRUE,
size_of_pvalue = 5,
hjust = 1,
angle_x_text = 60,
size_of_font = 8)
p2 <- sig_box(data = input,
signature = "Pan_F_TBRs",
variable = "Subtype",
jitter = FALSE,
cols = NULL,
palette = "jama",
show_pvalue = TRUE,
angle_x_text = 60,
hjust = 1,
size_of_pvalue = 5,
size_of_font = 8)
p3 <- sig_box(data = input,
signature = "Immune_Checkpoint",
variable = "Subtype",
jitter = FALSE,
cols = NULL,
palette = "jama",
show_pvalue = TRUE,
angle_x_text = 60,
hjust = 1,
size_of_pvalue = 5,
size_of_font = 8)
```
```{r, message = F, warning = F, fig.width= 10, fig.height=6, fig.align='center'}
p1|p2|p3
```
## Survival analysis and visulization
### Kaplan-Meier plot
Displaying the outcomes of survival analyses using Kaplan-Meier plot. Multiple stratifications of the signature were used to judge the efficacy of this metric in predicting patient survival.
```{r, message = F, warning = F, fig.width= 16, fig.height=8}
res <- sig_surv_plot(input_pdata = input,
signature = "Glycogen_Biosynthesis",
cols = NULL,
palette = "jama",
project = "ACRG",
time = "OS_time",
status = "OS_status",
time_type = "month",
save_path = "result")
res$plots
```
### Time-Dependent ROC curve
```{r, message = F, warning = F, fig.width= 14, fig.height=6.5}
p1<- roc_time(input = input,
vars = "Glycogen_Biosynthesis",
time = "OS_time",
status = "OS_status",
time_point = c(12, 24, 36),
time_type = "month",
palette = "jama",
cols = "normal",
seed = 1234,
show_col = FALSE,
path = "result",
main = "OS",
index = 1,
fig.type = "pdf",
width = 5,
height = 5.2)
p2<- roc_time(input = input,
vars = "Glycogen_Biosynthesis",
time = "RFS_time",
status = "RFS_status",
time_point = c(12, 24, 36),
time_type = "month",
palette = "jama",
cols = "normal",
seed = 1234,
show_col = FALSE,
path = "result",
main = "OS",
index = 1,
fig.type = "pdf",
width = 5,
height = 5.2)
p1|p2
```
## Batch correlation analysis
### Finding continuity variables associated with signatures
Identifying genes or signatures related to the target signatures
#### Correlation between two variables
```{r}
res <- batch_cor(data = input, target = "Glycogen_Biosynthesis", feature = colnames(input)[69:ncol(input)])
head(res)
```
```{r, fig.show= 'hide', fig.width= 12, fig.height=9, message = F, warning = F}
p1<- get_cor(eset = sig_tme, pdata = pdata_acrg, is.matrix = TRUE, var1 = "Glycogen_Biosynthesis",
var2 = "TMEscore_CIR", subtype = "Subtype", palette = "aaas", path = "result")
p2<- get_cor(eset = sig_tme, pdata = pdata_acrg, is.matrix = TRUE, var1 = "Glycogen_Biosynthesis",
var2 = "TGFβ_myCAF", subtype = "Subtype", palette = "aaas", path = "result")
```
```{r, fig.width= 12, fig.height=6, message = F, warning = F}
p1|p2
```
#### Demonstrate correlation between multiple variables
Visualisation via correlation matrix
```{r, fig.width= 10, fig.height=4, message = F, warning = F}
feas1 <- c("Glycogen_Biosynthesis", "Ferroptosis")
feas2 <- c("Glutathione_Metabolism", "TMEscore_CIR", "Purine_Metabolism", "ICB_resistance_Peng_et_al", "Interleukins_Li_et_al", "TLS_Nature")
p <- get_cor_matrix(data = input,
feas1 = feas2,
feas2 = feas1,
method = "pearson",
font.size.star = 8,
font.size = 15,
fill_by_cor = FALSE,
round.num = 1,
path = "result")
```
Demonstrate the correlation between signatures and genes
```{r, fig.width= 11, fig.height=4, message = F, warning = F}
input2 <- combine_pd_eset(eset = eset, pdata = input[, c("ID", "Glycogen_Biosynthesis", "TLS_Nature", "Ferroptosis")])
feas1 <- c("Glycogen_Biosynthesis","TLS_Nature", "Ferroptosis")
feas2 <- signature_collection$CD_8_T_effector
feas2
p <- get_cor_matrix(data = input2,
feas1 = feas2,
feas2 = feas1,
method = "pearson",
scale = T,
font.size.star = 8,
font.size = 15,
fill_by_cor = FALSE,
round.num = 1,
path = "result")
```
Users can customize the image using parameters.
```{r, fig.width= 11, fig.height=4, message = F, warning = F}
p <- get_cor_matrix(data = input2,
feas1 = feas2,
feas2 = feas1,
method = "pearson",
scale = T,
font.size.star = 8,
font.size = 15,
fill_by_cor = TRUE,
round.num = 2,
path = "result")
```
### Identifying Category Variables Linked to Signatures
#### For binary variable
```{r, fig.width= 11, fig.height=4, message = F, warning = F}
res <- batch_wilcoxon(data = input, target = "TMEscore_binary", feature = colnames(input)[69:ncol(input)])
head(res)
```
```{r, fig.show= 'hide', fig.width= 12, fig.height=8.5, message = F, warning = F}
p1 <- sig_box(data = input,
signature = res$sig_names[1],
variable = "TMEscore_binary",
jitter = FALSE,
cols = NULL,
palette = "jco",
show_pvalue = TRUE,
size_of_pvalue = 5,
hjust = 1,
angle_x_text = 60,
size_of_font = 8)
p2 <- sig_box(data = input,
signature = res$sig_names[2],
variable = "TMEscore_binary",
jitter = FALSE,
cols = NULL,
palette = "jco",
show_pvalue = TRUE,
angle_x_text = 60,
hjust = 1,
size_of_pvalue = 5,
size_of_font = 8)
p3 <- sig_box(data = input,
signature = res$sig_names[3],
variable = "TMEscore_binary",
jitter = FALSE,
cols = NULL,
palette = "jco",
show_pvalue = TRUE,
angle_x_text = 60,
hjust = 1,
size_of_pvalue = 5,
size_of_font = 8)
```
```{r, message = F, warning = F, fig.width= 9, fig.height=5, fig.align='center'}
p1|p2|p3
```
### For multicategorical variables (>2 subgroups)
```{r, fig.width= 11, fig.height=4, message = F, warning = F}
res <- batch_kruskal(data = input, group = "Subtype", feature = colnames(input)[69:ncol(input)])
head(res)
```
```{r, fig.show= 'hide', fig.width= 12, fig.height=8.5, message = F, warning = F}
p1 <- sig_box(data = input,
signature = res$sig_names[1],
variable = "Subtype",
jitter = FALSE,
cols = NULL,
palette = "jco",
show_pvalue = TRUE,
size_of_pvalue = 5,
hjust = 1,
angle_x_text = 60,
size_of_font = 8)
p2 <- sig_box(data = input,
signature = res$sig_names[2],
variable = "Subtype",
jitter = FALSE,
cols = NULL,
palette = "jco",
show_pvalue = TRUE,
angle_x_text = 60,
hjust = 1,
size_of_pvalue = 5,
size_of_font = 8)
p3 <- sig_box(data = input,
signature = res$sig_names[3],
variable = "Subtype",
jitter = FALSE,
cols = NULL,
palette = "jco",
show_pvalue = TRUE,
angle_x_text = 60,
hjust = 1,
size_of_pvalue = 5,
size_of_font = 8)
```
```{r, message = F, warning = F, fig.width= 10, fig.height=6, fig.align='center'}
p1|p2|p3
```
## Reference
Cristescu, R., Lee, J., Nebozhyn, M. et al. Molecular analysis of gastric cancer identifies subtypes associated with distinct clinical outcomes. Nat Med 21, 449–456 (2015). https://doi.org/10.1038/nm.3850
Dongqiang Zeng, ..., WJ Liao et al., Tumor Microenvironment Characterization in Gastric Cancer Identifies Prognostic and Immunotherapeutically Relevant Gene Signatures, Cancer Immunol Res (2019) 7 (5): 737–750. https://doi.org/10.1158/2326-6066.CIR-18-0436