From d468d3b9cd62e0e7030f7efde779fb9eb6d88c2a Mon Sep 17 00:00:00 2001 From: phoman14 Date: Tue, 13 Oct 2026 18:47:21 -0400 Subject: [PATCH 1/5] feat: log Heatmap sample filtering --- R/Heatmap.R | 13 +++++++++++++ tests/testthat/test-Heatmap.R | 17 ++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/R/Heatmap.R b/R/Heatmap.R index f86a775..7c214a5 100755 --- a/R/Heatmap.R +++ b/R/Heatmap.R @@ -400,6 +400,16 @@ heatmapSC <- function(object, } stop("Could not find requested sample name column: ", sample.name.column) } + + requested.samples <- if (length(samples.to.include) > 0) { + paste(shQuote(samples.to.include), collapse = ", ") + } else { + "" + } + message( + "Filtering samples using metadata column '", sample.name.column, "': ", + requested.samples + ) #Set up annotation track: metadata.table <- object@meta.data[ @@ -414,6 +424,9 @@ heatmapSC <- function(object, sample.name.column ) } + message( + "Displaying ", nrow(metadata.table), "/", nrow(object@meta.data), " cells." + ) annot <- metadata.table %>% select(all_of(metadata)) a = dim(annot)[2] - 1 diff --git a/tests/testthat/test-Heatmap.R b/tests/testthat/test-Heatmap.R index 76c49a4..a578acd 100755 --- a/tests/testthat/test-Heatmap.R +++ b/tests/testthat/test-Heatmap.R @@ -54,7 +54,22 @@ test_that("Heatmap supports a custom sample name column", { cr.object$object@meta.data[["sample.name_1.2"]] == selected.sample ] - output <- do.call(heatmapSC, cr.object) + expect_message( + output <- do.call(heatmapSC, cr.object), + paste0( + "Filtering samples using metadata column 'sample.name_1.2': '", + selected.sample, "'" + ), + fixed = TRUE + ) + expect_message( + do.call(heatmapSC, cr.object), + paste0( + "Displaying ", length(expected.cells), "/", + nrow(cr.object$object@meta.data), " cells." + ), + fixed = TRUE + ) expect_setequal(names(output), c("plots", "data")) expect_setequal(colnames(output$data)[-1], expected.cells) From ee3736beff078c8e950fa47c324b41566278adb2 Mon Sep 17 00:00:00 2001 From: phoman14 Date: Tue, 13 Oct 2026 18:47:47 -0400 Subject: [PATCH 2/5] docs: note Heatmap filter logging --- NEWS.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index 3f0304a..024b7c2 100644 --- a/NEWS.md +++ b/NEWS.md @@ -6,4 +6,5 @@ ## heatmapSC -* Add `sample.name.column` to select the metadata column used for sample filtering, defaulting to `orig.ident` (#100). \ No newline at end of file +* Add `sample.name.column` to select the metadata column used for sample filtering, defaulting to `orig.ident` (#100). +* Log requested sample filtering and displayed filtered/total cell counts (#101). \ No newline at end of file From deabb4cfdc7ac17db8d44072a37a19953a7d0511 Mon Sep 17 00:00:00 2001 From: phoman14 Date: Tue, 13 Oct 2026 20:05:07 -0400 Subject: [PATCH 3/5] fix: use all Heatmap samples when selection blank --- R/Heatmap.R | 8 +++++++- tests/testthat/test-Heatmap.R | 13 +++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/R/Heatmap.R b/R/Heatmap.R index 7c214a5..72f3f15 100755 --- a/R/Heatmap.R +++ b/R/Heatmap.R @@ -4,7 +4,8 @@ #' gene or protein expression levels. Method is based on ComplexHeatmap::pheatmap #' #' @param object Seurat-class object -#' @param sample.names Sample names +#' @param sample.names Select which samples to include. Leave blank to use all +#' samples. #' @param sample.name.column Metadata column containing sample names. Blank #' values default to "orig.ident". #' @param metadata Metadata column to plot @@ -401,6 +402,11 @@ heatmapSC <- function(object, stop("Could not find requested sample name column: ", sample.name.column) } + if (length(samples.to.include) == 0) { + message("No samples specified. Using all samples.") + samples.to.include <- unique(object@meta.data[[sample.name.column]]) + } + requested.samples <- if (length(samples.to.include) > 0) { paste(shQuote(samples.to.include), collapse = ", ") } else { diff --git a/tests/testthat/test-Heatmap.R b/tests/testthat/test-Heatmap.R index a578acd..a0a6b16 100755 --- a/tests/testthat/test-Heatmap.R +++ b/tests/testthat/test-Heatmap.R @@ -76,6 +76,19 @@ test_that("Heatmap supports a custom sample name column", { expect_identical(colnames(cr.object$object@meta.data), metadata.names) }) +test_that("Heatmap uses all samples when sample selection is blank", { + cr.object <- getParamHM("Chariou") + cr.object$sample.names <- c("") + + expect_message( + output <- do.call(heatmapSC, cr.object), + "No samples specified. Using all samples.", + fixed = TRUE + ) + + expect_setequal(colnames(output$data)[-1], rownames(cr.object$object@meta.data)) +}) + test_that("Heatmap preserves punctuation in sample names", { cr.object <- getParamHM("Chariou") sample.column <- "sample.name_1.2" From 0d5801a1bb8bbf582337c24e8fee5878e0bcfb30 Mon Sep 17 00:00:00 2001 From: phoman14 Date: Tue, 13 Oct 2026 20:05:49 -0400 Subject: [PATCH 4/5] docs: note Heatmap blank sample selection --- NEWS.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index 024b7c2..7958f91 100644 --- a/NEWS.md +++ b/NEWS.md @@ -7,4 +7,5 @@ ## heatmapSC * Add `sample.name.column` to select the metadata column used for sample filtering, defaulting to `orig.ident` (#100). -* Log requested sample filtering and displayed filtered/total cell counts (#101). \ No newline at end of file +* Log requested sample filtering and displayed filtered/total cell counts (#101). +* Use all samples when sample selection is blank (#102). \ No newline at end of file From 2398c0c324cd029b44721529c4325d9b95390966 Mon Sep 17 00:00:00 2001 From: phoman14 Date: Tue, 13 Oct 2026 20:08:28 -0400 Subject: [PATCH 5/5] docs: update Heatmap roxygen output --- man/heatmapSC.Rd | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/man/heatmapSC.Rd b/man/heatmapSC.Rd index 89abb41..6543b28 100644 --- a/man/heatmapSC.Rd +++ b/man/heatmapSC.Rd @@ -35,7 +35,8 @@ heatmapSC( \arguments{ \item{object}{Seurat-class object} -\item{sample.names}{Sample names} +\item{sample.names}{Select which samples to include. Leave blank to use all +samples.} \item{metadata}{Metadata column to plot} @@ -86,7 +87,7 @@ heatmapSC( (default is empty vector)} \item{sample.name.column}{Metadata column containing sample names. Blank -values default to "orig.ident". Sample values are matched exactly.} +values default to "orig.ident".} } \value{ This function returns a heatmap plot and the data underlying the