Skip to content

Commit

Permalink
improve pcaSeurat test
Browse files Browse the repository at this point in the history
  • Loading branch information
mihem committed Nov 17, 2024
1 parent e43328a commit 7b028b8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
3 changes: 2 additions & 1 deletion R/visualization.R
Original file line number Diff line number Diff line change
Expand Up @@ -947,7 +947,7 @@ plotSlingshot <- function(object, lineage, pt, curves) {
#' @param height The height of the plot
#' @param dir_output directory to save the output plot (default: ".")
#'
#' @return A ggplot object.
#' @return Create and save PCA plot of Seurat cluster abundances.
#'
#' @examples
#' library(Seurat)
Expand Down Expand Up @@ -1080,4 +1080,5 @@ pcaSeurat <- function(object, cluster, sample, condition, width = 20, height = 5
width = width, height = height,
plot = pca_plots
)
return(pca_plots)
}
3 changes: 2 additions & 1 deletion man/pcaSeurat.Rd

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

11 changes: 9 additions & 2 deletions tests/testthat/test_visualization.R
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ test_that("pcaSeurat works as expected", {
tibble::column_to_rownames("barcode")

# Run the function
pcaSeurat(
plot <- pcaSeurat(
object = pbmc_small,
cluster = "cluster",
sample = "sample",
Expand All @@ -503,8 +503,15 @@ test_that("pcaSeurat works as expected", {

# Test 2: Function creates a file that is not empty
expect_gt(file.info("pbmc_small_condition_cluster.pdf")$size, 0)

# Test 3: Check if the function returns a ggplot object
expect_s3_class(plot, "ggplot")

# Test 4: Check if the plot is not empty
p <- ggplot2::ggplot_build(plot)
expect_gt(length(p$data), 0)

# Test 3: Check if the function throws an error if object is not a Seurat object
# Test 5: Check if the function throws an error if object is not a Seurat object
expect_error(
pcaSeurat(
object = data.frame(a = 1:3),
Expand Down

0 comments on commit 7b028b8

Please sign in to comment.