TigerZheng commited on
Commit
f282c74
·
verified ·
1 Parent(s): 4a4a37e

Update PFCapp.qmd

Browse files
Files changed (1) hide show
  1. PFCapp.qmd +68 -39
PFCapp.qmd CHANGED
@@ -4,7 +4,7 @@ author: "Cao Lab"
4
  server: shiny
5
  format:
6
  dashboard:
7
- logo: https://zhenghu159.github.io/picx-images-hosting/PFCapp/Logo.1756dx3zx7.webp
8
  nav-buttons:
9
  - icon: github
10
  href: https://github.com/GangCaoLab/mPFC-web
@@ -319,6 +319,8 @@ output$sp_gene_plot <- renderPlot({
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) +
@@ -332,13 +334,18 @@ output$sp_gene_plot <- renderPlot({
332
 
333
  output$sp_target_plot <- renderPlot({
334
  seu <- sp.PFC
335
- seu@meta.data[,c("PTi","ITi_D","ITi_V","ITc")][is.na(seu@meta.data[,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(sp.PFC@meta.data[,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) +
@@ -413,7 +420,13 @@ output$sp_target_line_plot <- renderPlot({
413
  ## {.sidebar}
414
 
415
  ```{r}
416
- selectInput('subtype', 'Select SubType', sort(unique(sp.PFC$SubType)))
 
 
 
 
 
 
417
  ```
418
 
419
 
@@ -427,42 +440,58 @@ rglwidgetOutput('spatial_subtype', width = "100%")
427
  ```{r}
428
  #| context: server
429
 
430
- output$spatial_subtype <- renderRglwidget({
431
- open3d()
432
- bg3d(color = "black")
433
- par3d(userMatrix = rotationMatrix(-pi/6, -1, 1, 0), zoom = 0.6)
434
- acr.list <- c("MOs","PL","ORBm","ACAd","ILA","DP","ACAv")
435
- for(acr in acr.list){
436
- mesh <- mesh3d.allen.annot.from.id(get.id.from.acronym(acr))
437
- #to.del <- which(mesh$vb[1,] < 0)
438
- #to.del <- NA
439
- #mesh$it <- mesh$it[,!is.element(mesh$it[1,], to.del) & !is.element(mesh$it[2,], to.del) & !is.element(mesh$it[3,], to.del)]
440
- #col <- color.from.acronym(acr)
441
- col <- "lightgray"
442
- #col <- col_Region[acr]
443
- shade3d(mesh, col = col, material = list(lit=FALSE), alpha = 0.1)
444
- }
445
-
446
- df_plot <- [email protected][which(sp.PFC$SubType == input$subtype),]
447
-
448
- spheres3d(x = df_plot$ML_new,
449
- y = df_plot$DV_new,
450
- z = df_plot$AP_new,
451
- col = col_cluster[["SubType"]][input$subtype], radius=0.01, alpha=1)
452
- rglwidget()
 
 
453
  })
454
- ```
455
-
456
-
457
-
458
-
459
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
460
 
461
- # raw image
462
 
463
- ```{=html}
464
- <iframe src="https://avivator.gehlenborglab.org/?image_url=https://huggingface.co/YAYUhuang/IT_Spatial_dataset/resolve/main/ITslice03.ome.tiff?rel=0&amp;autoplay=1" title="PFC" height="800" width="100%"></iframe>
465
- ```
466
 
467
 
468
 
 
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
 
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) +
 
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(seu@meta.data[,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) +
 
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
+ selectInput('subtype_3d', 'Select SubType', sort(unique(sp.PFC$SubType)))
429
+ selectInput('target_3d', 'Select Target', sp_Barcode)
430
  ```
431
 
432
 
 
440
  ```{r}
441
  #| context: server
442
 
443
+ observeEvent(input$target_3d,{
444
+ output$spatial_subtype <- renderRglwidget({
445
+ if (input$target_3d %in% c("ITi-D", "ITi-V", "ITc", "PTi")){
446
+ df_plot <- [email protected][which(sp.PFC$Proj_module==input$target_3d),]
447
+ }else{
448
+ df_plot <- [email protected][which([email protected][,input$target_3d] > 0),]
449
+ }
450
+
451
+ open3d()
452
+ bg3d(color = "black")
453
+ par3d(userMatrix = rotationMatrix(-pi/6, -1, 1, 0), zoom = 0.6)
454
+ acr.list <- c("MOs","PL","ORBm","ACAd","ILA","DP","ACAv")
455
+
456
+ for(acr in acr.list){
457
+ mesh <- mesh3d.allen.annot.from.id(get.id.from.acronym(acr))
458
+ col <- "lightgray"
459
+ shade3d(mesh, col = col, material = list(lit=FALSE), alpha = 0.1)
460
+ }
461
+
462
+ spheres3d(x = df_plot$ML_new,
463
+ y = df_plot$DV_new,
464
+ z = df_plot$AP_new,
465
+ col = col_subtype_target[input$target_3d], radius=0.01, alpha=1)
466
+ rglwidget()
467
+ })
468
  })
 
 
 
 
 
469
 
470
+ observeEvent(input$subtype_3d,{
471
+ output$spatial_subtype <- renderRglwidget({
472
+ df_plot <- [email protected][which(sp.PFC$SubType == input$subtype_3d),]
473
+
474
+ open3d()
475
+ bg3d(color = "black")
476
+ par3d(userMatrix = rotationMatrix(-pi/6, -1, 1, 0), zoom = 0.6)
477
+ acr.list <- c("MOs","PL","ORBm","ACAd","ILA","DP","ACAv")
478
+
479
+ for(acr in acr.list){
480
+ mesh <- mesh3d.allen.annot.from.id(get.id.from.acronym(acr))
481
+ col <- "lightgray"
482
+ shade3d(mesh, col = col, material = list(lit=FALSE), alpha = 0.1)
483
+ }
484
+
485
+ spheres3d(x = df_plot$ML_new,
486
+ y = df_plot$DV_new,
487
+ z = df_plot$AP_new,
488
+ col = col_subtype_target[input$subtype_3d], radius=0.01, alpha=1)
489
+ rglwidget()
490
+ })
491
+ })
492
+ ```
493
 
 
494
 
 
 
 
495
 
496
 
497