From 12d7fd43f620cd185ac23dd027ecd6581a768380 Mon Sep 17 00:00:00 2001 From: phoman14 Date: Tue, 13 Oct 2026 20:46:51 -0400 Subject: [PATCH 1/5] fix: streamline Heatmap feature logs --- R/Heatmap.R | 22 ++++++++++----------- tests/testthat/test-Heatmap.R | 36 ++++++++++++++++++++--------------- 2 files changed, 31 insertions(+), 27 deletions(-) diff --git a/R/Heatmap.R b/R/Heatmap.R index 72f3f15..725be17 100755 --- a/R/Heatmap.R +++ b/R/Heatmap.R @@ -292,6 +292,11 @@ heatmapSC <- function(object, } transcript.data <- object@assays[[use.assay]]@scale.data missing.genes <- setdiff(transcripts, rownames(transcript.data)) + transcripts <- transcripts[transcripts %in% rownames(transcript.data)] + if (length(transcripts) > 0) { + message("Transcripts found in ", use.assay, ": ", + paste(transcripts, collapse = ", ")) + } if (length(missing.genes) > 0) { missing.transcript.message <- paste0( "There are ", length(missing.genes), " gene(s) absent from dataset: ", @@ -300,12 +305,6 @@ heatmapSC <- function(object, "not highly expressed and has been filtered." ) message(missing.transcript.message) - warning(missing.transcript.message) - } - transcripts <- transcripts[transcripts %in% rownames(transcript.data)] - if (length(transcripts) > 0) { - message("Transcripts found in ", use.assay, ": ", - paste(transcripts, collapse = ", ")) } if (length(proteins) > 0 && !"Protein" %in% names(object@assays)) { @@ -314,18 +313,17 @@ heatmapSC <- function(object, if (length(proteins) > 0) { missing.proteins <- setdiff(proteins, rownames(object$Protein@scale.data)) + proteins <- proteins[proteins %in% rownames(object$Protein@scale.data)] + if (length(proteins) > 0) { + message("Proteins found in Protein assay: ", + paste(proteins, collapse = ", ")) + } if (length(missing.proteins) > 0) { missing.protein.message <- paste0( "Proteins not found in Protein assay: ", paste(missing.proteins, collapse = ", "), ". They will be excluded." ) message(missing.protein.message) - warning(missing.protein.message) - } - proteins <- proteins[proteins %in% rownames(object$Protein@scale.data)] - if (length(proteins) > 0) { - message("Proteins found in Protein assay: ", - paste(proteins, collapse = ", ")) } } diff --git a/tests/testthat/test-Heatmap.R b/tests/testthat/test-Heatmap.R index a0a6b16..5eae5a9 100755 --- a/tests/testthat/test-Heatmap.R +++ b/tests/testthat/test-Heatmap.R @@ -197,14 +197,16 @@ test_that("Heatmap run with bad gene name", { "has been filtered." ) - expect_warning( - expect_message( + expect_no_warning( + logs <- capture.output( do.call(heatmapSC, cr.object), - missing.transcript.message, - fixed = TRUE - ), - missing.transcript.message, - fixed = TRUE + type = "message" + ) + ) + expect_true(any(grepl(missing.transcript.message, logs, fixed = TRUE))) + expect_lt( + grep("Transcripts found in", logs, fixed = TRUE)[[1]], + grep(missing.transcript.message, logs, fixed = TRUE)[[1]] ) }) @@ -213,12 +215,18 @@ test_that("Heatmap reports missing proteins and retains available proteins", { cr.object$proteins <- c("CD3", "not_a_protein") cr.object$protein.annotations <- NULL - expect_warning( - expect_message( + expect_no_warning( + logs <- capture.output( output <- do.call(heatmapSC, cr.object), - "Proteins not found in Protein assay: not_a_protein. They will be excluded." - ), + type = "message" + ) + ) + missing.protein.message <- "Proteins not found in Protein assay: not_a_protein. They will be excluded." + expect_true(any(grepl(missing.protein.message, logs, fixed = TRUE))) + expect_lt( + grep("Proteins found in", logs, fixed = TRUE)[[1]], + grep(missing.protein.message, logs, fixed = TRUE)[[1]] ) expect_true("CD3_Prot" %in% output$data$gene) @@ -267,7 +275,7 @@ test_that("Heatmap run with error for missing all genes", { "'CD3E', 'CD3G'. Possible reasons are that gene is not official gene symbol ", "or gene is not highly expressed and has been filtered." ) - expect_warning( + expect_no_warning( expect_message( expect_error( do.call(heatmapSC, cr.object), @@ -275,9 +283,7 @@ test_that("Heatmap run with error for missing all genes", { ), missing.transcript.message, fixed = TRUE - ), - missing.transcript.message, - fixed = TRUE + ) ) }) From df824bec0ff51198e1cf7767b897ca825483f2f9 Mon Sep 17 00:00:00 2001 From: phoman14 Date: Tue, 13 Oct 2026 20:48:14 -0400 Subject: [PATCH 2/5] docs: note Heatmap feature log cleanup --- NEWS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/NEWS.md b/NEWS.md index 920ad9f..b91816a 100644 --- a/NEWS.md +++ b/NEWS.md @@ -9,3 +9,4 @@ * 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). * Use all samples when sample selection is blank (#102). +* Report found Heatmap features before missing requested features without duplicate warnings (#103). From a4302ae3448210b2f7a101680d90e045aa0de27a Mon Sep 17 00:00:00 2001 From: phoman14 Date: Tue, 13 Oct 2026 21:02:02 -0400 Subject: [PATCH 3/5] fix: format Heatmap missing feature logs --- R/Heatmap.R | 4 ++-- tests/testthat/test-Heatmap.R | 15 ++++++++------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/R/Heatmap.R b/R/Heatmap.R index 725be17..d327836 100755 --- a/R/Heatmap.R +++ b/R/Heatmap.R @@ -301,8 +301,8 @@ heatmapSC <- function(object, missing.transcript.message <- paste0( "There are ", length(missing.genes), " gene(s) absent from dataset: ", paste(shQuote(missing.genes), collapse = ", "), - ". Possible reasons are that gene is not official gene symbol or gene is ", - "not highly expressed and has been filtered." + ".\n Possible reasons are that gene is not official gene symbol ", + "or gene is not highly expressed and has been filtered." ) message(missing.transcript.message) } diff --git a/tests/testthat/test-Heatmap.R b/tests/testthat/test-Heatmap.R index 5eae5a9..4bb19a7 100755 --- a/tests/testthat/test-Heatmap.R +++ b/tests/testthat/test-Heatmap.R @@ -192,9 +192,9 @@ test_that("Heatmap run with bad gene name", { #Spike in with bad gene name cr.object$transcripts <- c("badgene", cr.object$transcripts) missing.transcript.message <- paste0( - "There are 1 gene(s) absent from dataset: 'badgene'. Possible reasons are ", - "that gene is not official gene symbol or gene is not highly expressed and ", - "has been filtered." + "There are 1 gene(s) absent from dataset: 'badgene'.\n", + " Possible reasons are that gene is not official gene symbol or gene ", + "is not highly expressed and has been filtered." ) expect_no_warning( @@ -203,10 +203,11 @@ test_that("Heatmap run with bad gene name", { type = "message" ) ) - expect_true(any(grepl(missing.transcript.message, logs, fixed = TRUE))) + log.text <- paste(logs, collapse = "\n") + expect_true(grepl(missing.transcript.message, log.text, fixed = TRUE)) expect_lt( grep("Transcripts found in", logs, fixed = TRUE)[[1]], - grep(missing.transcript.message, logs, fixed = TRUE)[[1]] + grep("There are 1 gene(s) absent from dataset", logs, fixed = TRUE)[[1]] ) }) @@ -272,8 +273,8 @@ test_that("Heatmap run with error for missing all genes", { c("APOE", "ARG1", "CD38", "CD3D", "CD3E", "CD3G") missing.transcript.message <- paste0( "There are 6 gene(s) absent from dataset: 'APOE', 'ARG1', 'CD38', 'CD3D', ", - "'CD3E', 'CD3G'. Possible reasons are that gene is not official gene symbol ", - "or gene is not highly expressed and has been filtered." + "'CD3E', 'CD3G'.\n Possible reasons are that gene is not official ", + "gene symbol or gene is not highly expressed and has been filtered." ) expect_no_warning( expect_message( From bd8e54c0e1388ca232f78e922634bc9adf40f372 Mon Sep 17 00:00:00 2001 From: phoman14 Date: Tue, 13 Oct 2026 21:09:17 -0400 Subject: [PATCH 4/5] chore: ignore generated R plot PDFs --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index f2fa164..aee1517 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ #*.png Rcheck.txt #*.pdf +Rplots.pdf tests/testthat/otherData/ tests/testthat/_snaps tests/testthat/fixtures/ From b00c7fc374f8c301cd493365941f29483b9745b0 Mon Sep 17 00:00:00 2001 From: phoman14 Date: Tue, 13 Oct 2026 21:12:00 -0400 Subject: [PATCH 5/5] chore: restore existing plot artifact rules --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index aee1517..f2fa164 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,6 @@ #*.png Rcheck.txt #*.pdf -Rplots.pdf tests/testthat/otherData/ tests/testthat/_snaps tests/testthat/fixtures/