Skip to content

Commit f84c392

Browse files
authored
Merge pull request #382 from taraeicher/SEAHORSE_corr_option
Added option not to compute coexpression matrix in SEAHORSE
2 parents c0a0bb8 + 3875d03 commit f84c392

File tree

3 files changed

+29
-4
lines changed

3 files changed

+29
-4
lines changed

R/SEAHORSE.R

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#' Types can be either "numeric" or "categorical"
2323
#' @param pathways : a list of pathways (e.g. KEGG, GO, Reactome etc.
2424
#' downloaded from http://www.gsea-msigdb.org/gsea/msigdb/human/collections.jsp)
25+
#' @param compute_cor : Whether or not to compute the correlation matrix. Default is TRUE.
2526
#' Outputs:
2627
#' @return results : a list containing three objects
2728
#' results$coexpression: a gene x gene Pearson correlation matrix.
@@ -51,7 +52,7 @@
5152
#' results <- seahorse(expression_data, phenotype_data, phenotype_dictionary, pathways)
5253
#'
5354
#' @export
54-
seahorse <- function(expression, phenotype, phenotype_dictionary, pathways){
55+
seahorse <- function(expression, phenotype, phenotype_dictionary, pathways, compute_cor = TRUE){
5556
if (!requireNamespace("fgsea", quietly = TRUE)) {
5657
stop("Package 'fgsea' is required but not installed.")
5758
}
@@ -60,7 +61,10 @@ seahorse <- function(expression, phenotype, phenotype_dictionary, pathways){
6061
results = list()
6162

6263
# Compute coexpression of genes
63-
results$coexpression = cor(t(expression), use="pairwise.complete.obs")
64+
results$coexpression <- NA
65+
if(compute_cor == TRUE){
66+
results$coexpression = cor(t(expression), use="pairwise.complete.obs")
67+
}
6468

6569
# Compute association of gene expression with phenotypes and run GSEA
6670
results$phenotype_association = list()

man/seahorse.Rd

Lines changed: 10 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/test-seahorse.R

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,17 @@ test_that("seahorse function works", {
3333
expect_true(all(c("coexpression", "phenotype_association", "GSEA") %in% names(results)))
3434
# Check that phenotype names appear in sub-lists
3535
expect_true(all(c("sex", "height") %in% names(results$GSEA)))
36+
37+
# Run seahorse without correlation matrix
38+
results <- seahorse(expression_data, phenotype_data, phenotype_dictionary, pathways,
39+
compute_cor = FALSE)
40+
41+
# Verify structure
42+
expect_type(results, "list")
43+
expect_true(length(results) > 0)
44+
# Check that results contain expected top-level keys
45+
expect_true(all(c("coexpression", "phenotype_association", "GSEA") %in% names(results)))
46+
# Check that phenotype names appear in sub-lists
47+
expect_true(all(c("sex", "height") %in% names(results$GSEA)))
48+
expect_true(is.na(results$coexpression))
3649
})

0 commit comments

Comments
 (0)