As well as importing expression matrices into
compare_pathways
, you can also compare populations directly
within a Seurat or SingleCellExperiment object in one function within
SCPA. To do this, you just need the Seurat/SCE object that is annotated
with the groups you want to compare.
Let’s load in a few packages.
We’re going to do the same comparison of Th1 and Tcm cells that we did in the quick start tutorial, again using all Hallmark gene sets. We’ll use the Szabo, P… Sims, P T cell dataset that you can download here.
t_cells <- readRDS("szabo_t_cell.rds")
We need to define our gene sets, and we can do this through the msigdbr package that contains a bunch of biological gene sets that can be found here. Here we just take the Hallmark gene sets (using the “H” call to msigdbr), and use the format_pathways function to get them in a readable format for SCPA.
pathways <- msigdbr("Homo sapiens", "H") %>%
format_pathways()
Now to compare the Th1 and Tcm populations, we can use the
compare_seurat function within SCPA. Here, group1
defines
the column name for your metadata, and group1_population
defines two values within that column. N.B. We’re going to compare
populations within a Seurat object here, but it’s the same set up for a
SCE object using the compare_sce
function.
scpa_out <- compare_seurat(t_cells,
group1 = "cell",
group1_population = c("cd4 th1", "cd4 tcm"),
pathways = pathways)
# For faster analysis with parallel processing, use 'parallel = TRUE' and 'cores = x' arguments
And that’s it. Your results will be stored in your
scpa_out
object.