TigerZheng commited on
Commit
824790f
·
verified ·
1 Parent(s): 5a43661

Update PFCapp.qmd

Browse files
Files changed (1) hide show
  1. PFCapp.qmd +312 -17
PFCapp.qmd CHANGED
@@ -38,19 +38,53 @@ Medial prefrontal cortex (mPFC) is the high-level center of brain cognitive func
38
  Interactively exploring the data
39
  </p>
40
 
41
- <a style="font-size: 20px; font-weight: bold; text-align: left;">
42
  scRNAseq
43
- </a>
 
 
 
 
44
 
45
- - Cell cluster UMAP
46
- - Feature plot in UMAP
 
 
47
 
48
- <a style="font-size: 20px; font-weight: bold; text-align: left;">
 
 
49
  Spatial data
50
- </a>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
 
52
 
53
 
 
 
 
 
 
 
 
54
 
55
 
56
  ```{r}
@@ -63,6 +97,9 @@ library(Seurat)
63
  #library(scCustomize)
64
  library(shiny)
65
  library(rgl)
 
 
 
66
  #library(wholebrain)
67
  #attach(loadNamespace('wholebrain'), warn.conflicts = FALSE)
68
  source("R/Palettes.R")
@@ -74,24 +111,62 @@ options(rgl.useNULL = TRUE)
74
 
75
 
76
 
77
- # scRNAseq
78
 
79
- ## Row
80
 
81
- ### Column
 
 
82
 
83
  ```{r}
84
  selectInput('cluster', 'Select Cluster', c("SubType_Layer","SubType"))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
85
  plotOutput('cluster_plot')
86
  ```
87
 
88
- ### Column
89
 
90
  ```{r}
91
- selectInput('gene', 'Select Gene', rownames(Adult.Ex))
92
  plotOutput('gene_plot')
93
  ```
94
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
95
 
96
  ```{r}
97
  #| context: server
@@ -113,29 +188,238 @@ output$gene_plot <- renderPlot({
113
  features = input$gene) +
114
  coord_fixed()
115
  })
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
116
  ```
117
 
118
 
119
 
120
 
121
 
 
122
 
123
- # Spatial
124
 
125
- ```{=html}
126
- <iframe src="https://avivator.gehlenborglab.org/?image_url=https://huggingface.co/YAYUhuang/Imagesave/resolve/main/PT-2-C2-C.ome.tiff" title="PFC" height="800" width="100%"></iframe>
127
  ```
128
 
 
 
 
129
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
130
 
131
- # 3D
132
 
133
- ## Row
134
 
135
- ### Column
 
 
 
 
 
136
 
137
  ```{r}
138
  selectInput('subtype', 'Select SubType', sort(unique(sp.PFC$SubType)))
 
 
 
 
 
 
139
  rglwidgetOutput('spatial_subtype', width = "100%")
140
  ```
141
 
@@ -173,3 +457,14 @@ output$spatial_subtype <- renderRglwidget({
173
 
174
 
175
 
 
 
 
 
 
 
 
 
 
 
 
 
38
  Interactively exploring the data
39
  </p>
40
 
41
+ <p style="font-size: 20px; font-weight: bold; text-align: left;">
42
  scRNAseq
43
+ </p>
44
+
45
+ <p style="font-size: 20px; text-align: justify;">
46
+ Our scRNAseq dataset sequenced the PFC of 3 mice. It contains the transcriptome of mouse PFC and the projectome information of 24 PFC targets. Users can browse the following content through the scRNA-seq tab:
47
+ </p>
48
 
49
+ - Cells in the UMAP can be clustered differently by selecting different classification in Metadata
50
+ - Select to view different genes expression in the UMAP
51
+ - Select to view different PFC targets expression in the UMAP
52
+ - View PFC targets cell numbers in different cell type
53
 
54
+
55
+
56
+ <p style="font-size: 20px; font-weight: bold; text-align: left;">
57
  Spatial data
58
+ </p>
59
+
60
+ <p style="font-size: 20px; text-align: justify;">
61
+ Our spatial dataset sequenced 36 slices of mouse PFC. It contains 32 genes and 15 targets information of mouse PFC. Users can browse the following content through the spatial tab:
62
+ </p>
63
+
64
+ - Select to view different cell types in spatial
65
+ - Select to view different gene expression in spatial
66
+ - Select to view different PFC targets expression in spatial
67
+ - Select to view different PFC targets distribution in anterior-posterior and ventralis-dorsalis axes
68
+
69
+
70
+
71
+ <p style="font-size: 20px; font-weight: bold; text-align: left;">
72
+ 3D
73
+ </p>
74
+
75
+ <p style="font-size: 20px; text-align: justify;">
76
+ 3D interactive visualization of mouse PFC.
77
+ </p>
78
 
79
 
80
 
81
+ <p style="font-size: 20px; font-weight: bold; text-align: left;">
82
+ raw image
83
+ </p>
84
+
85
+ <p style="font-size: 20px; text-align: justify;">
86
+ visualization of raw images.
87
+ </p>
88
 
89
 
90
  ```{r}
 
