Skip to content

Commit

Permalink
Resolve sapply() -> vapply() BiocCheck NOTE
Browse files Browse the repository at this point in the history
Co-authored-by: Nick Eagles <[email protected]>
  • Loading branch information
lcolladotor and Nick-Eagles committed Jul 26, 2024
1 parent 4b35386 commit 09b1365
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
10 changes: 6 additions & 4 deletions R/add_overlap_info.R
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,12 @@ add_overlap_info <- function(spe, metric_name) {
ungroup()

# Since we only want overlapping spot keys, remove the "identity spot"
col_data$overlap_key <- sapply(
col_data$overlap_key <- vapply(
seq_len(nrow(col_data)),
function(i) {
sub(col_data$key[i], "", col_data$overlap_key[i], fixed = TRUE)
}
},
character(1)
)

# Remove double commas (only possible in the middle) or leading/trailing
Expand All @@ -102,7 +103,7 @@ add_overlap_info <- function(spe, metric_name) {
ungroup() |>
arrange(desc(exclude_overlapping_mean_tmp))

col_data$exclude_overlapping <- sapply(
col_data$exclude_overlapping <- vapply(
seq_len(nrow(col_data)),
function(i) {
# Don't exclude spots that don't overlap anything
Expand All @@ -124,7 +125,8 @@ add_overlap_info <- function(spe, metric_name) {
match(col_data$capture_area[i], metrics_by_id$capture_area)

return(exclude)
}
},
logical(1)
)

# Add colData back to the SpatialExperiment
Expand Down
4 changes: 2 additions & 2 deletions R/prep_fiji_coords.R
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ prep_fiji_coords <- function(sample_info, out_dir) {
# Find paths to input images and the order the corresponding capture
# areas appear in these paths
input_paths <- xml_attr(transform_nodes, "file_path")
input_indices <- sapply(
this_sample_info$capture_area, function(x) grep(x, input_paths)
input_indices <- vapply(
this_sample_info$capture_area, function(x) grep(x, input_paths), integer(1)
)
if (length(input_paths) != nrow(this_sample_info) || any(is.na(input_indices))) {
stop("Expected each capture area to be present exactly once in the input filenames to Fiji for each group.")
Expand Down

0 comments on commit 09b1365

Please sign in to comment.