Spaces:
Sleeping
Sleeping
Update PFCapp.qmd
Browse files- PFCapp.qmd +21 -18
PFCapp.qmd
CHANGED
@@ -9,9 +9,6 @@ format:
|
|
9 |
- icon: github
|
10 |
href: https://github.com/ZhengTiger/SPIDER-Seq
|
11 |
---
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
# Home
|
16 |
|
17 |
<p style="font-size: 50px; font-weight: bold; text-align: center;">Modular organization of mouse prefrontal cortex subnetwork revealed by spatial single-cell multi-omic analysis of SPIEDER-Seq</p>
|
@@ -106,12 +103,20 @@ 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 |
|
110 |
clean_cells <- colnames(Adult.Ex)[!(
|
111 |
(Adult.Ex$Ex_subtype %in% c("CT","NP") & Adult.Ex$BC_num>0) |
|
112 |
(Adult.Ex$sample %in% c("Adult2","Adult3") & Adult.Ex$Ex_subtype=="PT" & Adult.Ex$BC_num>0)
|
113 |
)]
|
114 |
Adult.Ex.clean <- subset(Adult.Ex, cells = clean_cells)
|
|
|
|
|
|
|
|
|
115 |
|
116 |
options(rgl.useNULL = TRUE)
|
117 |
```
|
@@ -135,7 +140,7 @@ selectInput('gene', 'Select Gene', rownames(Adult.Ex),
|
|
135 |
|
136 |
```{r}
|
137 |
Barcode <- c(
|
138 |
-
"ITi-
|
139 |
'VIS-I','SSp-I','CP-I','AUD-I','RSP-I',
|
140 |
'BLA-I','ACB-I','ENTl-I','AId-I','ECT-I',
|
141 |
'ACB-C','PL-C','ECT-C','ENTl-C',
|
@@ -199,7 +204,7 @@ output$gene_plot <- renderPlot({
|
|
199 |
|
200 |
output$target_plot <- renderPlot({
|
201 |
Barcode <- c(
|
202 |
-
"ITi-
|
203 |
'VIS-I','SSp-I','CP-I','AUD-I','RSP-I',
|
204 |
'BLA-I','ACB-I','ENTl-I','AId-I','ECT-I',
|
205 |
'ACB-C','PL-C','ECT-C','ENTl-C',
|
@@ -207,7 +212,6 @@ output$target_plot <- renderPlot({
|
|
207 |
'MD-I','RE-I','DR-I','VTA-I','LHA-I','SC-I'
|
208 |
)
|
209 |
seu <- Adult.Ex.clean
|
210 |
-
colnames([email protected])[match(c("ITi_D_score", "ITi_V_score", "ITc_score", "PTi_score"),colnames([email protected]))] <- c("ITi-D", "ITi-V","ITc","PTi")
|
211 |
[email protected][,Barcode][is.na([email protected][,Barcode])] <- 0
|
212 |
FeaturePlot(
|
213 |
seu, features = input$target, order = T) +
|
@@ -216,7 +220,7 @@ output$target_plot <- renderPlot({
|
|
216 |
|
217 |
output$target_bar_plot <- renderPlot({
|
218 |
seu <- Adult.Ex.clean
|
219 |
-
if (input$target %in% c("ITi-
|
220 |
df <- as.data.frame(table([email protected][,input$cluster][which(seu$Proj_module==input$target)]))
|
221 |
}else{
|
222 |
df <- as.data.frame(table([email protected][,input$cluster][which([email protected][,input$target]>0)]))
|
@@ -258,7 +262,7 @@ selectInput('sp_gene', 'Select Gene', rownames(sp.PFC),
|
|
258 |
|
259 |
```{r}
|
260 |
sp_Barcode <- c(
|
261 |
-
"ITi-
|
262 |
'VIS-I','SSp-I','CP-I','AUD-I','RSP-I',
|
263 |
'BLA-I','ACB-I','AId-I','ECT-I',
|
264 |
'ACB-C','ECT-C','CP-C','AId-C','RSP-C',
|
@@ -317,7 +321,7 @@ output$sp_cluster_plot <- renderPlot({
|
|
317 |
ggplot(df, aes(x=x, y=y, color=type)) +
|
318 |
geom_point(size=1) +
|
319 |
scale_color_manual(values = col_cluster[[input$sp_cluster]]) +
|
320 |
-
labs(title = paste(input$slice,'
|
321 |
guides(color=guide_legend(nrow = 2, byrow = TRUE, reverse = T,
|
322 |
override.aes = list(size=2))) +
|
323 |
coord_fixed() +
|
@@ -350,10 +354,10 @@ output$sp_gene_plot <- renderPlot({
|
|
350 |
output$sp_target_plot <- renderPlot({
|
351 |
seu <- sp.PFC
|
352 |
seu$PTi[is.na(seu$PTi)] <- 0
|
353 |
-
seu
|
354 |
-
seu
|
355 |
-
seu
|
356 |
-
|
357 |
df <- data.frame(
|
358 |
X = seu$ML_new,
|
359 |
Y = seu$DV_new,
|
@@ -379,7 +383,7 @@ output$sp_target_line_plot <- renderPlot({
|
|
379 |
slice <- unique(seu$slice)
|
380 |
df <- data.frame('slice'=slice)
|
381 |
for (i in 1:length(slice)){
|
382 |
-
if (input$sp_target %in% c("ITi-
|
383 |
df$cellnum[i] <- length(which(seu$slice==slice[i] & seu$Proj_module==input$sp_target))/length(which(seu$slice==slice[i] & seu$BC_num>0))
|
384 |
}else{
|
385 |
df$cellnum[i] <- length(which(seu$slice==slice[i] & [email protected][,input$sp_target]>0))/length(which(seu$slice==slice[i] & seu$BC_num>0))
|
@@ -396,13 +400,12 @@ output$sp_target_line_plot <- renderPlot({
|
|
396 |
labs(x='A → P',y='Cell proportion')
|
397 |
|
398 |
# DV
|
399 |
-
sp_Barcode <- c("ITi-
|
400 |
'VIS-I','SSp-I','CP-I','AUD-I','RSP-I',
|
401 |
'BLA-I','ACB-I','AId-I','ECT-I',
|
402 |
'ACB-C','ECT-C','CP-C','AId-C','RSP-C',
|
403 |
'LHA-I')
|
404 |
seu <- subset(sp.PFC, cells=colnames(sp.PFC)[which(sp.PFC$ABA_hemisphere=="Left")])
|
405 |
-
colnames([email protected])[match(c("ITi_D","ITi_V"),colnames([email protected]))] <- c("ITi-D","ITi-V")
|
406 |
bc_slice <- [email protected][,c(sp_Barcode, 'Y','BC_num')]
|
407 |
bc_slice <-
|
408 |
bc_slice |>
|
@@ -438,7 +441,7 @@ output$sp_target_line_plot <- renderPlot({
|
|
438 |
## {.sidebar}
|
439 |
|
440 |
```{r}
|
441 |
-
sp_Barcode <- c("ITi-
|
442 |
'VIS-I','SSp-I','CP-I','AUD-I','RSP-I',
|
443 |
'BLA-I','ACB-I','AId-I','ECT-I',
|
444 |
'ACB-C','ECT-C','CP-C','AId-C','RSP-C',
|
@@ -462,7 +465,7 @@ rglwidgetOutput('spatial_subtype', width = "100%")
|
|
462 |
observeEvent(input$target_3d,{
|
463 |
waiter::Waiter$new(id = "spatial_subtype", color="black")$show()
|
464 |
output$spatial_subtype <- renderRglwidget({
|
465 |
-
if (input$target_3d %in% c("ITi-
|
466 |
df_plot <- [email protected][which(sp.PFC$Proj_module==input$target_3d),]
|
467 |
}else{
|
468 |
df_plot <- [email protected][which([email protected][,input$target_3d] > 0),]
|
|
|
9 |
- icon: github
|
10 |
href: https://github.com/ZhengTiger/SPIDER-Seq
|
11 |
---
|
|
|
|
|
|
|
12 |
# Home
|
13 |
|
14 |
<p style="font-size: 50px; font-weight: bold; text-align: center;">Modular organization of mouse prefrontal cortex subnetwork revealed by spatial single-cell multi-omic analysis of SPIEDER-Seq</p>
|
|
|
103 |
source('R/includes.R')
|
104 |
Adult.Ex <- readRDS('data/Adult.Ex.rds')
|
105 |
sp.PFC <- readRDS('data/sp.PFC.rds')
|
106 |
+
sp.PFC$Proj_module[which(sp.PFC$Proj_module=="ITi-D")] <- "ITi-M1"
|
107 |
+
sp.PFC$Proj_module[which(sp.PFC$Proj_module=="ITi-V")] <- "ITi-M2"
|
108 |
+
sp.PFC$Proj_module[which(sp.PFC$Proj_module=="ITc")] <- "ITc-M3"
|
109 |
+
colnames([email protected])[match(c("ITi_D","ITi_V","ITc"),colnames([email protected]))] <- c("ITi-M1","ITi-M2","ITc-M3")
|
110 |
|
111 |
clean_cells <- colnames(Adult.Ex)[!(
|
112 |
(Adult.Ex$Ex_subtype %in% c("CT","NP") & Adult.Ex$BC_num>0) |
|
113 |
(Adult.Ex$sample %in% c("Adult2","Adult3") & Adult.Ex$Ex_subtype=="PT" & Adult.Ex$BC_num>0)
|
114 |
)]
|
115 |
Adult.Ex.clean <- subset(Adult.Ex, cells = clean_cells)
|
116 |
+
Adult.Ex.clean$Proj_module[which(Adult.Ex.clean$Proj_module=="ITi-D")] <- "ITi-M1"
|
117 |
+
Adult.Ex.clean$Proj_module[which(Adult.Ex.clean$Proj_module=="ITi-V")] <- "ITi-M2"
|
118 |
+
Adult.Ex.clean$Proj_module[which(Adult.Ex.clean$Proj_module=="ITc")] <- "ITc-M3"
|
119 |
+
colnames([email protected])[match(c("ITi_D_score", "ITi_V_score", "ITc_score", "PTi_score"),colnames([email protected]))] <- c("ITi-M1", "ITi-M2","ITc-M3","PTi")
|
120 |
|
121 |
options(rgl.useNULL = TRUE)
|
122 |
```
|
|
|
140 |
|
141 |
```{r}
|
142 |
Barcode <- c(
|
143 |
+
"ITi-M1", "ITi-M2", "ITc-M3", "PTi",
|
144 |
'VIS-I','SSp-I','CP-I','AUD-I','RSP-I',
|
145 |
'BLA-I','ACB-I','ENTl-I','AId-I','ECT-I',
|
146 |
'ACB-C','PL-C','ECT-C','ENTl-C',
|
|
|
204 |
|
205 |
output$target_plot <- renderPlot({
|
206 |
Barcode <- c(
|
207 |
+
"ITi-M1", "ITi-M2","ITc-M3","PTi",
|
208 |
'VIS-I','SSp-I','CP-I','AUD-I','RSP-I',
|
209 |
'BLA-I','ACB-I','ENTl-I','AId-I','ECT-I',
|
210 |
'ACB-C','PL-C','ECT-C','ENTl-C',
|
|
|
212 |
'MD-I','RE-I','DR-I','VTA-I','LHA-I','SC-I'
|
213 |
)
|
214 |
seu <- Adult.Ex.clean
|
|
|
215 |
[email protected][,Barcode][is.na([email protected][,Barcode])] <- 0
|
216 |
FeaturePlot(
|
217 |
seu, features = input$target, order = T) +
|
|
|
220 |
|
221 |
output$target_bar_plot <- renderPlot({
|
222 |
seu <- Adult.Ex.clean
|
223 |
+
if (input$target %in% c("ITi-M1", "ITi-M2","ITc-M3","PTi")){
|
224 |
df <- as.data.frame(table([email protected][,input$cluster][which(seu$Proj_module==input$target)]))
|
225 |
}else{
|
226 |
df <- as.data.frame(table([email protected][,input$cluster][which([email protected][,input$target]>0)]))
|
|
|
262 |
|
263 |
```{r}
|
264 |
sp_Barcode <- c(
|
265 |
+
"ITi-M1", "ITi-M2","ITc-M3","PTi",
|
266 |
'VIS-I','SSp-I','CP-I','AUD-I','RSP-I',
|
267 |
'BLA-I','ACB-I','AId-I','ECT-I',
|
268 |
'ACB-C','ECT-C','CP-C','AId-C','RSP-C',
|
|
|
321 |
ggplot(df, aes(x=x, y=y, color=type)) +
|
322 |
geom_point(size=1) +
|
323 |
scale_color_manual(values = col_cluster[[input$sp_cluster]]) +
|
324 |
+
labs(title = paste(input$slice,'Cell types in spatial')) +
|
325 |
guides(color=guide_legend(nrow = 2, byrow = TRUE, reverse = T,
|
326 |
override.aes = list(size=2))) +
|
327 |
coord_fixed() +
|
|
|
354 |
output$sp_target_plot <- renderPlot({
|
355 |
seu <- sp.PFC
|
356 |
seu$PTi[is.na(seu$PTi)] <- 0
|
357 |
+
seu$`ITi-M1`[is.na(seu$`ITi-M1`)] <- 0
|
358 |
+
seu$`ITi-M2`[is.na(seu$`ITi-M2`)] <- 0
|
359 |
+
seu$`ITc-M3`[is.na(seu$`ITc-M3`)] <- 0
|
360 |
+
|
361 |
df <- data.frame(
|
362 |
X = seu$ML_new,
|
363 |
Y = seu$DV_new,
|
|
|
383 |
slice <- unique(seu$slice)
|
384 |
df <- data.frame('slice'=slice)
|
385 |
for (i in 1:length(slice)){
|
386 |
+
if (input$sp_target %in% c("ITi-M1","ITi-M2","ITc-M3","PTi")){
|
387 |
df$cellnum[i] <- length(which(seu$slice==slice[i] & seu$Proj_module==input$sp_target))/length(which(seu$slice==slice[i] & seu$BC_num>0))
|
388 |
}else{
|
389 |
df$cellnum[i] <- length(which(seu$slice==slice[i] & [email protected][,input$sp_target]>0))/length(which(seu$slice==slice[i] & seu$BC_num>0))
|
|
|
400 |
labs(x='A → P',y='Cell proportion')
|
401 |
|
402 |
# DV
|
403 |
+
sp_Barcode <- c("ITi-M1","ITi-M2","ITc-M3", "PTi",
|
404 |
'VIS-I','SSp-I','CP-I','AUD-I','RSP-I',
|
405 |
'BLA-I','ACB-I','AId-I','ECT-I',
|
406 |
'ACB-C','ECT-C','CP-C','AId-C','RSP-C',
|
407 |
'LHA-I')
|
408 |
seu <- subset(sp.PFC, cells=colnames(sp.PFC)[which(sp.PFC$ABA_hemisphere=="Left")])
|
|
|
409 |
bc_slice <- [email protected][,c(sp_Barcode, 'Y','BC_num')]
|
410 |
bc_slice <-
|
411 |
bc_slice |>
|
|
|
441 |
## {.sidebar}
|
442 |
|
443 |
```{r}
|
444 |
+
sp_Barcode <- c("ITi-M1","ITi-M2","ITc-M3", "PTi",
|
445 |
'VIS-I','SSp-I','CP-I','AUD-I','RSP-I',
|
446 |
'BLA-I','ACB-I','AId-I','ECT-I',
|
447 |
'ACB-C','ECT-C','CP-C','AId-C','RSP-C',
|
|
|
465 |
observeEvent(input$target_3d,{
|
466 |
waiter::Waiter$new(id = "spatial_subtype", color="black")$show()
|
467 |
output$spatial_subtype <- renderRglwidget({
|
468 |
+
if (input$target_3d %in% c("ITi-M1","ITi-M2","ITc-M3", "PTi")){
|
469 |
df_plot <- [email protected][which(sp.PFC$Proj_module==input$target_3d),]
|
470 |
}else{
|
471 |
df_plot <- [email protected][which([email protected][,input$target_3d] > 0),]
|