97
  #library(scCustomize)
98
  library(shiny)
99
  library(rgl)
100
+ library(ggdark)
101
+ library(viridis)
102
+ library(tidyverse)
103
  #library(wholebrain)
104
  #attach(loadNamespace('wholebrain'), warn.conflicts = FALSE)
105
  source("R/Palettes.R")
 
111
 
112
 
113
 
 
114
 
 
115
 
116
+ # scRNAseq {scrolling="true"}
117
+
118
+ ## {.sidebar}
119
 
120
  ```{r}
121
  selectInput('cluster', 'Select Cluster', c("SubType_Layer","SubType"))
122
+ ```
123
+
124
+ ```{r}
125
+ selectInput('gene', 'Select Gene', rownames(Adult.Ex))
126
+ ```
127
+
128
+ ```{r}
129
+ Barcode <- c(
130
+ "ITi_D_score", "ITi_V_score", "ITc_score", "PTi_score",
131
+ 'VIS-I','SSp-I','CP-I','AUD-I','RSP-I',
132
+ 'BLA-I','ACB-I','ENTl-I','AId-I','ECT-I',
133
+ 'ACB-C','PL-C','ECT-C','ENTl-C',
134
+ 'BLA-C','CP-C','AId-C','RSP-C',
135
+ 'MD-I','RE-I','DR-I','VTA-I','LHA-I','SC-I')
136
+ selectInput('target', 'Select Target', Barcode)
137
+ ```
138
+
139
+
140
+ ## Column
141
+
142
+ ### Row
143
+
144
+ #### Column
145
+
146
+ ```{r}
147
  plotOutput('cluster_plot')
148
  ```
149
 
150
+ #### Column
151
 
152
  ```{r}
 
153
  plotOutput('gene_plot')
154
  ```
155
 
156
+ ### Row
157
+
158
+ #### Column
159
+
160
+ ```{r}
161
+ plotOutput('target_plot')
162
+ ```
163
+
164
+ #### Column
165
+
166
+ ```{r}
167
+ plotOutput('target_bar_plot')
168
+ ```
169
+
170
 
171
  ```{r}
172
  #| context: server
 
188
  features = input$gene) +
189
  coord_fixed()
190
  })
191
+
192
+ output$target_plot <- renderPlot({
193
+ Barcode <- c(
194
+ "ITi_D_score", "ITi_V_score", "ITc_score", "PTi_score",
195
+ 'VIS-I','SSp-I','CP-I','AUD-I','RSP-I',
196
+ 'BLA-I','ACB-I','ENTl-I','AId-I','ECT-I',
197
+ 'ACB-C','PL-C','ECT-C','ENTl-C',
198
+ 'BLA-C','CP-C','AId-C','RSP-C',
199
+ 'MD-I','RE-I','DR-I','VTA-I','LHA-I','SC-I')
200
+
201
+ seu <- Adult.Ex
202
+ [email protected][,Barcode][is.na([email protected][,Barcode])] <- 0
203
+ FeaturePlot(
204
+ seu, features = input$target, order = T) +
205
+ coord_fixed()
206
+ })
207
+
208
+ output$target_bar_plot <- renderPlot({
209
+ df <- as.data.frame(table([email protected][,input$cluster][which(
210
+ [email protected][,input$target]>0)]))
211
+ colnames(df) <- c("Celltypes","Cellnum")
212
+
213
+ ggplot(df, aes(x=Celltypes, y=Cellnum, fill=Celltypes)) +
214
+ geom_col() +
215
+ scale_fill_manual(values = col_cluster[[input$cluster]]) +
216
+ theme_classic() +
217
+ theme(axis.text.x = element_text(angle = 25, hjust = 1),
218
+ plot.title = element_text(hjust = 0.5)) +
219
+ labs(title = paste("PFC → ",input$target," cell numbers in different cell type",
220
+ sep=""))
221
+ })
222
  ```
223
 
224
 
225
 
226
 
227
 
228
+ # Spatial {scrolling="true"}
229
 
230
+ ## {.sidebar}
231
 
