-
Notifications
You must be signed in to change notification settings - Fork 0
/
tme-deg-gsea.Rmd
244 lines (192 loc) · 9.07 KB
/
tme-deg-gsea.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
# **Tumor ecosystem analysis**
## Loading packages
```{r, eval=TRUE, warning=FALSE, message=FALSE}
library(IOBR)
```
## 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: HGU133PLUS-2 (Affaymetrix)
```{r,message=FALSE,warning=FALSE}
# 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]
```
## Determine TME subtype of gastric cancer using [TMEclassifier R package](https://github.com/LiaoWJLab/TMEclassifier)
```{r, message=FALSE, warning=FALSE}
if (!requireNamespace("TMEclassifier", quietly = TRUE)) devtools::install_github("LiaoWJLab/TMEclassifier")
library(TMEclassifier)
tme <- tme_classifier(eset = eset, scale = TRUE)
table(tme$TMEcluster)
head(tme)
```
```{r}
table(tme$TMEcluster)
head(tme)
```
## DEG analysis: method1
Differential analysis of selected immune-activated and immune-expelled gastric cancers
```{r}
pdata <- tme[!tme$TMEcluster=="IS", ]
deg <- iobr_deg(eset = eset,
annotation = NULL,
pdata = pdata,
group_id = "TMEcluster",
pdata_id = "ID",
array = TRUE,
method = "limma",
contrast = c("IA","IE"),
path = "result",
padj_cutoff = 0.01,
logfc_cutoff = 0.5)
```
## GSEA analysis based on differential express gene analysis results
Select the gene set list in IOBR's signature collection.
```{r}
head(deg)
sig_list <- signature_collection[c("TMEscoreB_CIR", "TMEscoreA_CIR", "DNA_replication", "Base_excision_repair",
"Pan_F_TBRs", "TGFb.myCAF", "Ferroptosis", "TLS_Nature", "Glycolysis")]
sig_list
```
```{r, eval=FALSE}
gsea<- sig_gsea(deg,
genesets = sig_list,
path = "result",
gene_symbol = "symbol",
logfc = "log2FoldChange",
org = "hsa",
show_plot = FALSE,
msigdb = TRUE,
category = "H",
subcategory = NULL,
palette_bar = "set2")
```
```{r echo=FALSE, fig.cap='GSEA of TME gent sets', out.width='95%', fig.asp=.85, fig.align='center'}
knitr::include_graphics(rep("./fig/gsea-1.png", 1))
```
Hallmark gene signatures
```{r, eval=FALSE}
gsea<- sig_gsea(deg,
genesets = NULL,
path = "GSEA",
gene_symbol = "symbol",
logfc = "log2FoldChange",
org = "hsa",
show_plot = FALSE,
msigdb = TRUE,
category = "H",
subcategory = NULL,
palette_bar = "aaas",
show_bar = 5,
show_gsea = 6)
```
```{r echo=FALSE, fig.cap='GSEA of Hallmark gent sets', out.width='95%', fig.asp=.85, fig.align='center'}
knitr::include_graphics(rep("./fig/gsea-2.png", 1))
```
## DEG analysis: method2
Identifing TME subtype-related differential genes using `find_markers_in_bulk`
```{r, message = F, warning = F}
library(Seurat)
res <- find_markers_in_bulk(pdata = tme,
eset = eset,
group = "TMEcluster",
nfeatures = 2000,
top_n = 50,
thresh.use = 0.15,
only.pos = TRUE,
min.pct = 0.10)
top15 <- res$top_markers %>% dplyr:: group_by(cluster) %>% dplyr::top_n(15, avg_log2FC)
top15$gene
```
Heatmap visualisation using `Seurat`'s `DoHeatmap`
```{r,fig.show= 'hide',message=FALSE}
#定义分型对应的颜色
cols <- c('#2692a4','#fc0d3a','#ffbe0b')
p1 <- DoHeatmap(res$sce, top15$gene, group.colors = cols )+
scale_fill_gradientn(colours = rev(colorRampPalette(RColorBrewer::brewer.pal(11,"RdBu"))(256)))
```
Extracting variables from the expression matrix to merge with TME subtypes
```{r,fig.show= 'hide',message=FALSE}
input <- combine_pd_eset(eset = eset, pdata = tme, feas = top15$gene, scale = T)
p2 <- sig_box(input, variable = "TMEcluster", signature = "IFNG", jitter = TRUE,
cols = cols, show_pvalue = TRUE, size_of_pvalue = 4)
p3 <- sig_box(input, variable = "TMEcluster", signature = "IL1A",
jitter = TRUE, cols = cols, show_pvalue = TRUE, size_of_pvalue = 4)
```
```{r, fig.width= 12, fig.height=9, message = F, warning = F}
if (!requireNamespace("patchwork", quietly = TRUE)) install.packages("patchwork")
library(patchwork)
p <- (p1|p2/p3) + plot_layout(widths = c(2.3,1))
p + plot_annotation(tag_levels = 'A')
```
## Identifying signatures associated with TME clusters
Calculate TME associated signatures-(through PCA method).
```{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]
```
Finding signatures or cell types associated with TMEcluster
```{r, message = F, warning = F}
res <- find_markers_in_bulk(pdata = tme, eset = sig_tme, group = "TMEcluster", nfeatures = 1000, top_n = 20, min.pct = 0.10)
top15 <- res$top_markers %>% dplyr:: group_by(cluster) %>% dplyr::top_n(15, avg_log2FC)
p1 <- DoHeatmap(res$sce, top15$gene, group.colors = cols)+
scale_fill_gradientn(colours = rev(colorRampPalette(RColorBrewer::brewer.pal(11,"RdBu"))(256)))
```
```{r,fig.show= 'hide', message=FALSE}
top15$gene <- gsub(top15$gene, pattern = "-", replacement = "\\_")
input <- combine_pd_eset(eset = sig_tme, pdata = tme, feas = top15$gene, scale = T)
p2 <- sig_box(input, variable = "TMEcluster", signature = "CD_8_T_effector", jitter = TRUE,
cols = cols, show_pvalue = TRUE, size_of_pvalue = 4, size_of_font = 6)
p3 <- sig_box(input, variable = "TMEcluster", signature = "Neutrophils_Bindea_et_al",
jitter = TRUE, cols = cols, show_pvalue = TRUE, size_of_pvalue = 4, size_of_font = 6)
```
```{r, fig.width= 12, fig.height=9}
p <- (p1|p2/p3) + plot_layout(widths = c(2.3,1))
p + plot_annotation(tag_levels = 'A')
```
```{r, fig.width= 5, fig.height=8}
library(survminer)
data(pdata_acrg, package = "IOBR")
input <- merge(pdata_acrg, input, by = "ID")
p1<-surv_group(input_pdata = input,
target_group = "TMEcluster",
ID = "ID",
reference_group = "High",
project = "ACRG",
cols = cols,
time = "OS_time",
status = "OS_status",
time_type = "month",
save_path = "result")
p1
```
```{r,fig.show= 'hide',message=FALSE}
p1<- percent_bar_plot(input, x = "TMEcluster" , y = "Subtype", palette = "jama")
p2<- percent_bar_plot(input, x = "TMEcluster" , y = "Lauren", palette = "jama")
p3<- percent_bar_plot(input, x = "TMEcluster" , y = "TMEscore_binary", palette = "jama")
```
```{r,fig.width= 12, fig.height=8}
p1|p2|p3
```
## References
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
[CIBERSORT](https://cibersort.stanford.edu/); Newman, A. M., Liu, C. L., Green, M. R., Gentles, A. J., Feng, W., Xu, Y., … Alizadeh, A. A. (2015). Robust enumeration of cell subsets from tissue expression profiles. Nature Methods, 12(5), 453–457. https://doi.org/10.1038/nmeth.3337;
Seurat: Hao and Hao et al. Integrated analysis of multimodal single-cell data. Cell (2021)
Zeng D, Yu Y, Qiu W, Mao Q, …, Zhang K, Liao W; Tumor microenvironment immunotyping heterogeneity reveals distinct molecular mechanisms to clinical immunotherapy applications in gastric cancer. (2024) Under Review.