Skip to content

Commit

Permalink
Start with basic suite of functionality tests. [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
willgryan committed Sep 10, 2023
1 parent 290684e commit b3ab963
Show file tree
Hide file tree
Showing 10 changed files with 206 additions and 2 deletions.
2 changes: 1 addition & 1 deletion R/PAVER_export.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#' of each GO term for that group.
#'
#' @param PAVER_result A PAVER result object generated by the \code{\link{generate_themes}} function.
#' @return A wide format data frame with GO Term IDs, Definitions, gererated themes, and columns
#' @return A wide format data frame with GO Term IDs, Definitions, generated themes, and columns
#' for each of the groups in the PAVER result, with values representing the original input value
#' of each GO term for that group.
#'
Expand Down
2 changes: 1 addition & 1 deletion man/PAVER_export.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions tests/testthat/test-PAVER_combined_plot.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
library(testthat)
library(ggplot2)
library(ggpubr)

test_that("PAVER_combined_plot works correctly", {

#Use vignette example data
input = gsea_example

embeddings = readRDS(url("https://github.com/willgryan/PAVER_embeddings/raw/main/2023-03-06/embeddings_2023-03-06.RDS"))

ontology_index = readRDS(url("https://github.com/willgryan/PAVER_embeddings/raw/main/2023-03-06/ontology_2023-03-06.RDS"))

PAVER_result <- prepare_data(input, embeddings, ontology_index)

PAVER_result <- generate_themes(PAVER_result, minClusterSize = 40)

# Run the function and catch the result
p <- PAVER_combined_plot(PAVER_result)

# Verify the function runs and produces a ggplot object
expect_s3_class(p, "gg")
})
27 changes: 27 additions & 0 deletions tests/testthat/test-PAVER_export.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
library(testthat)
library(dplyr)
library(tidyr)
library(tibble)

test_that("PAVER_export works correctly", {

#Use vignette example data
input = gsea_example

embeddings = readRDS(url("https://github.com/willgryan/PAVER_embeddings/raw/main/2023-03-06/embeddings_2023-03-06.RDS"))

ontology_index = readRDS(url("https://github.com/willgryan/PAVER_embeddings/raw/main/2023-03-06/ontology_2023-03-06.RDS"))

PAVER_result <- prepare_data(input, embeddings, ontology_index)

PAVER_result <- generate_themes(PAVER_result, minClusterSize = 40)

# Test PAVER_export function
export_result <- PAVER_export(PAVER_result)

# Verify the structure and content of the output
expect_s3_class(export_result, "tbl_df")
expect_gte(ncol(export_result), 3)
expect_equal(names(export_result)[1:3], c("GOID", "Cluster", "Term"))

})
23 changes: 23 additions & 0 deletions tests/testthat/test-PAVER_hunter_plot.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
library(testthat)
library(ggplot2)
library(ggpubr)

test_that("PAVER_hunter_plot works correctly", {

#Use vignette example data
input = gsea_example

embeddings = readRDS(url("https://github.com/willgryan/PAVER_embeddings/raw/main/2023-03-06/embeddings_2023-03-06.RDS"))

ontology_index = readRDS(url("https://github.com/willgryan/PAVER_embeddings/raw/main/2023-03-06/ontology_2023-03-06.RDS"))

PAVER_result <- prepare_data(input, embeddings, ontology_index)

PAVER_result <- generate_themes(PAVER_result, minClusterSize = 40)

# Run the function and catch the result
p <- PAVER_hunter_plot(PAVER_result)

# Verify the function runs and produces a ggplot object
expect_s4_class(p, "HeatmapList")
})
23 changes: 23 additions & 0 deletions tests/testthat/test-PAVER_interpretation_plot.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
library(testthat)
library(ggplot2)
library(ggpubr)

test_that("PAVER_interpretation_plot works correctly", {

#Use vignette example data
input = gsea_example

embeddings = readRDS(url("https://github.com/willgryan/PAVER_embeddings/raw/main/2023-03-06/embeddings_2023-03-06.RDS"))

ontology_index = readRDS(url("https://github.com/willgryan/PAVER_embeddings/raw/main/2023-03-06/ontology_2023-03-06.RDS"))

PAVER_result <- prepare_data(input, embeddings, ontology_index)

PAVER_result <- generate_themes(PAVER_result, minClusterSize = 40)

# Run the function and catch the result
p <- PAVER_interpretation_plot(PAVER_result)

# Verify the function runs and produces a ggplot object
expect_s3_class(p, "gg")
})
23 changes: 23 additions & 0 deletions tests/testthat/test-PAVER_regulation_plot.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
library(testthat)
library(ggplot2)
library(ggpubr)

test_that("PAVER_regulation_plot works correctly", {

#Use vignette example data
input = gsea_example

embeddings = readRDS(url("https://github.com/willgryan/PAVER_embeddings/raw/main/2023-03-06/embeddings_2023-03-06.RDS"))

ontology_index = readRDS(url("https://github.com/willgryan/PAVER_embeddings/raw/main/2023-03-06/ontology_2023-03-06.RDS"))

PAVER_result <- prepare_data(input, embeddings, ontology_index)

PAVER_result <- generate_themes(PAVER_result, minClusterSize = 40)

# Run the function and catch the result
p <- PAVER_regulation_plot(PAVER_result)

# Verify the function runs and produces a ggplot object
expect_s3_class(p, "gg")
})
23 changes: 23 additions & 0 deletions tests/testthat/test-PAVER_theme_plot.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
library(testthat)
library(ggplot2)
library(ggpubr)

test_that("PAVER_theme_plot works correctly", {

#Use vignette example data
input = gsea_example

embeddings = readRDS(url("https://github.com/willgryan/PAVER_embeddings/raw/main/2023-03-06/embeddings_2023-03-06.RDS"))

ontology_index = readRDS(url("https://github.com/willgryan/PAVER_embeddings/raw/main/2023-03-06/ontology_2023-03-06.RDS"))

PAVER_result <- prepare_data(input, embeddings, ontology_index)

PAVER_result <- generate_themes(PAVER_result, minClusterSize = 40)

# Run the function and catch the result
p <- PAVER_theme_plot(PAVER_result)

# Verify the function runs and produces a ggplot object
expect_s3_class(p, "gg")
})
33 changes: 33 additions & 0 deletions tests/testthat/test-generate_themes.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
library(testthat)
library(dplyr)
library(tidyr)
library(tibble)
library(magrittr)
library(umap)
library(dynamicTreeCut)
library(randomcoloR)

test_that("generate_themes works correctly", {

#Use vignette example data
input = gsea_example

embeddings = readRDS(url("https://github.com/willgryan/PAVER_embeddings/raw/main/2023-03-06/embeddings_2023-03-06.RDS"))

ontology_index = readRDS(url("https://github.com/willgryan/PAVER_embeddings/raw/main/2023-03-06/ontology_2023-03-06.RDS"))

PAVER_result <- prepare_data(input, embeddings, ontology_index)

# Test generate_themes function
result <- generate_themes(PAVER_result, minClusterSize = 40)

# Verify output structure
expect_type(result, "list")
expect_named(result, c("prepared_data", "embedding_mat", "umap", "goterms_df", "clustering", "avg_cluster_embeddings", "mds", "colors"))
expect_s3_class(result$clustering, "tbl_df")
expect_s3_class(result$avg_cluster_embeddings, "tbl_df")
expect_s3_class(result$mds, "smacof")
expect_type(result$colors, "character")

})

29 changes: 29 additions & 0 deletions tests/testthat/test-prepare_data.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
library(testthat)
library(dplyr)
library(tidyr)
library(tibble)
library(magrittr)
library(umap)

test_that("prepare_data works correctly", {

#Use vignette example data
input = gsea_example

embeddings = readRDS(url("https://github.com/willgryan/PAVER_embeddings/raw/main/2023-03-06/embeddings_2023-03-06.RDS"))

ontology_index = readRDS(url("https://github.com/willgryan/PAVER_embeddings/raw/main/2023-03-06/ontology_2023-03-06.RDS"))

# Test function
result <- prepare_data(input, embeddings, ontology_index)

# Verify output structure
expect_type(result, "list")
expect_named(result, c("prepared_data", "embedding_mat", "umap", "goterms_df"))
expect_s3_class(result$prepared_data, "data.frame")
expect_s3_class(result$embedding_mat, "tbl_df")
expect_s3_class(result$umap, "umap")
expect_s3_class(result$goterms_df, "tbl_df")

})

0 comments on commit b3ab963

Please sign in to comment.