TigerZheng commited on
Commit
c9f54c2
·
verified ·
1 Parent(s): ffb3634

Delete PFCapp.qmd

Browse files
Files changed (1) hide show
  1. PFCapp.qmd +0 -502
PFCapp.qmd DELETED
@@ -1,502 +0,0 @@
1
- ---
2
- title: "PFC Dashboards"
3
- author: "Cao Lab"
4
- server: shiny
5
- format:
6
- dashboard:
7
- logo: https://zhenghu159.github.io/picx-images-hosting/PFCapp/Logo-circle.7sn4nqapcl.png
8
- nav-buttons:
9
- - icon: github
10
- href: https://github.com/GangCaoLab/mPFC-web
11
- ---
12
-
13
-
14
-
15
- # Home
16
-
17
- <p style="font-size: 50px; font-weight: bold; text-align: center;">A single-cell resolution spatial-transcriptome-connectome integrated multi-omic atlas of prefrontal cortex</p>
18
-
19
- <br>
20
-
21
- <img src="https://zhenghu159.github.io/picx-images-hosting/PFCapp/main.77dcin4jph.webp" style="width: 100%;">
22
-
23
- <br>
24
- <br>
25
-
26
- <p style="font-size: 30px; font-weight: bold; text-align: left;">
27
- Abstract
28
- </p>
29
-
30
- <p style="font-size: 20px; text-align: justify;">
31
- Medial prefrontal cortex (mPFC) is the high-level center of brain cognitive function, which regulates emotion, memory, decision-making, behavior, neuroendocrine and other brain functions. mPFC has a wide range of projections in the cerebral cortex, thalamus, hypothalamus, basal ganglia, midbrain and other brain regions, forms extremely complex projection circuits. Analyzing these numerous projection circuits structures is an urgent problem in neuroscience. The conventional method is using neurotropic viruses to express fluorescent proteins for nucleus labeling. However, due to the limitation of fluorescent protein types and spectral crossover, it is time-consuming and labor-intensive to realize multiple nucleus labeling and tracing. The ideal circuits analysis solution is to break through the limit of fluorescent protein types and can label multiple brain regions. On the basis of multi-brain circuits labeling, it can also analyze the expression of neuron-related genes in the circuits, so as to better interpret the mechanism by which specific circuits perform their functions.
32
- </p>
33
-
34
-
35
- <br>
36
-
37
- <p style="font-size: 30px; font-weight: bold; text-align: left;">
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}
91
- #| context: setup
92
- #| warning: false
93
- #| message: false
94
-
95
- library(ggplot2)
96
- library(Seurat)
97
- #library(scCustomize)
98
- library(shiny)
99
- library(rgl)
100
- library(ggdark)
101
- library(viridis)
102
- library(dplyr)
103
- #library(wholebrain)
104
- #attach(loadNamespace('wholebrain'), warn.conflicts = FALSE)
105
- source("R/Palettes.R")
106
- source('R/includes.R')
107
- Adult.Ex <- readRDS('data/Adult.Ex.rds')
108
- sp.PFC <- readRDS('data/sp.PFC.rds')
109
- options(rgl.useNULL = TRUE)
110
- ```
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
173
-
174
- output$cluster_plot <- renderPlot({
175
- DimPlot(
176
- Adult.Ex,
177
- reduction = 'umap',
178
- group.by = input$cluster,
179
- cols = col_cluster[[input$cluster]],
180
- label = T
181
- ) +
182
- coord_fixed()
183
- })
184
-
185
- output$gene_plot <- renderPlot({
186
- FeaturePlot(
187
- Adult.Ex,
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$Zscore[df$Zscore<0] <- 0
323
- df$Zscore[df$Zscore>3] <- 3
324
- df <- df[order(df$Zscore),]
325
- ggplot(df,aes(x=X,y=Y)) +
326
- geom_point(aes(colour=Zscore), size=1) +
327
- scale_color_gradientn(colours = viridis(n = 256, option = "D", direction = 1)) +
328
- ggdark::dark_theme_void() +
329
- labs(title = input$sp_gene) +
330
- theme(plot.title = element_text(size = 20, hjust = 0.5),
331
- legend.position = 'bottom') +
332
- coord_fixed()
333
- })
334
-
335
- output$sp_target_plot <- renderPlot({
336
- seu <- sp.PFC
337
- seu$PTi[is.na(seu$PTi)] <- 0
338
- seu$ITi_D[is.na(seu$ITi_D)] <- 0
339
- seu$ITi_V[is.na(seu$ITi_V)] <- 0
340
- seu$ITc[is.na(seu$ITc)] <- 0
341
- df <- data.frame(
342
- X = seu$ML_new,
343
- Y = seu$DV_new,
344
- Zscore = scale(log1p([email protected][,input$sp_target]))
345
- )
346
- df <- df[which(seu$slice==input$sp_slice),]
347
- df$Zscore[df$Zscore<0] <- 0
348
- df$Zscore[df$Zscore>3] <- 3
349
- df <- df[order(df$Zscore),]
350
- ggplot(df, aes(x=X,y=Y)) +
351
- geom_point(aes(colour=Zscore), size=1) +
352
- scale_color_gradientn(colours = viridis(n = 256, option = "E", direction = 1)) +
353
- ggdark::dark_theme_void() +
354
- labs(title = input$sp_target) +
355
- theme(plot.title = element_text(size = 20, hjust = 0.5),
356
- legend.position = 'bottom') +
357
- coord_fixed()
358
- })
359
-
360
- output$sp_target_line_plot <- renderPlot({
361
- # AP
362
- seu <- subset(sp.PFC, cells=colnames(sp.PFC)[which(sp.PFC$ABA_hemisphere=="Left")])
363
- slice <- unique(seu$slice)
364
- df <- data.frame('slice'=slice)
365
- for (i in 1:length(slice)){
366
- df$cellnum[i] <- length(which(seu$slice==slice[i] &
367
- [email protected][,input$sp_target]>0))/
368
- length(which(seu$slice==slice[i] & seu$BC_num>0))
369
- }
370
- df$x <- c(1:36)
371
- p1 <- ggplot(df, aes(x=x, y=cellnum)) +
372
- geom_point(alpha=0.5, size=3, color=col_Barcode[input$sp_target]) +
373
- geom_smooth(se = F, linewidth=1.5, color=col_Barcode[input$sp_target]) +
374
- theme_bw() +
375
- scale_x_continuous(breaks = seq(0,35,5)) +
376
- theme(text = element_text(size=15),
377
- plot.title = element_text(size = 20, hjust = 0.5)) +
378
- labs(x='A → P',y='Cell proportion')
379
-
380
- # DV
381
- sp_Barcode <- c("ITi_D", "ITi_V", "ITc", "PTi",
382
- 'VIS-I','SSp-I','CP-I','AUD-I','RSP-I',
383
- 'BLA-I','ACB-I','AId-I','ECT-I',
384
- 'ACB-C','ECT-C','CP-C','AId-C','RSP-C',
385
- 'LHA-I')
386
- seu <- subset(sp.PFC, cells=colnames(sp.PFC)[which(sp.PFC$ABA_hemisphere=="Left")])
387
- bc_slice <- [email protected][,c(sp_Barcode, 'Y','BC_num')]
388
- bc_slice <-
389
- bc_slice |>
390
- mutate(bin = cut(Y, breaks = 36))
391
- bin <- sort(unique(bc_slice$bin))
392
- bc_slice$bin_index <- match(bc_slice$bin, bin)
393
- df <- data.frame('bin_index'=c(1:36))
394
- for (i in 1:36){
395
- df$cellnum[i] <- length(which(bc_slice$bin_index==i &
396
- bc_slice[,input$sp_target]>0))/
397
- length(which(bc_slice$bin_index==i & bc_slice$BC_num>0))
398
- }
399
- df$x <- c(1:36)
400
- p2 <- ggplot(df, aes(x=x, y=cellnum)) +
401
- geom_point(alpha=0.5, size=3, color=col_Barcode[input$sp_target]) +
402
- geom_smooth(se = F, linewidth=1.5, color=col_Barcode[input$sp_target]) +
403
- theme_bw() +
404
- scale_x_continuous(breaks = seq(0,35,5)) +
405
- theme(text = element_text(size=15),
406
- plot.title = element_text(size = 20, hjust = 0.5)) +
407
- labs(x='D → V',y='Cell proportion') +
408
- xlim(36, 0)
409
- p1/p2
410
- })
411
- ```
412
-
413
-
414
-
415
-
416
-
417
-
418
- # 3D
419
-
420
- ## {.sidebar}
421
-
422
- ```{r}
423
- sp_Barcode <- c("ITi-D", "ITi-V", "ITc", "PTi",
424
- 'VIS-I','SSp-I','CP-I','AUD-I','RSP-I',
425
- 'BLA-I','ACB-I','AId-I','ECT-I',
426
- 'ACB-C','ECT-C','CP-C','AId-C','RSP-C',
427
- 'LHA-I')
428
- waiter::use_waiter()
429
- selectInput('subtype_3d', 'Select SubType', sort(unique(sp.PFC$SubType)))
430
- selectInput('target_3d', 'Select Target', sp_Barcode)
431
- ```
432
-
433
-
434
- ## Column
435
-
436
- ```{r}
437
- rglwidgetOutput('spatial_subtype', width = "100%")
438
- ```
439
-
440
-
441
- ```{r}
442
- #| context: server
443
-
444
- observeEvent(input$target_3d,{
445
- waiter::Waiter$new(id = "spatial_subtype", color="black")$show()
446
- output$spatial_subtype <- renderRglwidget({
447
- if (input$target_3d %in% c("ITi-D", "ITi-V", "ITc", "PTi")){
448
- df_plot <- [email protected][which(sp.PFC$Proj_module==input$target_3d),]
449
- }else{
450
- df_plot <- [email protected][which([email protected][,input$target_3d] > 0),]
451
- }
452
-
453
- open3d()
454
- bg3d(color = "black")
455
- par3d(userMatrix = rotationMatrix(-pi/6, -1, 1, 0), zoom = 0.6)
456
- acr.list <- c("MOs","PL","ORBm","ACAd","ILA","DP","ACAv")
457
-
458
- for(acr in acr.list){
459
- mesh <- mesh3d.allen.annot.from.id(get.id.from.acronym(acr))
460
- col <- "lightgray"
461
- shade3d(mesh, col = col, material = list(lit=FALSE), alpha = 0.1)
462
- }
463
-
464
- spheres3d(x = df_plot$ML_new,
465
- y = df_plot$DV_new,
466
- z = df_plot$AP_new,
467
- col = col_subtype_target[input$target_3d], radius=0.01, alpha=1)
468
- rglwidget()
469
- })
470
- })
471
-
472
- observeEvent(input$subtype_3d,{
473
- waiter::Waiter$new(id = "spatial_subtype", color="black")$show()
474
- output$spatial_subtype <- renderRglwidget({
475
- df_plot <- [email protected][which(sp.PFC$SubType == input$subtype_3d),]
476
-
477
- open3d()
478
- bg3d(color = "black")
479
- par3d(userMatrix = rotationMatrix(-pi/6, -1, 1, 0), zoom = 0.6)
480
- acr.list <- c("MOs","PL","ORBm","ACAd","ILA","DP","ACAv")
481
-
482
- for(acr in acr.list){
483
- mesh <- mesh3d.allen.annot.from.id(get.id.from.acronym(acr))
484
- col <- "lightgray"
485
- shade3d(mesh, col = col, material = list(lit=FALSE), alpha = 0.1)
486
- }
487
-
488
- spheres3d(x = df_plot$ML_new,
489
- y = df_plot$DV_new,
490
- z = df_plot$AP_new,
491
- col = col_subtype_target[input$subtype_3d], radius=0.01, alpha=1)
492
- rglwidget()
493
- })
494
- })
495
- ```
496
-
497
-
498
-
499
-
500
-
501
-
502
-