-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathplotExpressionCustom.R
34 lines (30 loc) · 1.39 KB
/
plotExpressionCustom.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
32
33
34
## TEST
# test_markers <- list(A = paste0("Gene_000", 1:4),
# B = paste0("Gene_000", 5:8))
#
# plotExpressionCustom(sce = example_sce, features = test_markers$A, "A", anno_name = "Cell_Cycle")
plotExpressionCustom <- function(sce, features, features_name, anno_name = "cellType",
point_alpha=0.2, point_size=0.7, ncol=2, xlab = NULL,
exprs_values = "logcounts", scales = "fixed"){
scater::plotExpression(sce,
exprs_values = exprs_values,
features = features,
x = anno_name,
colour_by = anno_name,
ncol = ncol,
xlab = xlab,
point_alpha = point_alpha,
point_size = point_size,
add_legend = F,
scales = scales) +
stat_summary(fun = median,
fun.min = median,
fun.max = median,
geom = "crossbar",
width = 0.3) +
theme(axis.text.x = element_text(angle = 90, hjust = 1),
strip.text = element_text(face = "italic")) +
ggtitle(label=paste0(features_name, " markers"))
}
# MNT note: if want to add a custom title, just call this function and can 'overwrite' that with
# another `+ ggtitle(...)`