Skip to content

Commit 1849db4

Browse files
committed
Allow this check, even though I assay names might not be present
1 parent 638183d commit 1849db4

File tree

1 file changed

+39
-22
lines changed

1 file changed

+39
-22
lines changed

R/utilities.R

Lines changed: 39 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1252,29 +1252,46 @@ is_filer_columns_in_column_selection <- function(.data, ...) {
12521252
}
12531253

12541254
check_if_assays_are_NOT_consistently_ordered <- function(se) {
1255-
1256-
# If I have any assay at all
1255+
1256+
# If I have any assay at all
1257+
do_I_have_assays =
12571258
assays(se) |> length() |> gt(0) &&
1258-
1259-
# If I have more than one assay with colnames
1260-
Filter(
1261-
Negate(is.null),
1262-
assays(se, withDimnames = FALSE) |>
1263-
as.list() |>
1264-
map(colnames)
1265-
) |>
1266-
length() |>
1267-
gt(0) &&
1268-
1269-
# If I have lack of consistency
1270-
se |>
1271-
assays(withDimnames = FALSE) |>
1272-
as.list() |>
1273-
purrr::map_dfr(colnames) |>
1274-
apply(1, function(x) x |> unique() |> length()) |>
1275-
equals(1) |>
1276-
all() |>
1277-
not()
1259+
1260+
# If I have more than one assay with colnames
1261+
Filter(
1262+
Negate(is.null),
1263+
assays(se, withDimnames = FALSE) |>
1264+
as.list() |>
1265+
map(colnames)
1266+
) |>
1267+
length() |>
1268+
gt(0)
1269+
1270+
# If I have lack of consistency
1271+
# Forcing assay names otherwise fails if assay is unnamed
1272+
if(
1273+
se |>
1274+
assays(withDimnames = FALSE) |>
1275+
as.list() |>
1276+
names()
1277+
)
1278+
assays(se) =
1279+
se |>
1280+
assays(withDimnames = FALSE) |>
1281+
as.list() |>
1282+
set_names(se |> assays() |> as.list() |> length() |> seq_len())
1283+
1284+
lack_of_consistency =
1285+
se |>
1286+
assays(withDimnames = FALSE) |>
1287+
as.list() |>
1288+
purrr::map_dfr(colnames) |>
1289+
apply(1, function(x) x |> unique() |> length()) |>
1290+
equals(1) |>
1291+
all() |>
1292+
not()
1293+
1294+
do_I_have_assays && lack_of_consistency
12781295
}
12791296

12801297
check_if_any_dimnames_duplicated <- function(se, dim = "cols") {

0 commit comments

Comments
 (0)