7171# ' @importFrom dplyr select
7272# '
7373# ' @export
74- # ' @example Do not run: moduleScore(object = seuratObject,
75- # ' marker.table = immuneCellMarkers,
76- # ' celltypes = c("CD4_T","Treg",Monocytes"),
77- # ' ms_threshold = c("CD4_T 0.1","Treg 0.4", "Monocytes 0.3"),
78- # ' multi.lvl = FALSE
79- # ' )
80- # '
81- # ' @example Do not run: moduleScore(object = seuratObject,
82- # ' marker.table = immuneCellMarkers,
83- # ' celltypes = c("CD4_T","Treg",Monocytes"),
84- # ' ms_threshold = c("CD4_T 0.1","Treg 0.4", "Monocytes 0.3"),
85- # ' general.class = c("CD_T","Monocytes"),
86- # ' multi.lvl = TRUE,
87- # ' lvl.df = parentChildTable
88- # ' )
74+ # ' @examples
75+ # ' \dontrun{
76+ # ' modScore(
77+ # ' object = seuratObject,
78+ # ' marker.table = immuneCellMarkers,
79+ # ' use_columns = c("CD4_T", "Treg", "Monocytes"),
80+ # ' ms_threshold = c("CD4_T 0.1", "Treg 0.4", "Monocytes 0.3"),
81+ # ' general.class = c("CD4_T", "Monocytes"),
82+ # ' multi.lvl = FALSE
83+ # ' )
84+ # '
85+ # ' modScore(
86+ # ' object = seuratObject,
87+ # ' marker.table = immuneCellMarkers,
88+ # ' use_columns = c("CD4_T", "Treg", "Monocytes"),
89+ # ' ms_threshold = c("CD4_T 0.1", "Treg 0.4", "Monocytes 0.3"),
90+ # ' general.class = c("CD4_T", "Monocytes"),
91+ # ' multi.lvl = TRUE,
92+ # ' lvl.df = parentChildTable
93+ # ' )
94+ # ' }
8995
9096# ' @return List containing annotated dimension plot with ModuleScore
9197# ' distribution of cell marker gene, Seurat Object with cell
9298# ' classification metadata
9399
94100modScore <- function (object ,
95101 marker.table ,
102+ group_var = " orig.ident" ,
96103 use_columns ,
97104 ms_threshold ,
98105 general.class ,
@@ -231,7 +238,7 @@ modScore <- function(object,
231238 umap.pos <- clusmat %> % group_by(clusid ) %> % dplyr :: summarise(umap1.mean = mean(umap1 ), umap2.mean = mean(umap2 ))
232239 title = as.character(m )
233240 clusmat <- clusmat %> % dplyr :: arrange(clusid )
234- clusid.df <- data.frame (id = object @ meta.data $ orig.ident ,
241+ clusid.df <- data.frame (id = object @ meta.data [[ group_var ]] ,
235242 ModuleScore = object @ meta.data [[m ]])
236243
237244 g <- ggplot(clusmat , aes(x = umap1 , y = umap2 )) + theme_bw() +
@@ -240,7 +247,7 @@ modScore <- function(object,
240247 1 ), limits = c(0 , 1 ))) + guides(colour = guide_legend(override.aes = list (size = 5 , alpha = 1 ))) + theme(panel.grid.major = element_blank(),
241248 panel.grid.minor = element_blank(), panel.background = element_blank()) + xlab(" tsne-1" ) + ylab(" tsne-2" )
242249
243- g1 <- RidgePlot(object , features = m , group.by = " orig.ident " ) +
250+ g1 <- RidgePlot(object , features = m , group.by = group_var ) +
244251 theme(legend.position = " none" , title = element_blank(),
245252 axis.text.x = element_text(size = gradient.ft.size )) +
246253 geom_vline(xintercept = numeric_threshold [celltype_name ], linetype = " dashed" ,
0 commit comments