This function tests whether specific pathways are differentially enriched in particular cell types with cell types stored in a Seurat object. The function applies the Wilcoxon rank-sum test to compare the pathway scores between cells of a given cell type and all other cells. It supports parallel computation to speed up the testing process.

CAESAR.CTDEP(
  seu,
  pathway_scores,
  ident = NULL,
  cts = NULL,
  parallel = TRUE,
  ncores = 10,
  seed = 1
)

Arguments

seu

A Seurat object containing the single-cell RNA-seq data.

pathway_scores

A matrix of pathway scores where rows represent cells and columns represent different pathways.

ident

A character string specifying the column name in the Seurat object's metadata to use as the cell type labels. If NULL, the default identities (Idents(seu)) will be used. Default is NULL.

cts

A character vector specifying the cell types to test. If NULL, the function will test all unique cell types present in ident or Idents(seu). Default is NULL.

parallel

Logical, indicating whether to run the computation in parallel. Default is TRUE.

ncores

An integer specifying the number of cores to use for parallel computation. Default is 10.

seed

An integer specifying the random seed for reproducibility in parallel computation. Default is 1.

Value

A matrix of p-values where rows represent the pathways and columns represent the tested cell types.

See also

wilcox.test for the Wilcoxon rank-sum test. CAESAR.enrich.score for spot level pathway enrich scores.

Examples

data(toydata)

seu <- toydata$seu
pathway_list <- toydata$pathway_list
cts <- levels(seu)[1:2]

enrich.score <- CAESAR.enrich.score(seu, pathway_list)
#> Calculate co-embedding distance...
#> There are 2 pathways. The largest pathway has 48 genes.
#> Pathways with 37 genes finished, which includes 1 pathways, elapsed time is 4.05s.
#> Pathways with 48 genes finished, which includes 1 pathways, elapsed time is 0.06s.
dep.pvals <- CAESAR.CTDEP(seu, enrich.score, cts = cts)
#> Warning: package 'purrr' was built under R version 4.3.3
print(dep.pvals)
#>                              Cancer Epithelial       Myeloid
#> GOBP_VASCULATURE_DEVELOPMENT                 1  2.634230e-24
#> GOBP_T_CELL_ACTIVATION                       1 3.100715e-102