-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfigure_4.Rmd
executable file
·129 lines (101 loc) · 3.26 KB
/
figure_4.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
---
title: 'Figure 4'
output: pdf_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
knitr::opts_knit$set(root.dir='/local1/USERS/jfleck/data/PUBLIC_ORGANOIDS')
```
This notebook reproduces the main analyses from figure 4 of the manuscript. First we import the necessary packages.
```{r message=FALSE, warning=FALSE, results='hide'}
library(voxhunt)
library(tidyverse)
library(Seurat)
```
Now we load the data. The loaded seurat object contains the neuronal popultions of the datasets shown in the manuscript. We further subset the ones shown in figure 2.
```{r}
load_aba_data('voxhunt_data/')
neurons <- read_rds('combined_neurons_srt.rds')
neurons <- subset(neurons, orig.ident%in%c('cerebral', 'hCS', 'hSS', 'tanaka_thalamus'))
neurons <- subset(neurons,
cluster%in%c('mesen_ex_cerebral', 'mesen_in_cerebral', 'ctx_ex_cerebral',
'ge_in_cerebral', 'dien_ex_cerebral', 'ge_hss', 'ctx_hcs', 'dien_tho')
)
print(unique(neurons$cluster))
```
We can see that `cluster` already captures the different neuronal types we are interested in. Now we select some structure markers.
```{r}
struct_markers <- structure_markers('E13', 'custom_3')
genes_use <- struct_markers %>%
group_by(group) %>%
top_n(10, auc) %>%
pull(gene) %>% unique()
print(head(genes_use))
```
Now we run VoxHunt using these genes
```{r, fig.height=3, fig.width=5}
neuron_voxmap <- voxel_map(
neurons,
group_name='cluster',
genes_use=genes_use
)
plot_map(neuron_voxmap) & no_legend()
```
As shown in the figure, we can also plot coronal slices. We can first pick the slices from the annotated map.
```{r, fig.width=8, fig.height=3}
voxhunt::plot_annotation('E13', show_coordinates = T, show_legend = T)
```
Now we plot slices 6, 11, 23 and 28
```{r, fig.height=7, fig.width=5}
voxhunt::plot_map(neuron_voxmap, view='slice', slices=c(6, 11, 23, 28)) &
no_legend()
```
```{r, include=F, results='hide'}
## Struct ape paper
struct_names <- c(
'pallium',
'subpallium',
'preoptic telencephalon',
'hypothalamus',
'diencephalon',
'midbrain',
'hindbrain',
'NA'
)
struct_colors <- c(
'#ad1457',
'#7b1fa2',
'#5e35b1',
'#ba68c8',
'#303f9f',
'#0097a7',
'#43a047',
'gray'
)
names(struct_colors) <- struct_names
```
Now we can also assign each cell to the highest correlating structure, similar as shown in figure 2.
```{r, fig.height=4, fig.width=6}
cell_assign <- assign_cells(neuron_voxmap)
cell_meta <- as_tibble([email protected], rownames='cell') %>%
dplyr::select(-stage) %>%
dplyr::inner_join(cell_assign) %>%
# dplyr::filter(custom_2!='medullary hindbrain') %>%
dplyr::mutate(struct_name=case_when(
str_detect(custom_2, 'hindbrain') ~ 'hindbrain',
str_detect(custom_4, 'septum|subpall|striatum|amygda|telencephalic') ~ 'subpallium',
str_detect(custom_2, 'telen') ~ 'pallium',
TRUE ~ custom_2
))
ggplot(cell_meta, aes(UMAP1, UMAP2, color=struct_name)) +
geom_point(size=0.2) +
facet_wrap(~dataset) +
scale_color_manual(values=struct_colors) +
theme_void()
```
```{r, fig.height=2, fig.width=4}
ggplot(cell_meta, aes(cluster, fill=struct_name)) +
geom_bar(position='fill') +
coord_flip() +
scale_fill_manual(values=struct_colors)
```