Skip to contents

Compute MSigDB Collection enrichments using msigdbr using Fisher test.

Usage

compute_MSigDB_enrichment(
  membership_matrix,
  K = 100,
  memb_cut = 0.65,
  cats = c("H", "C3", "C6", "C7", "C8"),
  p_cut = 0.001
)

Arguments

membership_matrix

a community membership (kME) matrix with genes as rows and communities as columns. Often community_membership or full_community_membership output from icwgcna()

K

cutoff for top community genes to include for computing enrichment. Used in an AND condition with memb_cut.

memb_cut

cutoff as a membership score threshold for determining top community genes for computing enrichment. Used in an AND condition with K.

cats

MSigDB collections to use. We recommend only using H, C3, C6, C7, C8 and avoiding C1, C2, C4, C5 for speed

p_cut

p value cutoff for determining importance. If all p values are below p_cut for a community, no cell type is selected

Value

Returns a list with the following items:

  • top_enr - a data.frame of the most significant enrichment for each MSigDB collection.

  • full_enr - all MSigDB enrichment scores for all communities for the selected collections.

Details

The function can use parallel and distributed processing in R, via the foreach package.

GSEA Enrichment testing assumes differential analysis so we are using simple fisher tests instead (actually hypergeometric for speed)

Examples

if (FALSE) { # \dontrun{
library("UCSCXenaTools")
luad <- getTCGAdata(
  project = "LUAD", mRNASeq = TRUE, mRNASeqType = "normalized",
  clinical = FALSE, download = TRUE
)
ex <- as.matrix(data.table::fread(luad$destfiles), rownames = 1)
results <- icwgcna(ex)

# Running with whatever parallel processing is already set up
compute_MSigDB_enrichment(results$community_membership)

# Using doParallel package to set up parallel processing
cl <- parallel::makePSOCKcluster(2)
doParallel::registerDoParallel(cl)
compute_MSigDB_enrichment(results$community_membership)

# Using doMC package to set up parallel processing (not available in Windows)
doMC::registerDoMC()
compute_MSigDB_enrichment(results$community_membership)
} # }