Using the layer-level (group-level) data, this function evaluates whether list of gene sets (Ensembl gene IDs) are enriched among the significant genes (FDR < 0.1 by default) genes for a given model type result. Test the alternative hypothesis that OR > 1, i.e. that gene set is over-represented in the set of enriched genes. If you want to check depleted genes, change reverse to TRUE.

gene_set_enrichment(
  gene_list,
  fdr_cut = 0.1,
  modeling_results = fetch_data(type = "modeling_results"),
  model_type = names(modeling_results)[1],
  reverse = FALSE
)

Arguments

gene_list

A named list object (could be a data.frame) where each element of the list is a character vector of Ensembl gene IDs.

fdr_cut

A numeric(1) specifying the FDR cutoff to use for determining significance among the modeling results genes.

modeling_results

Defaults to the output of fetch_data(type = 'modeling_results'). This is a list of tables with the columns f_stat_* or t_stat_* as well as p_value_* and fdr_* plus ensembl. The column name is used to extract the statistic results, the p-values, and the FDR adjusted p-values. Then the ensembl column is used for matching in some cases. See fetch_data() for more details. Typically this is the set of reference statistics used in layer_stat_cor().

model_type

A named element of the modeling_results list. By default that is either enrichment for the model that tests one human brain layer against the rest (one group vs the rest), pairwise which compares two layers (groups) denoted by layerA-layerB such that layerA is greater than layerB, and anova which determines if any layer (group) is different from the rest adjusting for the mean expression level. The statistics for enrichment and pairwise are t-statistics while the anova model ones are F-statistics.

reverse

A logical(1) indicating whether to multiply by -1 the input statistics and reverse the layerA-layerB column names (using the -) into layerB-layerA.

Value

A table in long format with the enrichment results using stats::fisher.test().

  • OR odds ratio.

  • Pval p-value for fisher.test().

  • test group or layer in the modeling_results.

  • NumSig Number of genes from the gene set present in modeling_results & with fdr < fdr_cut and t_stat > 0 (unless reverse = TRUE) for test in modeling results.

  • SetSize Number of genes from modeling_results present in gene_set.

  • ID name of gene set.

  • model_type record of input model type from modeling results.

  • fdr_cut record of input frd_cut.

  • GeneList List of gene names from input set with fdr < fdr_cut and t_stat > 0, possible that some gene_names are missing from modeling data.

Details

Check https://github.com/LieberInstitute/HumanPilot/blob/master/Analysis/Layer_Guesses/check_clinical_gene_sets.R to see a full script from where this family of functions is derived from.

See also

Other Gene set enrichment functions: gene_set_enrichment_plot()

Author

Andrew E Jaffe, Leonardo Collado-Torres

Examples


## Read in the SFARI gene sets included in the package
asd_sfari <- utils::read.csv(
    system.file(
        "extdata",
        "SFARI-Gene_genes_01-03-2020release_02-04-2020export.csv",
        package = "spatialLIBD"
    ),
    as.is = TRUE
)

## Format them appropriately
asd_sfari_geneList <- list(
    Gene_SFARI_all = asd_sfari$ensembl.id,
    Gene_SFARI_high = asd_sfari$ensembl.id[asd_sfari$gene.score < 3],
    Gene_SFARI_syndromic = asd_sfari$ensembl.id[asd_sfari$syndromic == 1]
)

## Obtain the necessary data
if (!exists("modeling_results")) {
    modeling_results <- fetch_data(type = "modeling_results")
}
#> 2026-01-09 17:22:09.91296 loading file /github/home/.cache/R/BiocFileCache/101f43b88241_Human_DLPFC_Visium_modeling_results.Rdata%3Fdl%3D1

## Compute the gene set enrichment results
asd_sfari_enrichment <- gene_set_enrichment(
    gene_list = asd_sfari_geneList,
    modeling_results = modeling_results,
    model_type = "enrichment"
)

