Description Usage Arguments Details Value Examples
Performs gene-set enrichment analysis on a group of genes. Tests whether the scores among selected genes differ from the overall score dsitribution.
1 2 3 4 5 6 7 | term_gsea(
genes,
scores,
test = "wilcoxon",
alternative = "greater",
min_size = 3
)
|
genes |
Character vector of gene IDs that belong to a group to test. |
scores |
Named numeric vector of gene scores to be tested. The 'names' attribute must correspond to the values in 'genes'. |
test |
Which test to perform. Either 'wilcoxon' or 'ks' for Wilcoxon Rank Sum and Kolmogorov-Smirnov tests repsectiveley. Test use R's base wilcox.test and ks.test respectiveley. |
alternative |
The alternative hypothesis to test. Either 'greater', 'less' or 'two.sided'. It corresponds to option 'alternative' in wilcox.test or ks.test. Typically, if scores are p-values one wishes to #' test the hypothesis that p-values within 'genes' are 'less' than expected; while if scores are some other type of value (like fold-change abundance) one is trying to test that those values are 'greater'. Keep in mind that the Kolmogorov-Smirnov test is a test of the maximum difference in cumulative distribution values. Therefore, an alternative 'greater' in this case correspons to cases where score is stochastially smaller than the rest. |
min_size |
The minimum number of genes in the group for the test to be performed. Basically if the number of genes that appear in 'scores' is less than 'min_size', the test won't be performed. |
The function currently doesn't check whether some genes in 'genes' are missing from 'scores'. It will simply ignore those and test among the 'genes' found in scores.
If the test is not performed it returns NULL. If the test is performed it returns a tibble with elements: size (the number of elements in both 'genes' and 'scores'), statistic (the statistic calculated, depends on the test), and p.value (the p-value of the test).
1 2 3 4 5 6 7 8 9 10 11 | set.seed(123)
scores <- rnorm(n = 100)
names(scores) <- paste('gene', 1:100, sep = "")
# Select some genes and increase their scores
genes <- names(scores)[1:10]
scores[genes] <- scores[genes] + rnorm(10, mean = 1)
# Test
term_gsea(genes, scores)
term_gsea(genes, scores, test = 'ks', alternative = 'less')
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.