From e1deaa8e315205cdd86f5085b456637e706f934f Mon Sep 17 00:00:00 2001 From: maxim-h Date: Wed, 20 Mar 2024 17:23:51 +0100 Subject: [PATCH] Add warning if layer is absent from assay This is meant to help diagnose issues when assay doesn't have desired layer. For example see satijalab/seurat#8658 and discussion in satijalab/seurat#8659. The warning message might not be the prettiest, but I didn't want to go through `Layer.Seurat` method to get the assay name. --- R/assay.R | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/R/assay.R b/R/assay.R index c96de65f..67a75cf4 100644 --- a/R/assay.R +++ b/R/assay.R @@ -697,6 +697,11 @@ Layers.Assay <- function(object, search = NA, ...) { if (!is_na(x = search)) { layers <- intersect(x = search, y = layers) if (length(x = layers) == 0) { + warning( + "Layer ", search, " isn't present in the assay ", deparse(substitute(object)), ". Returning NULL.", + call. = FALSE, + immediate. = TRUE + ) return(NULL) } }