Skip to content

Commit

Permalink
Add warning if layer is absent from assay
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
maxim-h authored Mar 20, 2024
1 parent 87412bb commit e1deaa8
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions R/assay.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down

0 comments on commit e1deaa8

Please sign in to comment.