## Explore the results
asd_sfari_enrichment
#>           OR         Pval   test NumSig SetSize                   ID model_type
#> 1  1.2659915 1.761332e-03     WM    231     869       Gene_SFARI_all enrichment
#> 2  1.1819109 9.895949e-02     WM     90     355      Gene_SFARI_high enrichment
#> 3  1.2333378 1.853021e-01     WM     31     118 Gene_SFARI_syndromic enrichment
#> 4  0.9702022 6.130806e-01 Layer1     71     869       Gene_SFARI_all enrichment
#> 5  0.7192630 9.493328e-01 Layer1     22     355      Gene_SFARI_high enrichment
#> 6  1.1216176 4.054532e-01 Layer1     11     118 Gene_SFARI_syndromic enrichment
#> 7  2.7377140 5.096514e-21 Layer2    137     869       Gene_SFARI_all enrichment
#> 8  2.7066379 8.845390e-10 Layer2     57     355      Gene_SFARI_high enrichment
#> 9  2.6632367 3.564638e-04 Layer2     19     118 Gene_SFARI_syndromic enrichment
#> 10 1.3579958 1.687561e-01 Layer3     14     869       Gene_SFARI_all enrichment
#> 11 1.1738012 4.264658e-01 Layer3      5     355      Gene_SFARI_high enrichment
#> 12 2.8947133 5.518757e-02 Layer3      4     118 Gene_SFARI_syndromic enrichment
#> 13 1.2423009 1.544115e-01 Layer4     29     869       Gene_SFARI_all enrichment
#> 14 1.1445522 3.748009e-01 Layer4     11     355      Gene_SFARI_high enrichment
#> 15 2.6106289 1.575232e-02 Layer4      8     118 Gene_SFARI_syndromic enrichment
#> 16 2.0969125 7.366596e-07 Layer5     60     869       Gene_SFARI_all enrichment
#> 17 2.0956628 9.450654e-04 Layer5     25     355      Gene_SFARI_high enrichment
#> 18 0.7064982 7.951889e-01 Layer5      3     118 Gene_SFARI_syndromic enrichment
#> 19 2.6716353 1.472539e-07 Layer6     41     869       Gene_SFARI_all enrichment
#> 20 2.6206690 5.845493e-04 Layer6     17     355      Gene_SFARI_high enrichment
#> 21 2.2573853 7.927915e-02 Layer6      5     118 Gene_SFARI_syndromic enrichment
#>    fdr_cut
#> 1      0.1
#> 2      0.1
#> 3      0.1
#> 4      0.1
#> 5      0.1
#> 6      0.1
#> 7      0.1
#> 8      0.1
#> 9      0.1
#> 10     0.1
#> 11     0.1
#> 12     0.1
#> 13     0.1
#> 14     0.1
#> 15     0.1
#> 16     0.1
#> 17     0.1
#> 18     0.1
#> 19     0.1
#> 20     0.1
#> 21     0.1
#>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        GeneList
#> 1  SPEN, AGO4, AGO1, AGO3, GRIK3, MTF1, POMGNT1, SCP2, CPT2, NFIA, PATJ, ALG6, SRSF11, PTBP2, DPYD, SLC22A15, APH1A, SETDB1, POGZ, ILF2, KCNJ10, PBX1, PTPRC, CR1, HSD11B1, WDR26, NUP133, DISC1, HNRNPU, PXDN, SPAST, EXOC6B, POU3F3, NCKAP5, NR4A2, ERMN, BAZ2B, SCN9A, STK39, LRP2, INPP1, SF3B1, CYP27A1, DNER, TRIP12, AGAP1, XPC, TBC1D5, KAT2B, CX3CR1, SETD2, PLXNB1, FHIT, TBC1D23, ZBTB20, ADCY5, PCCB, STAG1, SLC9A9, C3orf58, NAALADL2, DVL3, PAK2, DLG1, CD38, WDFY3, DAPP1, TET2, TBCK, NAA15, SEMA5A, NIPBL, ZSWIM6, ERBIN, MEGF10, P4HA2, PITX1, KDM3B, DPYSL3, CCNG1, NUDCD2, UIMC1, NSD1, ELOVL2, HLA-A, HLA-B, HLA-DRB1, HLA-DPB1, RPS10, PTK7, LRRC1, DST, PHF3, PHIP, SYNCRIP, ZNF292, HS3ST5, SASH1, RPS6KA2, DLL1, RAC1, NFE2L3, PDE1C, RALA, CDK13, GTF2I, SMURF1, AZGP1, SERPINE1, KMT2E, FOXP2, CTTNBP2, GPR37, UBE2H, UBN2, SSPO, KMT2C, EN2, TBL1X, OFD1, IL1RAPL1, KDM6A, SMC1A, HUWE1, PHF8, AR, TAF1, UPF3B, SLC6A8, RPL10, CLN8, ARHGEF10, PCM1, DPYSL2, KIF13B, KAT6A, CHD7, UBR5, RAD21, EPPK1, DOCK8, KANK1, KDM4C, PHF2, LMX1B, POMT1, PNPLA7, EHMT1, ELP4, PAX6, POLA2, KMT5B, PPFIA1, DHCR7, PPP2R1B, DIXDC1, PAFAH1B2, HEPACAM, ZMYND11, DIP2C, WDFY4, ANK3, REEP3, CTNNA3, BTAF1, LZTS2, SMC3, DOCK1, ARID2, VDR, MBD6, ANKS1B, PTPN11, ATP6V0A2, KATNAL1, PCDH9, SLC7A7, ARHGAP5, MDGA2, EXOC5, ZFYVE26, VASH1, YY1, PACS2, NIPA1, CYFIP1, ATP10A, FAN1, OTUD7A, THBS1, CASC4, GATM, FBN1, MYO1E, MEGF11, NEO1, CHD2, CDH11, CNTNAP4, WWOX, CHMP1A, SLC25A39, PHB, PPM1D, MED13, TLK2, DNAH17, SGSH, SLC38A10, KATNAL2, SMAD4, SNX5, ADA, PREX1, BCAS1, KDM4B, EIF3G, ELAVL3, NFIX, MYO9B, ACTN4, PLAUR, PRKD2, ETFB, CECR2, CLTCL1, CSNK1E, EP300, SBF1, HMGN1, DIP2A
#> 2                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         SPEN, AGO4, AGO1, POMGNT1, SRSF11, APH1A, POGZ, ILF2, KCNJ10, DISC1, HNRNPU, SPAST, NR4A2, BAZ2B, SCN9A, TRIP12, KAT2B, SETD2, PLXNB1, ZBTB20, PAK2, WDFY3, DAPP1, TET2, TBCK, NAA15, SEMA5A, NIPBL, ERBIN, P4HA2, KDM3B, CCNG1, NUDCD2, NSD1, RPS10, PTK7, PHF3, PHIP, ZNF292, NFE2L3, KMT2E, FOXP2, CTTNBP2, UBN2, KMT2C, KDM6A, UPF3B, DPYSL2, KAT6A, CHD7, UBR5, DOCK8, KDM4C, PHF2, LMX1B, EHMT1, ELP4, KMT5B, DHCR7, ZMYND11, DIP2C, WDFY4, ANK3, BTAF1, PTPN11, CYFIP1, ATP10A, OTUD7A, FBN1, CHD2, CNTNAP4, WWOX, CHMP1A, PHB, MED13, TLK2, SLC38A10, KATNAL2, SMAD4, SNX5, ADA, PREX1, ELAVL3, MYO9B, PRKD2, ETFB, EP300, SBF1, HMGN1, DIP2A
#> 3                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              ALG6, WDR26, POU3F3, CYP27A1, XPC, TBC1D23, PCCB, STAG1, ZSWIM6, DLL1, RAC1, RALA, CDK13, KMT2E, SMC1A, HUWE1, PHF8, TAF1, KAT6A, RAD21, PAX6, HEPACAM, SMC3, ARID2, ANKS1B, YY1, PACS2, GATM, PPM1D, SGSH, NFIX
#> 4                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     SAMD11, DLGAP3, NFIA, OTX1, POU3F3, PLCD4, DNER, SLC6A1, KAT2B, CX3CR1, ZBTB20, SPARCL1, FAT1, SEMA5A, ELOVL2, HLA-A, HLA-B, HLA-DRB1, HLA-DPB1, CNR1, PLN, SLC29A4, AZGP1, CUX1, RELN, AP1S2, MAOA, VSIG4, GPC4, SDC2, KANK1, NFIB, NTRK2, TSPAN4, NAV2, ELP4, PAX6, SLC1A2, ZBTB16, GRIK4, HEPACAM, LRP1, MBD6, PTPRB, SLC7A7, ARHGAP5, CCDC88C, CCNK, CYFIP1, CHRFAM7A, CASC4, GATM, SYT17, HYDIN, SMG6, KDM6B, CHD3, PPP1R1B, THRA, PRKCA, LAMA1, KATNAL2, SNX5, MBD3, NFIX, DMPK, PRKD2, LILRB2, TBX1, SHANK3, HMGN1
#> 5                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    SLC6A1, KAT2B, ZBTB20, SPARCL1, SEMA5A, CNR1, CUX1, RELN, GPC4, NAV2, ELP4, LRP1, CYFIP1, CHRFAM7A, KDM6B, CHD3, KATNAL2, SNX5, DMPK, PRKD2, SHANK3, HMGN1
#> 6                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     POU3F3, AP1S2, NFIB, NTRK2, PAX6, SLC1A2, HEPACAM, CCNK, GATM, NFIX, TBX1
#> 7                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            TMEM39B, DLGAP3, KCND3, ASH1L, NTRK1, CACNA1E, CHRM3, MYT1L, ADCY3, FBXO11, NRXN1, SLC4A10, SCN2A, DLX2, NCKAP1, ZNF804A, HECW2, ITPR1, CNTN3, MED12L, TBL1XR1, GABRA4, NR3C2, GRIA2, CDH9, HOMER1, CAMK4, YTHDC2, RBM27, CAMK2A, GRIA1, CPEB4, DRD1, TSPAN17, SYNGAP1, LRFN2, SLC25A27, KHDRBS2, CNR1, GRIK2, WASF1, SYNE1, RPS6KA2, INTS1, SLC29A4, NXPH1, MPP6, CAMK2B, CACNA2D1, ACTL6B, RELN, LAMB1, IMMP2L, DOCK4, KCND2, CEP41, DPP6, NLGN4X, FRMPD4, CNKSR2, IQSEC2, ATRX, PCDH19, GABRA3, DLGAP2, CSMD1, PSD3, EGR3, PRKDC, SMARCA2, RFX3, SLC1A1, NFIB, GDA, GRIN1, DAGLA, NRXN2, SHANK2, GRM5, HTR3A, CADM1, KIRREL3, ARHGAP32, ZMYND11, UPF2, CACNB2, DYDC2, EXOC6, GRIN2B, LRP1, CUX2, DNAH10, SLITRK5, TRAPPC6B, IRF2BPL, CCDC88C, UNC79, YY1, GABRB3, CHRFAM7A, MEIS2, CELF6, ARNT2, NTRK3, ST8SIA2, METTL26, RBFOX1, MKL2, SYT17, PRKCB, CMIP, CDH13, P2RX5, NLGN2, RAI1, THRA, ITGB3, PDK2, CACNA1G, TSPOAP1, TANC2, SCN4A, PRKCA, MBD1, TCF4, SLC12A5, CDH22, ADNP, KLF16, BRD4, PIK3R2, GRIK5, CIC, GNB1L, TNRC6B, CHKB, SHANK3
#> 8                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        ASH1L, CACNA1E, MYT1L, ADCY3, NRXN1, SCN2A, NCKAP1, ZNF804A, HECW2, TBL1XR1, NR3C2, GRIA2, RBM27, GRIA1, CPEB4, SYNGAP1, CNR1, GRIK2, RELN, LAMB1, CEP41, NLGN4X, CNKSR2, IQSEC2, ATRX, PCDH19, RFX3, GRIN1, NRXN2, SHANK2, KIRREL3, ZMYND11, CACNB2, GRIN2B, LRP1, SLITRK5, IRF2BPL, UNC79, GABRB3, CHRFAM7A, MEIS2, ST8SIA2, RBFOX1, PRKCB, CDH13, P2RX5, NLGN2, RAI1, ITGB3, TANC2, TCF4, SLC12A5, ADNP, GRIK5, CIC, TNRC6B, SHANK3
#> 9                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  FBXO11, MED12L, NR3C2, CAMK2A, WASF1, SYNE1, INTS1, CAMK2B, ACTL6B, FRMPD4, CNKSR2, GABRA3, SMARCA2, NFIB, CUX2, TRAPPC6B, YY1, PIK3R2, CHKB
#> 10                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                NTNG1, RGS7, NRXN1, MED12L, CAMK2A, LAMB1, MET, LRRC4, RFX3, CCIN, CACNB2, STYK1, CUX2, CDH22
#> 11                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              NRXN1, LAMB1, MET, RFX3, CACNB2
#> 12                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  NTNG1, MED12L, CAMK2A, CUX2
#> 13                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               RIMS3, NTNG1, ATP1A1, SCN1A, CTNNB1, TDO2, MEF2C, ACHE, MET, SND1, LRRC4, CNTNAP2, RHEB, CD99L2, RORB, PRUNE2, KCNC1, CNTN5, GUCY1A2, GALNT8, NUAK1, MYO5A, ALDH1A3, PSMD12, RIT2, PTPRT, EEF1A2, ATP1A3, SOD1
#> 14                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 SCN1A, CTNNB1, ACHE, MET, CNTNAP2, RORB, CNTN5, GALNT8, NUAK1, MYO5A, PSMD12
#> 15                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 NTNG1, ATP1A1, MEF2C, CNTNAP2, RHEB, ALDH1A3, EEF1A2, ATP1A3
#> 16                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     HIVEP3, KCND3, MARK1, ASAP2, BCL11A, TBR1, RAPGEF4, ZNF385B, SYN2, FEZF2, ANK2, PCDH10, TDO2, CDH10, PPP2CA, PCDHA10, RIMS1, PRKAR1B, STX1A, FOXP2, CADPS2, NDUFA5, RHEB, TSPAN7, MAOB, SYN1, PCDH19, IL1RAPL2, SLC9A6, RAB39B, CNGB3, KCNQ3, TRAPPC9, SLC24A2, ELAVL2, RORB, PRUNE2, STXBP1, APBB1, DRD2, SYT1, PAH, NUAK1, DENR, DYNC1H1, MAGEL2, APBA2, DMXL2, MYO5A, SEZ6L2, BCKDK, CELF4, SNAP25, MACROD2, PTPRT, TSHZ3, SAE1, CACNA1I, SOD1, SYNJ1
#> 17                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           HIVEP3, ASAP2, BCL11A, TBR1, ANK2, RIMS1, FOXP2, PCDH19, SLC9A6, KCNQ3, TRAPPC9, RORB, STXBP1, APBB1, PAH, NUAK1, DENR, DYNC1H1, MAGEL2, MYO5A, BCKDK, CELF4, MACROD2, TSHZ3, SAE1
#> 18                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           PPP2CA, RHEB, SYT1
#> 19                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          GRIK3, ASH1L, ADSS, TPO, ASAP2, GALNT14, NR4A2, GPD2, TBR1, DPP4, SCN2A, NCKAP1, UNC80, SYN2, CADPS, PCDH10, GRIA1, HS3ST5, FRK, STXBP5, STX1A, FOXP2, DMD, CHRNB3, EFR3A, SLC24A2, ANXA1, ASTN2, NTNG2, TSC1, CAPRIN1, TECTA, EXOC6, PRICKLE1, SYT1, TRAPPC6B, PRKCB, CDH11, TANC2, UNC13A, CLTCL1
#> 20                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   ASH1L, ASAP2, NR4A2, TBR1, SCN2A, NCKAP1, GRIA1, STXBP5, FOXP2, EFR3A, ANXA1, ASTN2, TSC1, CAPRIN1, PRICKLE1, PRKCB, TANC2
#> 21                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           DMD, NTNG2, SYT1, TRAPPC6B, UNC13A