Run Gene Ontology enrichment analysis on differentially expressed genes.
Source:R/GSEA.R
runGOEnrich.Rd
This function forms genesets basing on the differential expression result, and calls gene ontology (GO) analysis method provided by gprofiler2.
Usage
runGOEnrich(
result,
group = NULL,
useBg = TRUE,
orderBy = "padj",
logFCThresh = 1,
padjThresh = 0.05,
splitReg = FALSE,
...
)
Arguments
- result
Data frame of unfiltered output from
runMarkerDEG
orrunPairwiseDEG
.- group
Selection of one group available from
result$group
. DefaultNULL
uses all groups involved in DEresult
table.- useBg
Logical, whether to set all genes involved in DE analysis (before threshold filtering) as a domain background of GO analysis. Default
TRUE
.- orderBy
Name of DE statistics metric to order the gene list for each group. Choose from
"logFC"
(default),"pval"
or"padj"
. Or setNULL
to turn off ranked mode.- logFCThresh
The log2FC threshold above which the genes will be used. Default
1
.- padjThresh
The adjusted p-value threshold less than which the genes will be used. Default
0.05
.- splitReg
Whether to have queries of both up-regulated and down-regulated genes for each group. Default
FALSE
only queries up-regulated genes and should be preferred whenresult
comes from marker detection test. Whenresult
comes from group-to-group DE test, it is recommended to setsplitReg = TRUE
.- ...
Additional arguments passed to
gprofiler2::gost()
. Argumentsquery
,custom_bg
,domain_scope
, andordered_query
are pre-specified by this wrapper function. Users must setorganism = "mmusculus"
when working on mouse data.
Value
A list object where each element is a result list for a group. Each result list contains two elements:
- result
data.frame of main GO analysis result.
- meta
Meta information for the query.
See gprofiler2::gost()
. for detailed explanation.
Examples
defaultCluster(pbmc) <- pbmcPlot$leiden_cluster
#> ℹ Storing given cluster labels to `cellMeta(x)` field: "defaultCluster".
# Test the DEG between "stim" and "ctrl", within each cluster
result <- runPairwiseDEG(
pbmc,
groupTest = "stim",
groupCtrl = "ctrl",
variable1 = "dataset",
splitBy = "defaultCluster",
nPsdRep = 3,
minCellPerRep = 3
)
#> ℹ Running DEG within: "0"
#> ℹ Calling pairwise DESeq2 Wald test
#> ✔ Calling pairwise DESeq2 Wald test ... done
#>
#> ℹ Running DEG within: "1"
#> ℹ Calling pairwise DESeq2 Wald test
#> -- note: fitType='parametric', but the dispersion trend was not well captured by the
#> function: y = a/x + b, and a local regression fit was automatically substituted.
#> specify fitType='local' or 'mean' to avoid this message next time.
#> ✔ Calling pairwise DESeq2 Wald test ... done
#>
#> ℹ Running DEG within: "2"
#> ℹ Calling pairwise DESeq2 Wald test
#> ✔ Calling pairwise DESeq2 Wald test ... done
#>
#> ℹ Running DEG within: "3"
#> ℹ Calling pairwise DESeq2 Wald test
#> ✔ Calling pairwise DESeq2 Wald test ... done
#>
#> ℹ Running DEG within: "4"
#> ℹ Calling pairwise DESeq2 Wald test
#> ✔ Calling pairwise DESeq2 Wald test ... done
#>
#> ℹ Running DEG within: "5"
#> ℹ Calling pairwise DESeq2 Wald test
#> ✔ Calling pairwise DESeq2 Wald test ... done
#>
#> ℹ Running DEG within: "6"
#> ℹ Calling pairwise DESeq2 Wald test
#> ✔ Calling pairwise DESeq2 Wald test ... done
#>
#> ℹ Running DEG within: "7"
#> ℹ Calling pairwise DESeq2 Wald test
#> ! Ignoring replicates (size in bracket) with too few cells: "others.ctrl.rep1 (2)"
#> ℹ Calling pairwise DESeq2 Wald test
#> ℹ Consider decrease minCellPerRep to exclude less replicates or/and lower nPsdRep to generate larger pseudo-replicates.
#> ℹ Calling pairwise DESeq2 Wald test
#> ✖ Error when computing on "7.stim": Too few replicates with more than 3 cells (`minCellPerRep`) for condition "others".
#> ℹ Calling pairwise DESeq2 Wald test
#> ! Empty result returned for this test.
#> ℹ Calling pairwise DESeq2 Wald test
#> ✖ Calling pairwise DESeq2 Wald test ... failed
#>
# Setting `significant = FALSE` because it's hard for a gene list obtained
# from small test dataset to represent real-life biology.
# \donttest{
if (requireNamespace("gprofiler2", quietly = TRUE)) {
go <- runGOEnrich(result, group = "0.stim", significant = FALSE)
}
# }