Diff of /figures/Figure6.Rmd [000000] .. [9905a0]

Switch to unified view

a b/figures/Figure6.Rmd
1
---
2
title: "Figure 6"
3
author: Tobias Roider
4
date: "Last compiled on `r format(Sys.time(), '%d %B, %Y, %X')`"
5
output: 
6
  rmdformats::readthedown: 
7
  
8
editor_options: 
9
  chunk_output_type: console
10
---
11
12
```{r options, include=FALSE, warning = FALSE}
13
14
library(knitr)
15
opts_chunk$set(echo=TRUE, tidy=FALSE, include=TRUE, message=FALSE,
16
               dpi = 100, cache = FALSE, warning = FALSE)
17
opts_knit$set(root.dir = "../")
18
options(bitmapType = "cairo")
19
20
```
21
22
# Read data, functions and packages
23
```{r read data}
24
25
source("R/ReadPackages.R")
26
source("R/Functions.R")
27
source("R/ReadData.R")
28
source("R/ThemesColors.R")
29
source("R/Helpers.R")
30
31
```
32
33
# Part 1
34
## Frequencies
35
```{r frequencies treg}
36
 
37
df_freq_treg <- df_comb %>% 
38
  add_prop(vars = c("PatientID", "Entity", "IdentI"), group.vars = 1) %>% 
39
  fill_zeros(values_from = "Prop", names_from = "IdentI") %>% 
40
  filter(IdentI %in% c(6,11))
41
42
pvalues <- df_freq_treg %>% 
43
  group_by(IdentI) %>% 
44
  wilcox_test(data=., formula =  Prop ~ Entity, comparisons = list(c("FL", "rLN"), c("MZL", "rLN"))) %>% 
45
  select(IdentI, Entity=group1, p) %>% 
46
  mutate(p_s=format(p, scientific = TRUE, digits=1)) %>% 
47
  mutate(p_f=case_when(p > 0.05 ~ "NA",
48
                           p==0.05 ~ "0.05",
49
                           p < 0.05 & p > 0.001 ~ as.character(round(p, 3)),
50
                           p==0.001 ~ "0.001",
51
                           p < 0.001 ~ p_s)) 
52
53
p1 <- 
54
  df_freq_treg %>% 
55
  filter(IdentI %in% c(6)) %>% 
56
  ggplot(aes(x=Entity, y=100*Prop))+
57
  geom_boxplot(width=0.5, outlier.alpha = 0, size=0.25)+
58
  ggbeeswarm::geom_beeswarm(size=0.75, shape=21, stroke=0.25, cex = 2.25, aes(fill=Entity))+
59
  geom_text(inherit.aes = F, data = pvalues %>% filter(IdentI==6) %>% mutate(Y=c(38,45)),
60
            aes(x=Entity, y=Y, label=p_f), size=2.5)+
61
  scale_fill_brewer(palette = "Paired", limits=c("DLBCL", "MCL", "FL", "MZL", "rLN"))+
62
  ggtitle(expression('T'[FH]))+
63
  scale_y_continuous(limits = c(0,60), name="% of total T-cells (CITE-seq)")+
64
  scale_x_discrete(limits=c("rLN", "DLBCL", "MCL", "FL", "MZL"))+
65
  mytheme_1+
66
  theme(legend.position = "none",
67
        strip.background = element_rect(color=NA),
68
        axis.title.x = element_blank(),
69
        panel.border = element_rect(size=0.5),
70
        plot.title = element_text(vjust = -1, color=colors_umap_cl[["6"]]),
71
        axis.text.x = element_text(angle=45, hjust = 1),
72
        panel.background = element_rect(fill=NA),
73
        plot.margin = unit(c(0,0.1,0,0.25), "cm"))+
74
  labs(tag = "A")
75
76
p2 <- 
77
  df_freq_treg %>% 
78
  filter(IdentI %in% c(11)) %>% 
79
  ggplot(aes(x=Entity, y=100*Prop))+
80
  geom_boxplot(width=0.5, outlier.alpha = 0, size=0.25)+
81
  ggbeeswarm::geom_beeswarm(size=0.75, shape=21, stroke=0.25, cex = 2.25, aes(fill=Entity))+
82
  geom_text(inherit.aes = F, data = pvalues %>% filter(IdentI==11) %>% mutate(Y=c(16,17.5)),
83
            aes(x=Entity, y=Y, label=p_f), size=2.5)+
84
  scale_fill_brewer(palette = "Paired", limits=c("DLBCL", "MCL", "FL", "MZL", "rLN"))+
85
  ggtitle(expression('T'[REG]~'EM'[2]))+
86
  scale_y_continuous(limits = c(0,18.25), name="% of total T-cells (CITE-seq)")+
87
  scale_x_discrete(limits=c("rLN", "DLBCL", "MCL", "FL", "MZL"))+
88
  mytheme_1+
89
  theme(strip.background = element_rect(color=NA),
90
        plot.title = element_text(vjust = -1, color=colors_umap_cl[["11"]]),
91
        axis.text.x = element_text(angle=45, hjust = 1),
92
        panel.border = element_rect(size=0.5),
93
        axis.title = element_blank(),
94
        panel.background = element_rect(fill=NA),
95
        plot.margin = unit(c(0,0.25,0,0.1), "cm"))
96
97
```
98
99
## Surface proteins
100
```{r surface proteins}
101
102
proteins_selected <- c("CD69"="CD69", 
103
                       "CD25"="CD25", 
104
                       "ICOS"="CD278", 
105
                       "CD134"="CD134", 
106
                       "CD161"="CD161", 
107
                       "CCR4"="CD194", 
108
                       "CCR5"="CD195", 
109
                       "CXCR3"="CD183", 
110
                       "CXCR5"="CD185", 
111
                       "PD1"="CD279", 
112
                       "CD38"="CD38", 
113
                       "CD39"="CD39", 
114
                       "TIGIT"="TIGIT")
115
116
p3 <- 
117
  left_join(percentageADT, meanADT) %>% 
118
  filter(IdentI %in% c(6, 8, 11, 15, 13), Epitope %in% proteins_selected) %>% 
119
  ggplot(aes(x=Epitope, y=IdentI, size=100*Prop, fill=Expression))+
120
  geom_point(shape=21, stroke=0.1, color="grey45")+ 
121
  scale_size_continuous(range=c(0, 4), name="% pos. cells", limits=c(0, 100))+
122
  scale_fill_gradientn(name="Expression", colours = brewer.pal(5, "BuGn"), limits=c(0,1))+
123
  scale_y_discrete(limits=rev(as.character(c(6, 8, 13, 15, 11))), 
124
                   labels=parse(text=rev(labels_cl_parsed[5:9]))
125
                   )+
126
  scale_x_discrete(limits=unname(proteins_selected), labels=names(proteins_selected))+
127
  ggtitle("Protein level")+
128
  coord_cartesian(clip = "off")+
129
  theme_bw()+
130
  theme(axis.title = element_blank(),
131
        legend.position = "right",
132
        axis.text.x = element_text(angle = 45, hjust = 1),
133
        axis.text.y = element_blank(),
134
        axis.text = element_text(size=7),
135
        axis.ticks.y = element_blank(),
136
        legend.text = element_text(size = 7, color="black"),
137
        legend.title = element_text(size = 7, color="black", vjust = 0.5),
138
        legend.box.margin=margin(-10,-10,-8,-8),
139
        legend.key.height = unit(0.3, "cm"),
140
        legend.key.width = unit(0.3, "cm"),
141
        panel.border = element_rect(size=0.25),
142
        plot.margin = unit(c(0,0.5,0,0.5), "cm"),
143
        plot.tag = element_text(margin =  unit(c(0,1,0,0), "cm")),
144
        plot.title = element_text(size = 7, color="black", vjust = -1, hjust = 0.5, face = "bold"),
145
        panel.grid = element_blank())+
146
  labs(tag = "B")
147
148
for(i in 5:9) {
149
  
150
  p3 <- p3+
151
    annotation_custom(grob = rectGrob(gp = gpar(fill=colors_umap_cl[as.character(cluster_order)[i]], col="white")), 
152
                    ymin = rev(c(seq(0.5, 4.5, 1)+0.25))[i-4], 
153
                    ymax = rev(c(seq(1.5, 5.5, 1)-0.25))[i-4],
154
                    xmin = 0, xmax = -0.75)+
155
    annotation_custom(grob = textGrob(label = labels_cl[[i]], rot = 0, hjust = 1, gp = gpar(cex=0.6)), 
156
                      ymin = rev(c(seq(0.5, 4.5, 1)+0.25))[i-4], 
157
                      ymax = rev(c(seq(1.5, 5.5, 1)-0.25))[i-4],
158
                    xmin = -1, xmax = -1)
159
}
160
161
162
```
163
164
## Assemble plot
165
```{r assemble plot I, fig.height=2.5}
166
167
p1+p2+p3+plot_layout(widths = c(1,1,1.45))
168
ggsave(width = 18.5, height = 5.8, units = "cm", filename = "Figure6_p1.pdf")
169
170
```
171
172
# Part 2
173
## Differentially expressed genes
174
```{r differentially expressed genes}
175
176
height.label <- 0.94
177
position.label <- 1.1
178
Idents(Combined_T) <- "IdentI"
179
180
df_markers1115 <- FindMarkers(Combined_T, ident.1 = 11, ident.2 = c(15), test.use = "roc", assay = "integratedRNA") %>% 
181
  rownames_to_column("Feature") %>% mutate(Assay="Gene")
182
183
labels <- c("KLF2", "IKZF3", "IL21", "ASCL2", "IKZF2", "FOXP3", "CXCL13")
184
185
df_tmp <- df_markers1115 %>% mutate(Label=ifelse(Feature %in% labels, Feature, NA)) %>% 
186
  mutate(Label=gsub(Label, pattern = ".", fixed = T, replacement = ""))
187
188
df_tmp1 <- df_tmp %>% filter(avg_log2FC<0)
189
df_tmp2 <- df_tmp %>% filter(avg_log2FC>0)
190
191
p4 <- 
192
  ggplot()+
193
  geom_point(data=df_tmp1, aes(x=avg_log2FC, y=power), alpha=ifelse(!is.na(df_tmp1$Label), 1, 0.25), stroke=0, size=1.25)+
194
  geom_point(data=df_tmp2, aes(x=avg_log2FC, y=power), alpha=ifelse(!is.na(df_tmp2$Label), 1, 0.25), stroke=0, size=1.25)+
195
  ggrepel::geom_text_repel(data=df_tmp1, aes(x=avg_log2FC, y=power, label=Label), show.legend = F, size=2.5, segment.size=0.25, xlim = c(-1.25, -1.75))+
196
  ggrepel::geom_text_repel(data=df_tmp2, aes(x=avg_log2FC, y=power, label=Label), show.legend = F, size=2.5, segment.size=0.25, xlim = c(1.3, 1.5))+
197
  geom_vline(xintercept = 0, linetype="dashed", size=0.25)+
198
  scale_y_continuous(breaks = c(0.2, 0.4, 0.6, 0.8), limits=c(0.1, 0.85), name="2 x abs(AUC-0.5)")+
199
  scale_x_continuous(name=expression('log'[2]~'fold change'), limits = c(-2.2, 2.2), expand = c(0,0))+
200
  annotation_custom(grob = textGrob(label = expression('T'[REG]~'EM'[1]), hjust = 0.5, gp = gpar(cex=0.6, fontface="bold", col=colors_umap_cl["15"])), 
201
                    xmin = -position.label, xmax = -position.label,
202
                    ymin = height.label, ymax = height.label)+
203
  annotation_custom(grob = textGrob(label = expression('T'[REG]~'EM'[2]), hjust = 0.5, gp = gpar(cex=0.6, fontface="bold", col=colors_umap_cl["11"])),
204
                    xmin = position.label, xmax = position.label,
205
                    ymin = height.label, ymax = height.label)+
206
  mytheme_1+
207
  coord_cartesian(clip = "off")+
208
  theme(legend.position = c(0.17, 0.15),
209
        legend.key.height = unit(units="cm", 0.3),
210
        legend.box.spacing = unit(units="cm", 0.01),
211
        legend.text = element_text(size=7),
212
        panel.border = element_rect(size=0.25),
213
        plot.margin = unit(c(0,0.25,0,0), "cm"),
214
        legend.background = element_rect(fill = NA),
215
        legend.box.margin=margin(-20,-20,-20,-20),
216
        legend.key.width = unit(units="cm", 0.1))+
217
    labs(tag = "C")
218
219
```
220
221
## Shared clonotypes
222
```{r shared clonotypes}
223
224
df_clonotypes_shared <- 
225
  left_join(DFtotal_5prime %>% filter(!is.na(raw_clonotype_id)) %>% 
226
            select(Barcode_fulla=Barcode_full, PatientID, refUMAP_1a=refUMAP_1, refUMAP_2a=refUMAP_2, IdentIa=IdentI, raw_clonotype_id) %>% distinct(),
227
          DFtotal_5prime %>% filter(!is.na(raw_clonotype_id)) %>% 
228
            select(Barcode_fullb=Barcode_full, PatientID, refUMAP_1b=refUMAP_1, refUMAP_2b=refUMAP_2, IdentIb=IdentI, raw_clonotype_id) %>% distinct()
229
          ) %>% 
230
  filter(Barcode_fulla!=Barcode_fullb) %>% 
231
  filter(IdentIa!=IdentIb)
232
233
df_subset <- 
234
  df_clonotypes_shared %>% 
235
  add_entity() %>% 
236
  filter(IdentIb==11) %>% 
237
  filter(refUMAP_1b<1, refUMAP_2b>4)
238
239
label6 <- paste0(100*round(nrow(df_subset %>% filter(IdentIa==6))/nrow(df_subset), 3), " %")
240
label14 <- paste0(100*round(nrow(df_subset %>% filter(IdentIa==14))/nrow(df_subset), 3), " %")
241
label5 <- paste0(100*round(nrow(df_subset %>% filter(IdentIa==5))/nrow(df_subset), 3), " %")
242
243
p5 <- ggplot()+
244
  geom_point_rast(data=DFtotal_5prime,
245
                  aes(x=refUMAP_1, y=refUMAP_2, fill=IdentI), size=0.25, 
246
                  alpha=ifelse(DFtotal_5prime$IdentI==11, 0.75, 0.05), stroke=0, shape=21)+
247
  geom_curve(data= df_subset, 
248
             aes(x=refUMAP_1a, y=refUMAP_2a, xend=refUMAP_1b, yend=refUMAP_2b, color=IdentIa,
249
                 group=paste(raw_clonotype_id, PatientID)), curvature = -0.4, size=0.1, alpha=0.4)+
250
  geom_text(inherit.aes = F, aes(x=-0.75, y=8.5, label=label6), color=colors_umap_cl[["6"]], size=2.5)+
251
  geom_text(inherit.aes = F, aes(x=4.5, y=6.75, label=label14), color=colors_umap_cl[["14"]], size=2.5)+
252
  geom_text(inherit.aes = F, aes(x=8, y=1, label=label5), color=colors_umap_cl[["5"]], size=2.5)+
253
  scale_fill_manual(values = colors_umap_cl, guide="none")+
254
  scale_color_manual(values = colors_umap_cl, guide="none")+
255
  coord_cartesian(clip = "off")+
256
  labs(
257
    x="refUMAP-1",
258
    y="refUMAP-2",
259
    title="Paired clonotypes of <span style='color:#08306B'>T<sub>REG</sub> EM<sub>2</sub></span>")+
260
  mytheme_1+
261
  theme(panel.border = element_rect(size=0.25),
262
        plot.title = element_textbox_simple(size = 7, width = NULL, padding = margin(1.25, 0, 1, 0), 
263
                                            lineheight = 1.25, halign=0.5, face = "plain"),
264
        plot.margin = unit(c(0,0.25,0,0), units = "cm"))+
265
  labs(tag = "D")
266
267
268
```
269
270
## Association with FL grade
271
```{r tumor grading}
272
273
p6 <- df_freq %>% 
274
  left_join(., df_meta %>% select(PatientID, FL_Grade, Entity) %>% distinct, by="PatientID") %>% 
275
  filter(Population==11, Entity=="FL") %>% 
276
  ggplot(aes(x=FL_Grade, y=RNA))+
277
  geom_boxplot(size=0.25, width=0.3, outlier.alpha = 0)+
278
  ggbeeswarm::geom_beeswarm(size=0.8, shape=21, stroke=0.25, cex = 2.75, fill="grey65")+
279
  stat_compare_means(comparisons = list(c("1/2", "3A")), vjust = -0.35, label.y = c(16.75),
280
                     size=2.5, tip.length = 0.02, bracket.size = 0.25)+
281
  ggtitle(expression('T'[REG]~'EM'[2]))+
282
  xlab("Grade")+
283
  ylim(0,18.25)+
284
  ylab("% of total T-cells")+
285
  mytheme_1+
286
  theme(legend.position = "none",
287
        strip.background = element_rect(color=NA),
288
        panel.border = element_rect(size=0.5),
289
        plot.title = element_text(vjust = -1, color=colors_umap_cl[["11"]]),
290
        panel.background = element_rect(fill=NA),
291
        plot.margin = unit(c(0,0.25,0,0.25), "cm"))+
292
    labs(tag = "E")
293
294
p7 <- df_freq %>% 
295
  left_join(., df_meta %>% select(PatientID, FL_Grade, Entity) %>% distinct, by="PatientID") %>% 
296
  filter(Population==6, Entity=="FL") %>% 
297
  ggplot(aes(x=FL_Grade, y=RNA))+
298
  geom_boxplot(size=0.25, width=0.3, outlier.size = 1, outlier.alpha = 0, outlier.shape = 21, outlier.fill = "grey70")+
299
  ggbeeswarm::geom_beeswarm(size=0.8, shape=21, stroke=0.25, cex = 2.75, fill="grey65")+
300
  stat_compare_means(comparisons = list(c("1/2", "3A")), vjust = -0.35, label.y = c(59.5),
301
                     size=2.5, tip.length = 0.02, bracket.size = 0.25)+
302
  ggtitle(expression('T'[FH]))+
303
  ylim(0,65)+
304
  xlab("Grade")+
305
  ylab("% of total T-cells")+
306
  mytheme_1+
307
  theme(legend.position = "none",
308
        strip.background = element_rect(color=NA),
309
        panel.border = element_rect(size=0.5),
310
        plot.title = element_text(vjust = -1, color=colors_umap_cl[["6"]]),
311
        panel.background = element_rect(fill=NA),
312
        plot.margin = unit(c(0,0.25,0,0.25), "cm"))+
313
    labs(tag = "F")
314
315
```
316
317
## Assemble plot
318
```{r compose plot II, fig.height=2.8}
319
320
p4+p5+p6+p7+plot_layout(widths = c(1.05,1,0.3,0.3))
321
322
#ggsave(width = 18.5, height = 6.5, units = "cm", filename = "Figure6_p2.pdf")
323
324
```
325
326
# Session info
327
```{r session info}
328
329
sessionInfo()
330
331
```