Skip to content

Commit da99242

Browse files
committed
fix: rank logic in add_inferred_sample
1 parent e9d212f commit da99242

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

R/utils.R

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,10 @@ add_inferred_sample <- function(tables, name, rank = NULL,
203203
}
204204

205205
# Rank is optional. If rank is provided or the samples table contains a 'rank'
206-
# column, it must be present in both places (argument and table).
207-
has_rank_col <- "rank" %in% colnames(tables$samples)
206+
# column with at least one non-NA value, it must be present in both places
207+
# (argument and table). A rank column that's entirely NA is treated as absent.
208+
has_rank_col <- "rank" %in% colnames(tables$samples) &&
209+
!all(is.na(tables$samples$rank))
208210
rank_provided <- !is.null(rank)
209211
if (xor(has_rank_col, rank_provided)) {
210212
stop("'rank' must be provided both as a function argument and present as a column in tables$samples, or omitted from both")

0 commit comments

Comments
 (0)