
Apply a pipeline independently to each group of a SingleCells object
apply_pipeline_per_group.RdSplits object by group_col, applies pipeline to each subset, and
returns a named list of processed SingleCellsSubsets. Useful for
per-sample / per-cell-type re-analysis where the same chain (HVG, PCA,
neighbours, clusters, ...) is run on each group, e.g. sample-pure metacell
generation followed by an external merge.
Value
Named list of processed objects, names being the group values.
Usually SingleCellsSubset, or MetaCells if the pipeline ends on
step_metacells_sc(), in which case merge_meta_cells() puts them back
together.
Examples
# the same chain re-run inside each cell type
sc <- demo_single_cells(prepped = FALSE)
p <- sc_pipeline() %>>% step_hvg_sc(hvg_no = 20L, .verbose = FALSE)
res <- apply_pipeline_per_group(p, sc, group_col = "cell_grp")
names(res)
#> [1] "cell_type_1" "cell_type_2" "cell_type_3"
unlink(sc@dir_data, recursive = TRUE, force = TRUE)