232
+ ```{r}
233
+ selectInput('sp_slice', 'Select Slice', unique(sp.PFC$slice))
234
  ```
235
 
236
+ ```{r}
237
+ selectInput('sp_cluster', 'Select Cluster', c("SubType_Layer","SubType"))
238
+ ```
239
 
240
+ ```{r}
241
+ selectInput('sp_gene', 'Select Gene', rownames(sp.PFC))
242
+ ```
243
+
244
+ ```{r}
245
+ sp_Barcode <- c(
246
+ "ITi_D", "ITi_V", "ITc", "PTi",
247
+ 'VIS-I','SSp-I','CP-I','AUD-I','RSP-I',
248
+ 'BLA-I','ACB-I','AId-I','ECT-I',
249
+ 'ACB-C','ECT-C','CP-C','AId-C','RSP-C',
250
+ 'LHA-I')
251
+ selectInput('sp_target', 'Select Target', sp_Barcode)
252
+ ```
253
+
254
+
255
+ ## Column
256
+
257
+ ### Row
258
+
259
+ #### Column
260
+
261
+ ```{r}
262
+ #| fig-width: 10
263
+
264
+ plotOutput('sp_cluster_plot')
265
+ ```
266
+
267
+ #### Column
268
+
269
+ ```{r}
270
+ #| fig-width: 10
271
+
272
+ plotOutput('sp_gene_plot')
273
+ ```
274
+
275
+ ### Row
276
+
277
+ #### Column
278
+
279
+ ```{r}
280
+ #| fig-width: 10
281
+
282
+ plotOutput('sp_target_plot')
283
+ ```
284
+
285
+ #### Column
286
+
287
+ ```{r}
288
+ #| fig-width: 10
289
+
290
+ plotOutput('sp_target_line_plot')
291
+ ```
292
+
293
+ ```{r}
294
+ #| context: server
295
+
296
+ output$sp_cluster_plot <- renderPlot({
297
+ df <- data.frame(
298
+ x = sp.PFC$ML_new[sp.PFC$slice==input$sp_slice],
299
+ y = sp.PFC$DV_new[sp.PFC$slice==input$sp_slice],
300
+ type = [email protected][sp.PFC$slice==input$sp_slice, input$sp_cluster]
301
+ )
302
+ ggplot(df, aes(x=x, y=y, color=type)) +
303
+ geom_point(size=1) +
304
+ scale_color_manual(values = col_cluster[[input$sp_cluster]]) +
305
+ labs(title = paste(input$slice,'cell types in spatial')) +
306
+ guides(color=guide_legend(nrow = 2, byrow = TRUE, reverse = T,
307
+ override.aes = list(size=2))) +
308
+ coord_fixed() +
309
+ ggdark::dark_theme_void() +
310
+ theme(plot.title = element_text(size = 20, hjust = 0.5),
311
+ legend.position = 'bottom', legend.title=element_blank(),
312
+ legend.text = element_text(size=10))
313
+ })
314
+
315
+ output$sp_gene_plot <- renderPlot({
316
+ df <- data.frame(
317
+ X = sp.PFC$ML_new,
318
+ Y = sp.PFC$DV_new,
319
+ Zscore = scale(log1p(sp.PFC@assays$RNA@counts[input$sp_gene,]))
320
+ )
321
+ df <- df[which(sp.PFC$slice==input$sp_slice),]
322
+ df <- df[order(df$Zscore),]
323
+ ggplot(df,aes(x=X,y=Y)) +
324
+ geom_point(aes(colour=Zscore), size=1) +
325
+ scale_color_gradientn(colours = viridis(n = 256, option = "D", direction = 1)) +
326
+ ggdark::dark_theme_void() +
327
+ labs(title = input$sp_gene) +
328
+ theme(plot.title = element_text(size = 20, hjust = 0.5),
329
+ legend.position = 'bottom') +
330
+ coord_fixed()
331
+ })
332
+
333
+ output$sp_target_plot <- renderPlot({
334
+ seu <- sp.PFC
335
+ [email protected][,c("PTi","ITi_D","ITi_V","ITc")][is.na([email protected][,c("PTi","ITi_D","ITi_V","ITc")])] <- 0
336
+ df <- data.frame(
337
+ X = sp.PFC$ML_new,
338
+ Y = sp.PFC$DV_new,
339
+ Zscore = scale(log1p([email protected][,input$sp_target]))
340
+ )
341
+ df <- df[which(sp.PFC$slice==input$sp_slice),]
342
+ df <- df[order(df$Zscore),]
343
+ ggplot(df, aes(x=X,y=Y)) +
344
+ geom_point(aes(colour=Zscore), size=1) +
345
+ scale_color_gradientn(colours = viridis(n = 256, option = "E", direction = 1)) +
346
+ ggdark::dark_theme_void() +
347
+ labs(title = input$sp_target) +
348
+ theme(plot.title = element_text(size = 20, hjust = 0.5),
349
+ legend.position = 'bottom') +
350
+ coord_fixed()
351
+ })
352
+
353
+ output$sp_target_line_plot <- renderPlot({
354
+ # AP
355
+ seu <- subset(sp.PFC, cells=colnames(sp.PFC)[which(sp.PFC$ABA_hemisphere=="Left")])
356
+ slice <- unique(seu$slice)
357
+ df <- data.frame('slice'=slice)
358
+ for (i in 1:length(slice)){
359
+ df$cellnum[i] <- length(which(seu$slice==slice[i] &
360
+ [email protected][,input$sp_target]>0))/
361
+ length(which(seu$slice==slice[i] & seu$BC_num>0))
362
+ }
363
+ df$x <- c(1:36)
364
+ p1 <- ggplot(df, aes(x=x, y=cellnum)) +
365
+ geom_point(alpha=0.5, size=3, color=col_Barcode[input$sp_target]) +
366
+ geom_smooth(se = F, linewidth=1.5, color=col_Barcode[input$sp_target]) +
367
+ theme_bw() +
368
+ scale_x_continuous(breaks = seq(0,35,5)) +
369
+ theme(text = element_text(size=15),
370
+ plot.title = element_text(size = 20, hjust = 0.5)) +
371
+ labs(x='A → P',y='Cell proportion')
372
+
373
+ # DV
374
+ sp_Barcode <- c("ITi_D", "ITi_V", "ITc", "PTi",
375
+ 'VIS-I','SSp-I','CP-I','AUD-I','RSP-I',
376
+ 'BLA-I','ACB-I','AId-I','ECT-I',
377
+ 'ACB-C','ECT-C','CP-C','AId-C','RSP-C',
378
+ 'LHA-I')
379
+ seu <- subset(sp.PFC, cells=colnames(sp.PFC)[which(sp.PFC$ABA_hemisphere=="Left")])
380
+ bc_slice <- [email protected][,c(sp_Barcode, 'Y','BC_num')]
381
+ bc_slice <-
382
+ bc_slice |>
383
+ mutate(bin = cut(Y, breaks = 36))
384
+ bin <- sort(unique(bc_slice$bin))
385
+ bc_slice$bin_index <- match(bc_slice$bin, bin)
386
+ df <- data.frame('bin_index'=c(1:36))
387
+ for (i in 1:36){
388
+ df$cellnum[i] <- length(which(bc_slice$bin_index==i &
389
+ bc_slice[,input$sp_target]>0))/
390
+ length(which(bc_slice$bin_index==i & bc_slice$BC_num>0))
391
+ }
392
+ df$x <- c(1:36)
393
+ p2 <- ggplot(df, aes(x=x, y=cellnum)) +
394
+ geom_point(alpha=0.5, size=3, color=col_Barcode[input$sp_target]) +
395
+ geom_smooth(se = F, linewidth=1.5, color=col_Barcode[input$sp_target]) +
396
+ theme_bw() +
397
+ scale_x_continuous(breaks = seq(0,35,5)) +
398
+ theme(text = element_text(size=15),
399
+ plot.title = element_text(size = 20, hjust = 0.5)) +
400
+ labs(x='D → V',y='Cell proportion') +
401
+ xlim(36, 0)
402
+ p1/p2
403
+ })
404
+ ```
405
 
 
406
 
 
407
 
408
+
409
+
410
+
411
+ # 3D
412
+
413
+ ## {.sidebar}
414
 
415
  ```{r}
416
  selectInput('subtype', 'Select SubType', sort(unique(sp.PFC$SubType)))
417
+ ```
418
+
419
+
420
+ ## Column
421
+
422
+ ```{r}
423
  rglwidgetOutput('spatial_subtype', width = "100%")
424
  ```
425
 
 
457
 
458
 
459
 
460
+
461
+ # raw image
462
+
463
+ ```{=html}
464
+ <iframe src="https://avivator.gehlenborglab.org/?image_url=https://huggingface.co/YAYUhuang/Imagesave/resolve/main/PT-2-C2-C.ome.tiff?rel=0&amp;autoplay=1" title="PFC" height="800" width="100%"></iframe>
465
+ ```
466
+
467
+
468
+
469
+
470
+