diff --git a/DESCRIPTION b/DESCRIPTION index b101ae6..02ac538 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -12,8 +12,8 @@ Authors@R: c( person("Leo", "Lahti", role=c("ctb"), email="leo.lahti@utu.fi", comment = c(ORCID = "0000-0001-5537-637X")) ) -Version: 1.31.0 -Date: 2023-08-23 +Version: 1.31.1 +Date: 2023-11-16 License: GPL-3 Title: Single-Cell Analysis Toolkit for Gene Expression Data in R Description: A collection of tools for doing various analyses of diff --git a/R/plotExplanatoryPCs.R b/R/plotExplanatoryPCs.R index cdb98a7..cf59dec 100644 --- a/R/plotExplanatoryPCs.R +++ b/R/plotExplanatoryPCs.R @@ -47,9 +47,8 @@ plotExplanatoryPCs <- function(object, nvars_to_plot = 10, npcs_to_plot=50, them df_to_plot <- data.frame( PC=rep(seq_len(nrow(chosen_rsquared)), ncol(chosen_rsquared)), Expl_Var=rep(ordered_vars, each=nrow(chosen_rsquared)), - Pct_Var_Explained=as.numeric(chosen_rsquared) * 100 # column major collapse. + Pct_Var_Explained=as.numeric(chosen_rsquared) # column major collapse. ) - plot_out <- ggplot(df_to_plot, aes(x = .data$PC, y = .data$"Pct_Var_Explained", colour = .data$"Expl_Var")) + geom_point(alpha= 1, shape = 16, size = 3) + geom_line(alpha = 0.7, linewidth = 2) + diff --git a/tests/testthat/test-expl-var.R b/tests/testthat/test-expl-var.R index e1cfb80..7faf9f8 100644 --- a/tests/testthat/test-expl-var.R +++ b/tests/testthat/test-expl-var.R @@ -151,6 +151,28 @@ test_that("getExplanatoryPCs matches with a reference function", { } }) + +test_that("getExplanatoryPCs doesn't return more than 100%", { + example_sce <- mockSCE() + example_sce <- logNormCounts(example_sce) + example_sce <- runPCA(example_sce) + + r2mat <- getExplanatoryPCs(example_sce) + expect_true(all(r2mat <= 100)) +}) + + +test_that("plotExplanatoryPCs doesn't return more than 100%", { + example_sce <- mockSCE() + example_sce <- logNormCounts(example_sce) + example_sce <- runPCA(example_sce) + + g <- plotExplanatoryPCs(example_sce) + expect_true(all(g$data$Pct_Var_Explained <= 100)) +}) + + + test_that("getExplanatoryPCs responds to PC-specific options", { # Responds to differences in the reduced dimension slot. blah <- normed