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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
|
| 90 |
|
| 91 |
|
|
|
|
| 86 |
</p>
|
| 87 |
|
| 88 |
|
| 89 |
+
```{r}
|
| 90 |
+
#| context: setup
|
| 91 |
+
#| warning: false
|
| 92 |
+
#| message: false
|
| 93 |
+
|
| 94 |
+
library(ggplot2)
|
| 95 |
+
library(Seurat)
|
| 96 |
+
library(shiny)
|
| 97 |
+
library(rgl)
|
| 98 |
+
library(ggdark)
|
| 99 |
+
library(viridis)
|
| 100 |
+
library(dplyr)
|
| 101 |
+
|
| 102 |
+
source("R/Palettes.R")
|
| 103 |
+
source('R/includes.R')
|
| 104 |
+
Adult.Ex <- readRDS('data/Adult.Ex.rds')
|
| 105 |
+
sp.PFC <- readRDS('data/sp.PFC.rds')
|
| 106 |
+
sp.PFC$PTi[is.na(sp.PFC$PTi)] <- 0
|
| 107 |
+
sp.PFC$ITi_D[is.na(sp.PFC$ITi_D)] <- 0
|
| 108 |
+
sp.PFC$ITi_V[is.na(sp.PFC$ITi_V)] <- 0
|
| 109 |
+
sp.PFC$ITc[is.na(sp.PFC$ITc)] <- 0
|
| 110 |
+
sp.PFC$Proj_module[which(sp.PFC$Proj_module=="ITi-D")] <- "ITi-M1"
|
| 111 |
+
sp.PFC$Proj_module[which(sp.PFC$Proj_module=="ITi-V")] <- "ITi-M2"
|
| 112 |
+
sp.PFC$Proj_module[which(sp.PFC$Proj_module=="ITc")] <- "ITc-M3"
|
| 113 |
+
colnames(sp.PFC@meta.data)[match(c("ITi_D","ITi_V","ITc"),colnames(sp.PFC@meta.data))] <- c("ITi-M1","ITi-M2","ITc-M3")
|
| 114 |
+
|
| 115 |
+
|
| 116 |
+
clean_cells <- colnames(Adult.Ex)[!(
|
| 117 |
+
(Adult.Ex$Ex_subtype %in% c("CT","NP") & Adult.Ex$BC_num>0) |
|
| 118 |
+
(Adult.Ex$sample %in% c("Adult2","Adult3") & Adult.Ex$Ex_subtype=="PT" & Adult.Ex$BC_num>0)
|
| 119 |
+
)]
|
| 120 |
+
Adult.Ex.clean <- subset(Adult.Ex, cells = clean_cells)
|
| 121 |
+
Adult.Ex.clean$Proj_module[which(Adult.Ex.clean$Proj_module=="ITi-D")] <- "ITi-M1"
|
| 122 |
+
Adult.Ex.clean$Proj_module[which(Adult.Ex.clean$Proj_module=="ITi-V")] <- "ITi-M2"
|
| 123 |
+
Adult.Ex.clean$Proj_module[which(Adult.Ex.clean$Proj_module=="ITc")] <- "ITc-M3"
|
| 124 |
+
colnames(Adult.Ex.clean@meta.data)[match(c("ITi_D_score", "ITi_V_score", "ITc_score", "PTi_score"),colnames(Adult.Ex.clean@meta.data))] <- c("ITi-M1", "ITi-M2","ITc-M3","PTi")
|
| 125 |
+
|
| 126 |
+
options(rgl.useNULL = TRUE)
|
| 127 |
+
```
|
| 128 |
+
|
| 129 |
+
|
| 130 |
+
|
| 131 |
+
|
| 132 |
+
|
| 133 |
+
# scRNAseq {scrolling="true"}
|
| 134 |
+
|
| 135 |
+
## {.sidebar}
|
| 136 |
+
|
| 137 |
+
```{r}
|
| 138 |
+
selectInput('cluster', 'Select Cluster', c("SubType_Layer","SubType"))
|
| 139 |
+
```
|
| 140 |
+
|
| 141 |
+
```{r}
|
| 142 |
+
selectInput('gene', 'Select Gene', rownames(Adult.Ex),
|
| 143 |
+
selected = "Cux2")
|
| 144 |
+
```
|
| 145 |
+
|
| 146 |
+
```{r}
|
| 147 |
+
Barcode <- c(
|
| 148 |
+
"ITi-M1", "ITi-M2", "ITc-M3", "PTi",
|
| 149 |
+
'VIS-I','SSp-I','CP-I','AUD-I','RSP-I',
|
| 150 |
+
'BLA-I','ACB-I','ENTl-I','AId-I','ECT-I',
|
| 151 |
+
'ACB-C','PL-C','ECT-C','ENTl-C',
|
| 152 |
+
'BLA-C','CP-C','AId-C','RSP-C',
|
| 153 |
+
'MD-I','RE-I','DR-I','VTA-I','LHA-I','SC-I')
|
| 154 |
+
selectInput('target', 'Select Target', Barcode, selected = "CP-I")
|
| 155 |
+
```
|
| 156 |
+
|
| 157 |
+
|
| 158 |
+
## Column
|
| 159 |
+
|
| 160 |
+
### Row
|
| 161 |
+
|
| 162 |
+
#### Column
|
| 163 |
+
|
| 164 |
+
```{r}
|
| 165 |
+
plotOutput('cluster_plot')
|
| 166 |
+
```
|
| 167 |
+
|
| 168 |
+
#### Column
|
| 169 |
+
|
| 170 |
+
```{r}
|
| 171 |
+
plotOutput('gene_plot')
|
| 172 |
+
```
|
| 173 |
+
|
| 174 |
+
### Row
|
| 175 |
+
|
| 176 |
+
#### Column
|
| 177 |
+
|
| 178 |
+
```{r}
|
| 179 |
+
plotOutput('target_plot')
|
| 180 |
+
```
|
| 181 |
+
|
| 182 |
+
#### Column
|
| 183 |
+
|
| 184 |
+
```{r}
|
| 185 |
+
plotOutput('target_bar_plot')
|
| 186 |
+
```
|
| 187 |
+
|
| 188 |
+
|
| 189 |
+
```{r}
|
| 190 |
+
#| context: server
|
| 191 |
+
|
| 192 |
+
output$cluster_plot <- renderPlot({
|
| 193 |
+
DimPlot(
|
| 194 |
+
Adult.Ex,
|
| 195 |
+
reduction = 'umap',
|
| 196 |
+
group.by = input$cluster,
|
| 197 |
+
cols = col_cluster[[input$cluster]],
|
| 198 |
+
label = T
|
| 199 |
+
) +
|
| 200 |
+
coord_fixed()
|
| 201 |
+
})
|
| 202 |
+
|
| 203 |
+
output$gene_plot <- renderPlot({
|
| 204 |
+
FeaturePlot(
|
| 205 |
+
Adult.Ex,
|
| 206 |
+
features = input$gene) +
|
| 207 |
+
coord_fixed()
|
| 208 |
+
})
|
| 209 |
+
|
| 210 |
+
output$target_plot <- renderPlot({
|
| 211 |
+
Barcode <- c(
|
| 212 |
+
"ITi-M1", "ITi-M2","ITc-M3","PTi",
|
| 213 |
+
'VIS-I','SSp-I','CP-I','AUD-I','RSP-I',
|
| 214 |
+
'BLA-I','ACB-I','ENTl-I','AId-I','ECT-I',
|
| 215 |
+
'ACB-C','PL-C','ECT-C','ENTl-C',
|
| 216 |
+
'BLA-C','CP-C','AId-C','RSP-C',
|
| 217 |
+
'MD-I','RE-I','DR-I','VTA-I','LHA-I','SC-I'
|
| 218 |
+
)
|
| 219 |
+
seu <- Adult.Ex.clean
|
| 220 |
+
seu@meta.data[,Barcode][is.na(seu@meta.data[,Barcode])] <- 0
|
| 221 |
+
FeaturePlot(
|
| 222 |
+
seu, features = input$target, order = T) +
|
| 223 |
+
coord_fixed()
|
| 224 |
+
})
|
| 225 |
+
|
| 226 |
+
output$target_bar_plot <- renderPlot({
|
| 227 |
+
seu <- Adult.Ex.clean
|
| 228 |
+
if (input$target %in% c("ITi-M1", "ITi-M2","ITc-M3","PTi")){
|
| 229 |
+
df <- as.data.frame(table(seu@meta.data[,input$cluster][which(seu$Proj_module==input$target)]))
|
| 230 |
+
}else{
|
| 231 |
+
df <- as.data.frame(table(seu@meta.data[,input$cluster][which(seu@meta.data[,input$target]>0)]))
|
| 232 |
+
}
|
| 233 |
+
colnames(df) <- c("Celltypes","Cellnum")
|
| 234 |
+
|
| 235 |
+
ggplot(df, aes(x=Celltypes, y=Cellnum, fill=Celltypes)) +
|
| 236 |
+
geom_col() +
|
| 237 |
+
scale_fill_manual(values = col_cluster[[input$cluster]]) +
|
| 238 |
+
theme_classic() +
|
| 239 |
+
theme(axis.text.x = element_text(angle = 25, hjust = 1),
|
| 240 |
+
plot.title = element_text(hjust = 0.5)) +
|
| 241 |
+
labs(title = paste("PFC → ",input$target," cell numbers in different cell type",
|
| 242 |
+
sep=""))
|
| 243 |
+
})
|
| 244 |
+
```
|
| 245 |
+
|
| 246 |
+
|
| 247 |
+
|
| 248 |
+
|
| 249 |
+
|
| 250 |
+
# Spatial {scrolling="true"}
|
| 251 |
+
|
| 252 |
+
## {.sidebar}
|
| 253 |
+
|
| 254 |
+
```{r}
|
| 255 |
+
selectInput('sp_slice', 'Select Slice', unique(sp.PFC$slice),
|
| 256 |
+
selected = "IT_slice_10")
|
| 257 |
+
```
|
| 258 |
+
|
| 259 |
+
```{r}
|
| 260 |
+
selectInput('sp_cluster', 'Select Cluster', c("SubType_Layer","SubType"))
|
| 261 |
+
```
|
| 262 |
+
|
| 263 |
+
```{r}
|
| 264 |
+
selectInput('sp_gene', 'Select Gene', rownames(sp.PFC),
|
| 265 |
+
selected = "Cux2")
|
| 266 |
+
```
|
| 267 |
+
|
| 268 |
+
```{r}
|
| 269 |
+
sp_Barcode <- c(
|
| 270 |
+
"ITi-M1", "ITi-M2","ITc-M3","PTi",
|
| 271 |
+
'VIS-I','SSp-I','CP-I','AUD-I','RSP-I',
|
| 272 |
+
'BLA-I','ACB-I','AId-I','ECT-I',
|
| 273 |
+
'ACB-C','ECT-C','CP-C','AId-C','RSP-C',
|
| 274 |
+
'LHA-I')
|
| 275 |
+
selectInput('sp_target', 'Select Target', sp_Barcode)
|
| 276 |
+
```
|
| 277 |
+
|
| 278 |
+
|
| 279 |
+
## Column
|
| 280 |
+
|
| 281 |
+
### Row
|
| 282 |
+
|
| 283 |
+
#### Column
|
| 284 |
+
|
| 285 |
+
```{r}
|
| 286 |
+
#| fig-width: 10
|
| 287 |
+
|
| 288 |
+
plotOutput('sp_cluster_plot')
|
| 289 |
+
```
|
| 290 |
+
|
| 291 |
+
#### Column
|
| 292 |
+
|
| 293 |
+
```{r}
|
| 294 |
+
#| fig-width: 10
|
| 295 |
+
|
| 296 |
+
plotOutput('sp_gene_plot')
|
| 297 |
+
```
|
| 298 |
+
|
| 299 |
+
### Row
|
| 300 |
+
|
| 301 |
+
#### Column
|
| 302 |
+
|
| 303 |
+
```{r}
|
| 304 |
+
#| fig-width: 10
|
| 305 |
+
|
| 306 |
+
plotOutput('sp_target_plot')
|
| 307 |
+
```
|
| 308 |
+
|
| 309 |
+
#### Column
|
| 310 |
+
|
| 311 |
+
```{r}
|
| 312 |
+
#| fig-width: 10
|
| 313 |
+
|
| 314 |
+
plotOutput('sp_target_line_plot')
|
| 315 |
+
```
|
| 316 |
+
|
| 317 |
+
```{r}
|
| 318 |
+
#| context: server
|
| 319 |
+
|
| 320 |
+
output$sp_cluster_plot <- renderPlot({
|
| 321 |
+
df <- data.frame(
|
| 322 |
+
x = sp.PFC$ML_new[sp.PFC$slice==input$sp_slice],
|
| 323 |
+
y = sp.PFC$DV_new[sp.PFC$slice==input$sp_slice],
|
| 324 |
+
type = sp.PFC@meta.data[sp.PFC$slice==input$sp_slice, input$sp_cluster]
|
| 325 |
+
)
|
| 326 |
+
ggplot(df, aes(x=x, y=y, color=type)) +
|
| 327 |
+
geom_point(size=1) +
|
| 328 |
+
scale_color_manual(values = col_cluster[[input$sp_cluster]]) +
|
| 329 |
+
labs(title = paste(input$slice,'Cell types in spatial')) +
|
| 330 |
+
guides(color=guide_legend(nrow = 2, byrow = TRUE, reverse = T,
|
| 331 |
+
override.aes = list(size=2))) +
|
| 332 |
+
coord_fixed() +
|
| 333 |
+
ggdark::dark_theme_void() +
|
| 334 |
+
theme(plot.title = element_text(size = 20, hjust = 0.5),
|
| 335 |
+
legend.position = 'bottom', legend.title=element_blank(),
|
| 336 |
+
legend.text = element_text(size=10))
|
| 337 |
+
})
|
| 338 |
+
|
| 339 |
+
output$sp_gene_plot <- renderPlot({
|
| 340 |
+
df <- data.frame(
|
| 341 |
+
X = sp.PFC$ML_new,
|
| 342 |
+
Y = sp.PFC$DV_new,
|
| 343 |
+
Zscore = scale(log1p(sp.PFC@assays$RNA@counts[input$sp_gene,]))
|
| 344 |
+
)
|
| 345 |
+
df <- df[which(sp.PFC$slice==input$sp_slice),]
|
| 346 |
+
df$Zscore[df$Zscore<0] <- 0
|
| 347 |
+
df$Zscore[df$Zscore>3] <- 3
|
| 348 |
+
df <- df[order(df$Zscore),]
|
| 349 |
+
ggplot(df,aes(x=X,y=Y)) +
|
| 350 |
+
geom_point(aes(colour=Zscore), size=1) +
|
| 351 |
+
scale_color_gradientn(colours = viridis(n = 256, option = "D", direction = 1),
|
| 352 |
+
limits = c(0,3)) +
|
| 353 |
+
ggdark::dark_theme_void() +
|
| 354 |
+
labs(title = input$sp_gene) +
|
| 355 |
+
theme(plot.title = element_text(size = 20, hjust = 0.5),
|
| 356 |
+
legend.position = 'bottom') +
|
| 357 |
+
coord_fixed()
|
| 358 |
+
})
|
| 359 |
+
|
| 360 |
+
output$sp_target_plot <- renderPlot({
|
| 361 |
+
df <- data.frame(
|
| 362 |
+
X = sp.PFC$ML_new,
|
| 363 |
+
Y = sp.PFC$DV_new,
|
| 364 |
+
Zscore = scale(log1p(sp.PFC@meta.data[,input$sp_target]))
|
| 365 |
+
)
|
| 366 |
+
df <- df[which(sp.PFC$slice==input$sp_slice),]
|
| 367 |
+
df$Zscore[df$Zscore<0] <- 0
|
| 368 |
+
df$Zscore[df$Zscore>3] <- 3
|
| 369 |
+
df <- df[order(df$Zscore),]
|
| 370 |
+
ggplot(df, aes(x=X,y=Y)) +
|
| 371 |
+
geom_point(aes(colour=Zscore), size=1) +
|
| 372 |
+
scale_color_gradientn(colours = viridis(n = 256, option = "E", direction = 1)) +
|
| 373 |
+
ggdark::dark_theme_void() +
|
| 374 |
+
labs(title = input$sp_target) +
|
| 375 |
+
theme(plot.title = element_text(size = 20, hjust = 0.5),
|
| 376 |
+
legend.position = 'bottom') +
|
| 377 |
+
coord_fixed()
|
| 378 |
+
})
|
| 379 |
+
|
| 380 |
+
output$sp_target_line_plot <- renderPlot({
|
| 381 |
+
# AP
|
| 382 |
+
seu <- subset(sp.PFC, cells=colnames(sp.PFC)[which(sp.PFC$ABA_hemisphere=="Left")])
|
| 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] & seu@meta.data[,input$sp_target]>0))/length(which(seu$slice==slice[i] & seu$BC_num>0))
|
| 390 |
+
}
|
| 391 |
+
}
|
| 392 |
+
df$x <- c(1:36)
|
| 393 |
+
p1 <- ggplot(df, aes(x=x, y=cellnum)) +
|
| 394 |
+
geom_point(alpha=0.5, size=3, color=col_subtype_target[input$sp_target]) +
|
| 395 |
+
geom_smooth(se = F, linewidth=1.5, color=col_subtype_target[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='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 <- seu@meta.data[,c(sp_Barcode, 'Y','BC_num')]
|
| 410 |
+
bc_slice <-
|
| 411 |
+
bc_slice |>
|
| 412 |
+
mutate(bin = cut(Y, breaks = 36))
|
| 413 |
+
bin <- sort(unique(bc_slice$bin))
|
| 414 |
+
bc_slice$bin_index <- match(bc_slice$bin, bin)
|
| 415 |
+
df <- data.frame('bin_index'=c(1:36))
|
| 416 |
+
for (i in 1:36){
|
| 417 |
+
df$cellnum[i] <- length(which(bc_slice$bin_index==i &
|
| 418 |
+
bc_slice[,input$sp_target]>0))/
|
| 419 |
+
length(which(bc_slice$bin_index==i & bc_slice$BC_num>0))
|
| 420 |
+
}
|
| 421 |
+
df$x <- c(1:36)
|
| 422 |
+
p2 <- ggplot(df, aes(x=x, y=cellnum)) +
|
| 423 |
+
geom_point(alpha=0.5, size=3, color=col_subtype_target[input$sp_target]) +
|
| 424 |
+
geom_smooth(se = F, linewidth=1.5, color=col_subtype_target[input$sp_target]) +
|
| 425 |
+
theme_bw() +
|
| 426 |
+
scale_x_continuous(breaks = seq(0,35,5)) +
|
| 427 |
+
theme(text = element_text(size=15),
|
| 428 |
+
plot.title = element_text(size = 20, hjust = 0.5)) +
|
| 429 |
+
labs(x='V → D',y='Cell proportion')
|
| 430 |
+
p1/p2
|
| 431 |
+
})
|
| 432 |
+
```
|
| 433 |
+
|
| 434 |
+
|
| 435 |
+
|
| 436 |
+
|
| 437 |
+
|
| 438 |
+
|
| 439 |
+
# 3D
|
| 440 |
+
|
| 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',
|
| 448 |
+
'LHA-I')
|
| 449 |
+
waiter::use_waiter()
|
| 450 |
+
selectInput('subtype_3d', 'Select SubType', sort(unique(sp.PFC$SubType)))
|
| 451 |
+
selectInput('target_3d', 'Select Target', sp_Barcode, selected = "PTi")
|
| 452 |
+
```
|
| 453 |
+
|
| 454 |
+
|
| 455 |
+
## Column
|
| 456 |
+
|
| 457 |
+
```{r}
|
| 458 |
+
rglwidgetOutput('spatial_subtype', width = "100%")
|
| 459 |
+
```
|
| 460 |
+
|
| 461 |
+
|
| 462 |
+
```{r}
|
| 463 |
+
#| context: server
|
| 464 |
+
|
| 465 |
+
observeEvent(input$subtype_3d,{
|
| 466 |
+
waiter::Waiter$new(id = "spatial_subtype", color="black")$show()
|
| 467 |
+
output$spatial_subtype <- renderRglwidget({
|
| 468 |
+
df_plot <- sp.PFC@meta.data[which(sp.PFC$SubType == input$subtype_3d),]
|
| 469 |
+
|
| 470 |
+
open3d()
|
| 471 |
+
bg3d(color = "black")
|
| 472 |
+
par3d(userMatrix = rotationMatrix(-pi/6, -1, 1, 0), zoom = 0.6)
|
| 473 |
+
acr.list <- c("MOs","PL","ORBm","ACAd","ILA","DP","ACAv")
|
| 474 |
+
|
| 475 |
+
for(acr in acr.list){
|
| 476 |
+
mesh <- mesh3d.allen.annot.from.id(get.id.from.acronym(acr))
|
| 477 |
+
col <- "lightgray"
|
| 478 |
+
shade3d(mesh, col = col, material = list(lit=FALSE), alpha = 0.1)
|
| 479 |
+
}
|
| 480 |
+
|
| 481 |
+
spheres3d(x = df_plot$ML_new,
|
| 482 |
+
y = df_plot$DV_new,
|
| 483 |
+
z = df_plot$AP_new,
|
| 484 |
+
col = col_subtype_target[input$subtype_3d], radius=0.01, alpha=1)
|
| 485 |
+
rglwidget()
|
| 486 |
+
})
|
| 487 |
+
})
|
| 488 |
+
|
| 489 |
+
|
| 490 |
+
observeEvent(input$target_3d,{
|
| 491 |
+
waiter::Waiter$new(id = "spatial_subtype", color="black")$show()
|
| 492 |
+
output$spatial_subtype <- renderRglwidget({
|
| 493 |
+
if (input$target_3d %in% c("ITi-M1","ITi-M2","ITc-M3", "PTi")){
|
| 494 |
+
df_plot <- sp.PFC@meta.data[which(sp.PFC$Proj_module==input$target_3d),]
|
| 495 |
+
}else{
|
| 496 |
+
df_plot <- sp.PFC@meta.data[which(sp.PFC@meta.data[,input$target_3d] > 0),]
|
| 497 |
+
}
|
| 498 |
+
|
| 499 |
+
open3d()
|
| 500 |
+
bg3d(color = "black")
|
| 501 |
+
par3d(userMatrix = rotationMatrix(-pi/6, -1, 1, 0), zoom = 0.6)
|
| 502 |
+
acr.list <- c("MOs","PL","ORBm","ACAd","ILA","DP","ACAv")
|
| 503 |
+
|
| 504 |
+
for(acr in acr.list){
|
| 505 |
+
mesh <- mesh3d.allen.annot.from.id(get.id.from.acronym(acr))
|
| 506 |
+
col <- "lightgray"
|
| 507 |
+
shade3d(mesh, col = col, material = list(lit=FALSE), alpha = 0.1)
|
| 508 |
+
}
|
| 509 |
+
|
| 510 |
+
spheres3d(x = df_plot$ML_new,
|
| 511 |
+
y = df_plot$DV_new,
|
| 512 |
+
z = df_plot$AP_new,
|
| 513 |
+
col = col_subtype_target[input$target_3d], radius=0.01, alpha=1)
|
| 514 |
+
rglwidget()
|
| 515 |
+
})
|
| 516 |
+
})
|
| 517 |
+
```
|
| 518 |
+
|
| 519 |
+
|
| 520 |
+
|
| 521 |
+
|
| 522 |
+
# Download
|
| 523 |
+
|
| 524 |
+
<p style="font-size: 20px; text-align: justify;">
|
| 525 |
+
The raw single cell RNA-seq data are available from GEO (<a href="https://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=GSE273066">GSE273066</a>).
|
| 526 |
+
</p>
|
| 527 |
+
|
| 528 |
+
<p style="font-size: 20px; text-align: justify;">
|
| 529 |
+
The raw image data for this study are available via Hugging Face at <a href="https://huggingface.co/TigerZheng/SPIDER-STdata">TigerZheng/SPIDER-STdata</a>. You can download and unzip the .zip file and then use <a href="https://github.com/hms-dbmi/viv">viv</a> to visualize our raw data.
|
| 530 |
+
An example: <a href="https://avivator.gehlenborglab.org/?image_url=https://huggingface.co/TigerZheng/SPIDER-STdata/resolve/main/IT_slice_36_reordered.ome.tiff">IT_slice_36</a>.</p>
|
| 531 |
+
|
| 532 |
+
<p style="font-size: 20px; text-align: justify;">
|
| 533 |
+
The processed data can be downloaded here:</p>
|
| 534 |
+
|
| 535 |
+
- All cells data: <a href="https://huggingface.co/spaces/TigerZheng/SPIDER-web/resolve/main/data/all.Adult.rds?download=true">all.Adult.rds</a>
|
| 536 |
+
- Excitatory data: <a href="https://huggingface.co/spaces/TigerZheng/SPIDER-web/resolve/main/data/Adult.Ex.rds?download=true">Adult.Ex.rds</a>
|
| 537 |
+
- Spatial data: <a href="https://huggingface.co/spaces/TigerZheng/SPIDER-web/resolve/main/data/sp.PFC.rds?download=true">sp.PFC.rds</a>
|
| 538 |
|
| 539 |
|
| 540 |
|