Functional enrichment analyses for dimensionally-reduced data
Source:R/methods-FactorisedExperiment.R
, R/methods-ModularExperiment.R
enrichment.Rd
Method for applying pathway enrichment analysis to components identified through dimensionality reduction (e.g., factors or modules). Enrichment analyses are applied to each component separately.
Usage
# S4 method for class 'FactorisedExperiment'
runEnrich(
object,
method = "gsea",
feature_id_col = "rownames",
center_loadings = FALSE,
abs_loadings = FALSE,
loading_threshold = 0.5,
proportional_threshold = 0.01,
as_dataframe = FALSE,
...
)
# S4 method for class 'ModularExperiment'
runEnrich(
object,
method = "overrepresentation",
feature_id_col = "rownames",
as_dataframe = FALSE,
...
)
Arguments
- object
FactorisedExperiment or ModularExperiment object.
- method
The method to use for identifying enriched pathways. One of "overrepresentation" or "gsea". The "overrepresentation" method calls enricher whereas the "gsea" method calls GSEA. Note that "gsea" is not available for modules.
- feature_id_col
The column in
rowData(object)
that will be used as a feature ID. Setting this to"rownames"
(default) instead usesrownames(object)
.- center_loadings
If
TRUE
, loadings will be centered column-wise to have a mean of 0.- abs_loadings
If
TRUE
, the absolute values of the loadings will be used for enrichment analysis. IfFALSE
, the signed loadings will be used for GSEA enrichment. Note that, regardless of the value of this term, the process used to select genes for overrepresentation analysis will be based on absolute loadings.- loading_threshold
See getAlignedFeatures. Only relevant for overrepresentation analysis.
- proportional_threshold
See getAlignedFeatures. Only relevant for overrepresentation analysis.
- as_dataframe
If
TRUE
, the results will be returned as a data.frame. Otherwise, the results will be returned as a list of objects created by either enricher, in the case of overrepresentation analysis, or GSEA, in the case of GSEA.- ...
Additional arguments to be passed to GSEA (if
method == "gsea"
) or enricher (ifmethod == "overrepresentation"
).
Value
If as_dataframe
is TRUE
, the results will be returned as a
data.frame. Otherwise, the results will be returned as a list of objects
created by either enricher, in the case of
overrepresentation analysis, or GSEA, in the case of
GSEA.
Details
When running module analysis, the overrepresentation method identifies pathways that are overrepresented in each module.
For factor analysis, the overrepresentation method first identifies the genes most highly aligned with each factor (using getAlignedFeatures), then uses the resulting gene lists to perform overrepresentation analysis. The GSEA method instead uses the entire set of factor loadings, and identifies pathways that are overrepresented in the tails of this distribution.
Examples
set.seed(2)
airway <- ReducedExperiment:::.getAirwayData(n_features = 2000)
airway_fe <- estimateFactors(
airway,
nc = 2,
use_stability = FALSE,
method = "imax"
)
# Get pathways (e.g., by using ReducedExperiment::getMsigdbT2G())
t2g <- read.csv(system.file(
"extdata",
"msigdb_t2g_filtered.csv",
package = "ReducedExperiment"
))
# Run overrepresentation analysis
overrep_res <- runEnrich(
airway_fe,
method = "overrepresentation",
feature_id_col = "rownames",
as_dataframe = TRUE,
p_cutoff = 0.1,
TERM2GENE = t2g,
universe = rownames(airway_fe)
)
head(overrep_res)
#> ID
#> factor_1.NABA_MATRISOME_ASSOCIATED NABA_MATRISOME_ASSOCIATED
#> factor_1.NABA_MATRISOME NABA_MATRISOME
#> factor_2.WP_MAPK_SIGNALING_PATHWAY WP_MAPK_SIGNALING_PATHWAY
#> factor_2.KEGG_MAPK_SIGNALING_PATHWAY KEGG_MAPK_SIGNALING_PATHWAY
#> factor_2.REACTOME_NEURONAL_SYSTEM REACTOME_NEURONAL_SYSTEM
#> factor_2.WP_MALIGNANT_PLEURAL_MESOTHELIOMA WP_MALIGNANT_PLEURAL_MESOTHELIOMA
#> Description
#> factor_1.NABA_MATRISOME_ASSOCIATED NABA_MATRISOME_ASSOCIATED
#> factor_1.NABA_MATRISOME NABA_MATRISOME
#> factor_2.WP_MAPK_SIGNALING_PATHWAY WP_MAPK_SIGNALING_PATHWAY
#> factor_2.KEGG_MAPK_SIGNALING_PATHWAY KEGG_MAPK_SIGNALING_PATHWAY
#> factor_2.REACTOME_NEURONAL_SYSTEM REACTOME_NEURONAL_SYSTEM
#> factor_2.WP_MALIGNANT_PLEURAL_MESOTHELIOMA WP_MALIGNANT_PLEURAL_MESOTHELIOMA
#> GeneRatio BgRatio RichFactor
#> factor_1.NABA_MATRISOME_ASSOCIATED 4/20 52/2000 0.07692308
#> factor_1.NABA_MATRISOME 4/20 69/2000 0.05797101
#> factor_2.WP_MAPK_SIGNALING_PATHWAY 3/20 22/2000 0.13636364
#> factor_2.KEGG_MAPK_SIGNALING_PATHWAY 3/20 24/2000 0.12500000
#> factor_2.REACTOME_NEURONAL_SYSTEM 3/20 31/2000 0.09677419
#> factor_2.WP_MALIGNANT_PLEURAL_MESOTHELIOMA 3/20 39/2000 0.07692308
#> FoldEnrichment zScore pvalue
#> factor_1.NABA_MATRISOME_ASSOCIATED 7.692308 4.913284 0.001447657
#> factor_1.NABA_MATRISOME 5.797101 4.074751 0.004140536
#> factor_2.WP_MAPK_SIGNALING_PATHWAY 13.636364 5.988377 0.001167625
#> factor_2.KEGG_MAPK_SIGNALING_PATHWAY 12.500000 5.695066 0.001515075
#> factor_2.REACTOME_NEURONAL_SYSTEM 9.677419 4.892574 0.003217371
#> factor_2.WP_MALIGNANT_PLEURAL_MESOTHELIOMA 7.692308 4.240902 0.006215118
#> p.adjust qvalue
#> factor_1.NABA_MATRISOME_ASSOCIATED 0.002895315 NA
#> factor_1.NABA_MATRISOME 0.004140536 NA
#> factor_2.WP_MAPK_SIGNALING_PATHWAY 0.004545224 NA
#> factor_2.KEGG_MAPK_SIGNALING_PATHWAY 0.004545224 NA
#> factor_2.REACTOME_NEURONAL_SYSTEM 0.006434743 NA
#> factor_2.WP_MALIGNANT_PLEURAL_MESOTHELIOMA 0.009322677 NA
#> geneID
#> factor_1.NABA_MATRISOME_ASSOCIATED ENSG00000172156/ENSG00000123243/ENSG00000145423/ENSG00000126838
#> factor_1.NABA_MATRISOME ENSG00000172156/ENSG00000123243/ENSG00000145423/ENSG00000126838
#> factor_2.WP_MAPK_SIGNALING_PATHWAY ENSG00000066468/ENSG00000165995/ENSG00000173110
#> factor_2.KEGG_MAPK_SIGNALING_PATHWAY ENSG00000066468/ENSG00000165995/ENSG00000173110
#> factor_2.REACTOME_NEURONAL_SYSTEM ENSG00000099337/ENSG00000165995/ENSG00000135821
#> factor_2.WP_MALIGNANT_PLEURAL_MESOTHELIOMA ENSG00000145423/ENSG00000040731/ENSG00000066468
#> Count adj_method method
#> factor_1.NABA_MATRISOME_ASSOCIATED 4 BH overrepresentation
#> factor_1.NABA_MATRISOME 4 BH overrepresentation
#> factor_2.WP_MAPK_SIGNALING_PATHWAY 3 BH overrepresentation
#> factor_2.KEGG_MAPK_SIGNALING_PATHWAY 3 BH overrepresentation
#> factor_2.REACTOME_NEURONAL_SYSTEM 3 BH overrepresentation
#> factor_2.WP_MALIGNANT_PLEURAL_MESOTHELIOMA 3 BH overrepresentation
#> component loading_threshold
#> factor_1.NABA_MATRISOME_ASSOCIATED factor_1 0.5
#> factor_1.NABA_MATRISOME factor_1 0.5
#> factor_2.WP_MAPK_SIGNALING_PATHWAY factor_2 0.5
#> factor_2.KEGG_MAPK_SIGNALING_PATHWAY factor_2 0.5
#> factor_2.REACTOME_NEURONAL_SYSTEM factor_2 0.5
#> factor_2.WP_MALIGNANT_PLEURAL_MESOTHELIOMA factor_2 0.5
#> proportional_threshold
#> factor_1.NABA_MATRISOME_ASSOCIATED 0.01
#> factor_1.NABA_MATRISOME 0.01
#> factor_2.WP_MAPK_SIGNALING_PATHWAY 0.01
#> factor_2.KEGG_MAPK_SIGNALING_PATHWAY 0.01
#> factor_2.REACTOME_NEURONAL_SYSTEM 0.01
#> factor_2.WP_MALIGNANT_PLEURAL_MESOTHELIOMA 0.01
#> loadings_centered loadings_scaled
#> factor_1.NABA_MATRISOME_ASSOCIATED FALSE TRUE
#> factor_1.NABA_MATRISOME FALSE TRUE
#> factor_2.WP_MAPK_SIGNALING_PATHWAY FALSE TRUE
#> factor_2.KEGG_MAPK_SIGNALING_PATHWAY FALSE TRUE
#> factor_2.REACTOME_NEURONAL_SYSTEM FALSE TRUE
#> factor_2.WP_MALIGNANT_PLEURAL_MESOTHELIOMA FALSE TRUE
#> abs_loadings
#> factor_1.NABA_MATRISOME_ASSOCIATED FALSE
#> factor_1.NABA_MATRISOME FALSE
#> factor_2.WP_MAPK_SIGNALING_PATHWAY FALSE
#> factor_2.KEGG_MAPK_SIGNALING_PATHWAY FALSE
#> factor_2.REACTOME_NEURONAL_SYSTEM FALSE
#> factor_2.WP_MALIGNANT_PLEURAL_MESOTHELIOMA FALSE