-
Notifications
You must be signed in to change notification settings - Fork 1
/
Box_plot_from_seurat.R
31 lines (24 loc) · 1.06 KB
/
Box_plot_from_seurat.R
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
#pull GEX from seurat obj (mine is all)
gex <- t(all@assays[["RNA"]]@data) %>% as.data.frame()
head(gex)
#add any meta.data you want to plot
gex$named <- all$named_niches
gex$condition <- all$condition
#get colors (optional)
cols <- as.data.frame(ArchR::paletteDiscrete([email protected][, "named_niches"]))
colnames(cols) <- "colors"
library(tidyverse)
#plot. No outliers and no whiskers
gex %>%
pivot_longer(cols = gene,
names_to = "gene",
values_to = "expression") %>%
ggplot(aes(x=gene, y=expression, fill=named))+
geom_boxplot(outlier.shape = NA, coef = 0)+facet_wrap(~ condition)+theme_minimal()+ylim(0,2000)+theme(axis.ticks = element_blank())+scale_fill_manual(values=cols$colors)
#plot. With outliers and with whiskers
gex %>%
pivot_longer(cols = gene,
names_to = "gene",
values_to = "expression") %>%
ggplot(aes(x=gene, y=expression, fill=named))+
geom_boxplot()+facet_wrap(~ condition)+theme_minimal()+ylim(0,2000)+theme(axis.ticks = element_blank())+scale_fill_manual(values=cols$colors)