From f50a493504874d54407abe6c05bf4c79a43f842c Mon Sep 17 00:00:00 2001 From: jonathanspeh Date: Mon, 22 Apr 2024 17:37:30 +0200 Subject: [PATCH] Fixed bug in plot_deconvolution and added test --- R/plot_deconvolution.R | 3 ++- tests/testthat/test-plot_deconvolution.R | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/R/plot_deconvolution.R b/R/plot_deconvolution.R index ce4cb09..1de4b9c 100644 --- a/R/plot_deconvolution.R +++ b/R/plot_deconvolution.R @@ -76,8 +76,9 @@ plot_deconvolution_celltype_corrs <- function(deconvolution, actual){ estimate_v_actual <- dplyr::left_join(deconvolution, actual, by = dplyr::join_by("sample", "cell_type"), suffix = c("_estimate", "_actual")) - cell_types <- unique(estimate_v_actual["cell_type"]) + cell_types <- unlist(unique(estimate_v_actual["cell_type"])) lapply(cell_types, plot_corr_celltype, data = estimate_v_actual) + } diff --git a/tests/testthat/test-plot_deconvolution.R b/tests/testthat/test-plot_deconvolution.R index eb7e0bc..63012b8 100644 --- a/tests/testthat/test-plot_deconvolution.R +++ b/tests/testthat/test-plot_deconvolution.R @@ -4,4 +4,5 @@ testdata <- readRDS("testdata/cellanneal_deconvolution_long.Rdata") test_that("plots without error", { expect_no_error(plot_deconvolution_violin(testdata, testdata)) expect_no_error(plot_deconvolution_celltype_corrs(testdata, testdata)) + expect_equal(length(plot_deconvolution_celltype_corrs(testdata, testdata)), 8) })