Runs geneset tests and store in BOWER class.

# S3 method for list
enrich_genesets(
  list,
  bower,
  core = FALSE,
  gene_symbol = "X1",
  logfoldchanges = "logfoldchanges",
  pvals = "pvals",
  remove_mito_ribo = TRUE,
  minSize = 0,
  maxSize = 1000,
  ...
)

# S3 method for Seurat
enrich_genesets(
  sce,
  bower,
  groupby = NULL,
  core = FALSE,
  standardize = TRUE,
  mode = c("AUCell", "Seurat", "scanpy"),
  sce_assay = "logcounts",
  seurat_assay = "RNA",
  ncpus = NULL,
  aucMaxRank_pct = 5,
  ...
)

# S3 method for SingleCellExperiment
enrich_genesets(
  sce,
  bower,
  groupby = NULL,
  core = FALSE,
  standardize = TRUE,
  mode = c("AUCell", "Seurat", "scanpy"),
  sce_assay = "logcounts",
  seurat_assay = "RNA",
  ncpus = NULL,
  aucMaxRank_pct = 5,
  ...
)

Arguments

list

list containing differentially expressed gene testing results in a data frame.

bower

Processed BOWER object.

core

boolean. Whether or not to use the coregenes of genesets slot. Default is FALSE (use genesets).

gene_symbol

column name for gene_symbol for gsea.

logfoldchanges

column name for logfoldchanges for gsea.

pvals

column name for pvals for gsea.

remove_mito_ribo

boolean. whether or not to remove mitochondial and ribosomal genes from consideration for gsea. Default is TRUE.

minSize

minimum geneset size for gsea. Default is 0.

maxSize

maximum geneset size for gsea. Default is 1000.

...

passed to fgsea::fgsea, AUCell::AUCell_buildRankings or Seurat::AddModuleScore

sce

a single cell object in the format of a Seurat object or SingleCellExperiment object.

groupby

Column name in the meta.data/colData of the single cell objects specifying the group to average the enrichment score. If not specified, not cluster average will be calculated.

standardize

whether or not to standardize mean enrichment values to 0 to 1. Only used if groupby is not NULL.

mode

choice of enrichment test to perform.

sce_assay

name of assay in SingleCellExperiment object.

seurat_assay

name of assay in Seurat object.

ncpus

number of cores used for parallelizing geneset testing.

aucMaxRank_pct

percentage to use for aucMaxRank in AUCell::AUCell_calcAUC.

nperm

number of permuation iterations for gsea. Default is 10000.

Value

Returns a dataframe of average gene set scores.

Details

Examples

library(ktplots)
#> Loading required package: ggplot2
data(kidneyimmune)
gmt_file <- system.file("extdata", "h.all.v7.4.symbols.gmt", package = "bowerbird")
bwr <- bower(gmt_file)
bwr <- snn_graph(bwr)
#> Loading required namespace: FNN
bwr <- find_clusters(bwr)
bwr <- summarize_clusters(bwr, ncpus = 1)
#> Downloading udpipe model from https://raw.githubusercontent.com/jwijffels/udpipe.models.ud.2.5/master/inst/udpipe-ud-2.5-191206/english-ewt-ud-2.5-191206.udpipe to ~/Library/Application Support/bowerbird/english-ewt-ud-2.5-191206.udpipe
#>  - This model has been trained on version 2.5 of data from https://universaldependencies.org
#>  - The model is distributed under the CC-BY-SA-NC license: https://creativecommons.org/licenses/by-nc-sa/4.0
#>  - Visit https://github.com/jwijffels/udpipe.models.ud.2.5 for model license details.
#>  - For a list of all models and their licenses (most models you can download with this package have either a CC-BY-SA or a CC-BY-SA-NC license) read the documentation at ?udpipe_download_model. For building your own models: visit the documentation by typing vignette('udpipe-train', package = 'udpipe')
#> Downloading finished, model stored at '~/Library/Application Support/bowerbird/english-ewt-ud-2.5-191206.udpipe'
bwr <- enrich_genesets(kidneyimmune, bwr, groupby = 'celltype', ncpus = 1)
#> Loading required package: Seurat
#> Registered S3 method overwritten by 'spatstat.geom':
#>   method     from
#>   print.boxx cli 
#> Attaching SeuratObject
#> Loading required namespace: AUCell
bwr
#> BOWER class
#> number of genesets:  50 
#> genesets kNN Graph: 
#> IGRAPH b91852b UNW- 50 124 -- 
#> + attr: name (v/c), cluster (v/n), geneset_size (v/n), terms (v/c),
#> | labels (v/c), weight (e/n)
#> + edges from b91852b (vertex names):
#> [1] HALLMARK_TNFA_SIGNALING_VIA_NFKB--HALLMARK_HYPOXIA                
#> [2] HALLMARK_TNFA_SIGNALING_VIA_NFKB--HALLMARK_TGF_BETA_SIGNALING     
#> [3] HALLMARK_TNFA_SIGNALING_VIA_NFKB--HALLMARK_IL6_JAK_STAT3_SIGNALING
#> [4] HALLMARK_TNFA_SIGNALING_VIA_NFKB--HALLMARK_APOPTOSIS              
#> [5] HALLMARK_TNFA_SIGNALING_VIA_NFKB--HALLMARK_MYOGENESIS             
#> [6] HALLMARK_TNFA_SIGNALING_VIA_NFKB--HALLMARK_COMPLEMENT             
#> + ... omitted several edges
#> number of geneset clusters:  9 
#> Core genes:
#> 	First six genes shown
#> 	 XENOBIOTIC METABOLISM : LIFR DNAJB9 CD36 ACOX1 IDH1 ECH1 ...
#> 	 E2F TARGETS : SAC3D1 KIF11 KIF23 RACGAP1 NUMA1 KIF2C ...
#> 	 ESTROGEN RESPONSE EARLY : JAG1 CTNNB1 GNAI1 FDFT1 DHCR7 FASN ...
#> 	 APOPTOSIS : ATF3 IER3 BIRC3 JUN EGR3 IL1B ...
#> 	 INTERFERON ALPHA RESPONSE : MX1 ISG15 IFIT3 IFI44 IFI35 IRF7 ...
#> 	 HEDGEHOG SIGNALING : VEGFA VLDLR MYH9 ERO1A DDIT4 STC2 ...
#> 	 APICAL JUNCTION : EGFR ADAM10 CLTC AP2M1 ARF1 MAPK1 ...
#> 	 TGF BETA SIGNALING : TGFB1 PMEPA1 SERPINE1 ID2 THBS1 PPP1R15A ...
#> 	 IL6 JAK STAT3 SIGNALING : IL4R IFNGR1 IL1R2 IL3RA TNFRSF1B CSF1 ...